/* ==========================================================================
   SHARED STYLES - FSDC V3 (Final) - REFACTORED
   ========================================================================== */
:root {
    --font-primary: 'Cairo', sans-serif; 
    --font-display: 'Cairo', sans-serif;
    --transition-fast: 0.2s ease-in-out; --transition-smooth: 0.3s ease-in-out;
    --bg-primary-light: #f4f7f9; --bg-secondary-light: #ffffff; --text-primary-light: #1a202c; --text-secondary-light: #4a5568; --border-light: #e2e8f0; --accent-primary-light: #034667; --accent-hover-light: #023650;

    /* FDR Color Palette */
    --fdr-1-bg: #00b050;
    --fdr-2-bg: #92d050;
    --fdr-3-bg: #ffff00;
    --fdr-4-bg: #ffc000;
    --fdr-5-bg: #ff0000;
    --fdr-6-bg: #c00000;
    --fdr-7-bg: #8b0000;
    --fdr-light-text: white;
    --fdr-dark-text: #1a202c;
}
.theme-dark {
    --bg-primary-dark: #0f172a; --bg-secondary-dark: #1e293b; --text-primary-dark: #94a3b8; /* THE FIX: Unified grey color */ --text-secondary-dark: #94a3b8; --border-dark: #334155; --accent-primary-dark: #38bdf8; --accent-hover-dark: #7dd3fc;
}
body.theme-light {
    --bg-primary: var(--bg-primary-light); --bg-secondary: var(--bg-secondary-light); --text-primary: var(--text-primary-light); --text-secondary: var(--text-secondary-light); --border-color: var(--border-light); --accent-color: var(--accent-primary-light); --accent-hover: var(--accent-hover-light);
}
body.theme-dark {
    --bg-primary: var(--bg-primary-dark); --bg-secondary: var(--bg-secondary-dark); --text-primary: var(--text-primary-dark); --text-secondary: var(--text-secondary-dark); --border-color: var(--border-dark); --accent-color: var(--accent-primary-dark); --accent-hover: var(--accent-hover-dark);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-primary); transition: background-color var(--transition-smooth), color var(--transition-smooth); background-color: var(--bg-primary); color: var(--text-primary); }
h1, h2, h3 { font-family: var(--font-display); color: var(--text-primary); }

.section-title {
    text-align: center;
    margin-bottom: 16px;
    margin-top: 24px;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.25rem;
}

a { color: var(--accent-color); text-decoration: none; }
.app-layout { display: flex; min-height: 100vh; }

#authContainer {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    width: 100%;
}

.main-content {
    flex-grow: 1;
    padding: 24px;
    overflow-y: auto;
    min-width: 0; 
}

#content-wrapper {
    width: 100%;
    max-width: 1140px;
    margin-left: auto;
    margin-right: auto;
}

.sidebar { flex-shrink: 0; width: 240px; background-color: var(--bg-secondary); border-right: 1px solid var(--border-color); display: flex; flex-direction: column; padding: 12px; transition: left var(--transition-smooth), right var(--transition-smooth); }
#menuToggle { display: none; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -280px; right: auto; width: 280px; height: 100%; z-index: 2002; }
    .sidebar.open { left: 0; right: auto; box-shadow: 0 0 40px rgba(0,0,0,0.2); }
    #menuToggle { display: block; position: fixed; top: 18px; left: 18px; right: auto; z-index: 1002; font-size: 1.5rem; background: var(--bg-secondary); padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border-color); }
    .main-content { padding: 16px; padding-top: 80px; }
}
.sidebar-header { justify-content: center; display: flex; align-items: center; gap: 12px; font-size: 1.5rem; font-weight: 700; padding-bottom: 12px; margin-bottom: 16px; border-bottom: 1px solid var(--border-color); color: var(--accent-color); height: 40px; }
.header-text { white-space: nowrap; font-weight: 700; font-size: 1.5rem; }

/* --- CORRECTED STYLES FOR SIDEBAR LOGO --- */
.sidebar-header img {
    max-width: 100%;
    height: auto;
    max-height: 35px;
}
.theme-light .logo-sidebar-dark, .theme-dark .logo-sidebar-light { display: none; }
.theme-light .logo-sidebar-light, .theme-dark .logo-sidebar-dark { display: inline-block; }
/* --- END OF STYLES --- */

.nav-item { display: flex; align-items: center; padding: 10px; margin-bottom: 4px; border-radius: 6px; text-decoration: none; color: var(--text-secondary); font-weight: 500; transition: background-color var(--transition-fast), color var(--transition-fast); white-space: nowrap; cursor: pointer; }
.nav-icon { font-size: 1.25rem; min-width: 32px; text-align: center; flex-shrink: 0; }
.nav-text { margin-left: 12px; }
.nav-item:hover { background-color: var(--bg-primary); color: var(--text-primary); }
.nav-item.active { background-color: var(--accent-color); color: white; }
.sidebar-footer { margin-top: auto; white-space: nowrap; }
.sidebar-footer p { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 10px; }
.submenu { padding-left: 15px; margin-top: 4px; }
.submenu .nav-item { padding-left: 32px; }
.submenu .nav-icon { font-size: 1rem; }
.submenu .nav-text { font-size: 0.9rem; }
.control-room-buttons { display: flex; justify-content: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.btn { padding: 4px 12px; border-radius: 6px; font-weight: 600; font-size: 1rem; cursor: pointer; transition: all var(--transition-fast); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-primary); }
.btn-outline { background-color: transparent; color: var(--text-primary); border: 1px solid var(--accent-color); }
.btn-outline:hover:not(:disabled) { background-color: var(--accent-color); color: white; }
.btn-active, .control-room-buttons .btn-active { background-color: var(--accent-color); color: white; border: 1px solid var(--accent-color); }
.btn-active:hover:not(:disabled) { background-color: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { background-color: var(--border-color); color: var(--text-secondary); border-color: var(--border-color); cursor: not-allowed; opacity: 0.6; }

/* === MY CORRECTED AND FINAL FIX === */
/* Establishes a global, consistent style for text inputs */
input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    padding: 4px 12px; /* Match button vertical padding */
    font-size: 1rem;      /* Match button font size */
    border-radius: 6px;   /* Match button border radius */
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-primary);
}
/* === END OF FIX === */

.table-container { width: 100%; background-color: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; overflow-x: auto; }
/* FIX: Removed the conflicting grid-template-columns property from the global style */
.data-grid { display: grid; font-size: 0.8rem; min-width: 450px; }
.grid-header, .grid-cell { padding: 4px 2px; text-align: center; border-bottom: 1px solid var(--border-color); border-right: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; min-height: 38px; }
.grid-header { padding: 8px 4px; background-color: var(--bg-primary); font-weight: 600; color: var(--text-secondary); text-transform: uppercase; font-size: 0.7rem; }
.grid-header:last-child, .grid-cell:last-child { border-right: none; }
.data-grid > div:last-of-type { border-bottom: none; }
.grid-cell > span { display: inline-flex; align-items: center; justify-content: center; width: auto; padding: 3px 8px; font-weight: 600; border: 1px solid transparent; border-radius: 4px; }
.grid-cell:first-child > span { font-weight: 700; background-color: transparent !important; border-color: transparent !important; color: var(--text-primary); }
.grid-cell-total > span { background-color: transparent !important; border-color: transparent !important; font-weight: 700; color: var(--text-primary); }
.header-with-toggle { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; flex-wrap: wrap; gap: 16px; }

/* --- REVERTED HEADER STYLES TO FIX LAYOUT --- */
.global-header {
    position: relative;
    display: flex;
    flex-direction: column;
    margin-bottom: 24px;
    height: 100px;
}

.header-top-right-controls { position: absolute; top: 0; right: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.logo-container { text-align: center; margin-top: auto; } /* This line was added from the old file to ensure the logo is centered vertically */
.logo-container img { height: 100px; width: auto; }
.theme-light .logo-dark, .theme-dark .logo-light { display: none; }
.theme-light .logo-light, .theme-dark .logo-dark { display: inline-block; }

.theme-switch-wrapper { display: flex; align-items: center; gap: 10px; }
.theme-switch { position: relative; display: inline-block; width: 45px; height: 25px; }
.theme-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; transition: .4s; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 4px; bottom: 4px; background-color: white; transition: .4s; }
input:checked + .slider { background-color: var(--accent-color); }
input:checked + .slider:before { transform: translateX(20px); }
.slider.round { border-radius: 25px; }
.slider.round:before { border-radius: 50%; }

.loading-container { display: flex; justify-content: center; align-items: center; padding: 40px; height: 200px; }
.loading-message, .error-message { font-size: 1.2rem; color: var(--text-secondary); }
.error-message { color: var(--fdr-5-bg); }

/* --- START: UNIVERSAL MODAL STYLES --- */
.modal-content {
    max-height: 90vh; /* Ensure modal never exceeds viewport height */
    overflow-y: auto;   /* Add a scrollbar if the content inside is too tall */
}
/* --- END: UNIVERSAL MODAL STYLES --- */


/* --- I18N and RTL Styles --- */
.language-switcher { display: flex; gap: 5px; }
.btn-lang { background: none; border: 1px solid var(--border-color); color: var(--text-secondary); font-family: var(--font-primary); font-weight: 600; padding: 5px 10px; border-radius: 6px; cursor: pointer; transition: all var(--transition-fast); }
.btn-lang.active { background-color: var(--accent-color); color: white; border-color: var(--accent-color); }
.btn-lang:not(.active):hover { border-color: var(--text-primary); color: var(--text-primary); }

[dir="rtl"] .sidebar { border-right: none; border-left: 1px solid var(--border-color); }
[dir="rtl"] .nav-text { margin-left: 0; margin-right: 12px; }
[dir="rtl"] .sidebar-footer p { text-align: right; }
[dir="rtl"] .header-top-right-controls { right: auto; left: 0; align-items: flex-start; }

@media (max-width: 768px) {
    [dir="rtl"] .sidebar { left: auto; right: -280px; }
    [dir="rtl"] .sidebar.open { left: auto; right: 0; }
    [dir="rtl"] #menuToggle { left: auto; right: 18px; }
}

/* --- UPDATED: Force LTR on Tables in RTL Mode --- */
[dir="rtl"] .table-container,
[dir="rtl"] .data-grid {
    direction: ltr;
}

/* Home Page Content Styles */
.home-content {
    text-align: center;
    padding: 20px;
}
.update-notes {
    margin-top: 30px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}
.update-notes h2 {
    font-size: 1.2rem;
    color: var(--accent-color);
    margin-bottom: 10px;
}
.update-notes ul {
    list-style-type: none;
    padding-left: 0;
    margin-bottom: 20px;
}
.update-notes li {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
}
[dir="rtl"] .update-notes {
    text-align: right;
}