* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    background: #f5f6fa;
    color: #333;
    direction: rtl;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-container {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-container h1 {
    color: #2c3e50;
    margin-bottom: 5px;
    font-size: 1.4em;
}

.login-container h2 {
    color: #7f8c8d;
    font-size: 1em;
    font-weight: normal;
    margin-bottom: 25px;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 {
    font-size: 1em;
    color: #ecf0f1;
}

.sidebar-menu {
    list-style: none;
    flex: 1;
    padding: 10px 0;
}

.sidebar-menu li a {
    display: block;
    padding: 12px 20px;
    color: #bdc3c7;
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-menu li a:hover,
.sidebar-menu li.active a {
    background: rgba(255,255,255,0.1);
    color: white;
    border-right: 3px solid #3498db;
}

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.content {
    flex: 1;
    margin-right: 250px;
    padding: 25px;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
    text-align: right;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    text-align: right;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #3498db;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    text-decoration: none;
    display: inline-block;
    transition: opacity 0.3s;
}

.btn:hover {
    opacity: 0.85;
}

.btn-primary { background: #3498db; color: white; }
.btn-success { background: #27ae60; color: white; }
.btn-danger { background: #e74c3c; color: white; }
.btn-warning { background: #f39c12; color: white; }
.btn-secondary { background: #95a5a6; color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }
.btn-group { display: flex; gap: 5px; }

/* Alerts */
.alert {
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
}

.alert-error { background: #fdecea; color: #c0392b; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card .number {
    font-size: 2em;
    font-weight: bold;
    color: #2c3e50;
}

.stat-card .label {
    color: #7f8c8d;
    margin-top: 5px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.page-header h2 {
    color: #2c3e50;
}

/* Tables */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    /* The table itself scrolls within this fixed height instead of the
       whole page growing with it — long lists (files, users, audit log,
       dashboard widgets) no longer push the page footer far below the fold. */
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: right;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: bold;
    color: #555;
    /* Stays visible while the body scrolls underneath it, so columns are
       still identifiable no matter how far down the list you've scrolled. */
    position: sticky;
    top: 0;
    z-index: 1;
}

tr:hover {
    background: #f8f9fa;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: 8px;
    padding: 25px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 {
    margin-bottom: 20px;
    color: #2c3e50;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-start;
}

/* Option sections */
.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.option-section {
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.option-section-header {
    background: #3498db;
    color: white;
    padding: 15px 20px;
    font-size: 1.1em;
    font-weight: bold;
    flex-shrink: 0;
}

.option-section-body {
    padding: 20px;
}

.option-value-list {
    max-height: 140px;
    overflow-y: auto;
}

.option-value-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #eee;
    border-radius: 4px;
    margin-bottom: 8px;
}

.add-value-form {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.add-value-form input {
    flex: 1;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-align: right;
}

/* Severity / status badges (dashboard security widgets) */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

.badge-info { background: #eaf2fb; color: #2980b9; }
.badge-warning { background: #fff3cd; color: #8a6d00; }
.badge-critical { background: #fdecea; color: #c0392b; }
.badge-success { background: #d4edda; color: #1e7e34; }

.row-danger td {
    background: #fdecea;
}

/* File upload form */
.upload-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Utility classes — introduced to remove every inline style="" attribute
   from admin/, so the CSP's style-src can drop 'unsafe-inline' (see
   admin/includes/security_headers.php). Each one maps 1:1 to a property
   value that used to be written inline. */
.d-inline { display: inline; }
.d-none { display: none; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-10 { gap: 10px; }
.text-center { text-align: center; }
.text-muted { color: #999; }
.text-mono { font-family: monospace; }
.text-sm { font-size: 12px; }
.text-uppercase { text-transform: uppercase; }
.text-danger { color: #e74c3c; }
.text-success { color: #27ae60; }
.text-info { color: #3498db; }
.mt-10 { margin-top: 10px; }
.mt-15 { margin-top: 15px; }
.mt-30 { margin-top: 30px; }
.mb-15 { margin-bottom: 15px; }
.m-0 { margin: 0; }
.p-20 { padding: 20px; }

/* Page-specific compound styles that don't reduce meaningfully to the
   generic utilities above. */
.ua-cell {
    font-size: 12px;
    color: #666;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.filter-form {
    display: flex;
    gap: 10px;
    align-items: end;
    padding: 15px;
    flex-wrap: wrap;
}

.pagination-bar {
    display: flex;
    gap: 8px;
    margin-top: 15px;
    align-items: center;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar { width: 200px; }
    .content { margin-right: 200px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .options-grid { grid-template-columns: 1fr; }
    .upload-form .form-row { grid-template-columns: 1fr; }
}
