@font-face {
    font-family: 'NRT';
    src: url('../fonts/NRT-Reg.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'NRT';
    src: url('../fonts/NRT-Bd.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
}

:root {
    --gold-primary: #C79346;
    --gold-light: #E4B962;
    --gold-dark: #A57530;
    --silver: #E0E0E0;
    --white: #FFFFFF;
    
    --bg-dark: #0A0A0A;
    --bg-card: rgba(20, 20, 20, 0.85);
    --border-color: rgba(199, 147, 70, 0.2);
    --sidebar-width: 280px;
    
    --status-pending: #8c8c8c;
    --status-viewed: #4ea8de;
    --status-started: #f0a500;
    --status-paused: #e85d04;
    --status-completed: #2d6a4f;

    --text-primary: #FFFFFF;
    --text-secondary: #A0A0A0;
    --transition: all 0.3s ease;
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    height: 8px; /* For horizontal scrollbars */
    width: 8px;  /* For vertical scrollbars */
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.5); 
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(199, 147, 70, 0.5); /* Gold color */
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(199, 147, 70, 0.8); /* Darker gold */
}

/* For Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(199, 147, 70, 0.5) rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'NRT', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    direction: rtl; 
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

/* Animated Background */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background-color: var(--bg-dark);
    overflow: hidden;
}

.animated-bg::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(199,147,70,0.1) 0%, transparent 70%);
    border-radius: 50%;
    animation: floatingLight 15s ease-in-out infinite alternate;
}

@keyframes floatingLight {
    0% { transform: translate(-50%, -50%) scale(1); }
    33% { transform: translate(10%, -60%) scale(1.2); }
    66% { transform: translate(-60%, 10%) scale(0.9); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* Sidebar Layout */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(15px);
    border-left: 1px solid var(--border-color); /* Left border because RTL */
    position: fixed;
    right: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 3rem;
    text-align: center;
}

.logo-text {
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 2px;
    background: linear-gradient(to right, var(--gold-light), var(--gold-primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 15px; /* Icon and text spacing */
    color: var(--text-secondary);
    text-decoration: none;
    padding: 1rem;
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 1.1rem;
}

.nav-links li a i {
    font-size: 1.3rem;
    width: 25px; /* Fixed width for icons to align text */
    text-align: center;
}

.nav-links li a:hover, .nav-links li a.active {
    background: rgba(199, 147, 70, 0.1);
    color: var(--gold-primary);
    transform: translateX(-5px); /* Move left slightly in RTL */
}

/* Notifications in Sidebar */
.nav-notif-container {
    position: relative;
    cursor: pointer;
}

.notification-count {
    position: absolute;
    top: 50%;
    left: 10px; /* Position on the left side of the link */
    transform: translateY(-50%);
    background: #ff3333;
    color: white;
    font-size: 0.8rem;
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
    font-weight: bold;
}

/* Main Content Area */
.main-wrapper {
    margin-right: var(--sidebar-width); /* Push content from the right */
    flex: 1;
    min-width: 0; /* FIX: allows flex child to shrink and contain table overflow */
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.top-header {
    display: flex;
    justify-content: flex-end; /* Align user profile to the left in RTL */
    padding: 1.5rem 2.5rem;
    background: transparent;
}

.content-area {
    padding: 0 2.5rem 2.5rem 2.5rem;
    flex: 1;
    min-width: 0; /* FIX: prevent flex blowout here too */
}

/* Typography */
h1, h2, h3 {
    color: var(--white);
    margin-bottom: 1rem;
    font-weight: bold;
}

h1 {
    font-size: 2.5rem;
    background: linear-gradient(to right, var(--white), var(--silver));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Cards */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--gold-primary);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

/* Grid Layouts */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    max-width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    color: var(--white);
    font-family: inherit;
    transition: var(--transition);
}

textarea.form-control {
    resize: vertical; /* Prevent horizontal resizing that breaks grids */
    min-height: 45px;
}

.form-control:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 2px rgba(199, 147, 70, 0.2);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.8rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    font-weight: bold;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--gold-light), var(--gold-primary));
    color: #000;
    box-shadow: 0 4px 15px rgba(199, 147, 70, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(199, 147, 70, 0.5);
}

.btn-secondary {
    background: rgba(255,255,255,0.05);
    color: var(--white);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-secondary:hover {
    background: rgba(255,255,255,0.1);
    border-color: var(--gold-primary);
    color: var(--gold-primary);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
}

/* Status Badges */
.badge {
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: bold;
    color: #fff;
    display: inline-block;
}

.status-pending { background-color: var(--status-pending); color: #000; }
.status-viewed { background-color: var(--status-viewed); }
.status-started { background-color: var(--status-started); color: #000; }
.status-paused { background-color: var(--status-paused); }
.status-completed { background-color: var(--status-completed); }
.status-needs_revision { background-color: #e74c3c; }

/* Tables */
.table-container {
    overflow-x: auto;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 1rem;
    text-align: center; /* Center horizontally for better data table look */
    vertical-align: middle; /* Center vertically */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 1px solid rgba(255, 255, 255, 0.02); /* Subtle vertical lines like Excel */
}

th {
    background: rgba(0, 0, 0, 0.4);
    color: var(--gold-light);
    white-space: nowrap; /* Keep headers on single lines */
    font-weight: bold;
}

tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Modals Fixed */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start; /* Ensure top is never cut off */
    overflow: hidden; /* Prevent overlay from scrolling */
}

/* F1: When shown, use flex for proper centering */
.modal-overlay[style*="display: block"],
.modal-overlay[style*="display: flex"] {
    display: flex !important;
}

.modal-content {
    position: relative;
    background: #111;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.5rem;
    width: 100%;
    max-width: 1100px;
    margin: 2vh auto; /* Bring it higher: 2vh from top */
    max-height: 95vh; /* Increased height to 95vh as requested */
    overflow-y: auto; /* INTERNAL scrollbar */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #e74c3c;
    width: 30px;
    height: 30px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 10;
}
.modal-close-btn:hover {
    background: rgba(231, 76, 60, 0.2);
    color: #ff6b6b;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.alert-success {
    background: rgba(45, 106, 79, 0.2);
    border: 1px solid #2d6a4f;
    color: #84dcc6;
}

.alert-error {
    background: rgba(255, 51, 51, 0.2);
    border: 1px solid #ff3333;
    color: #ff9999;
}

/* Notifications Panel in Header */
.notif-panel {
    position: relative;
}

.notif-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--white);
    padding: 0.6rem 1rem;
    border-radius: 30px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
}

.notif-btn:hover {
    border-color: var(--gold-primary);
    color: var(--gold-primary);
}

.notif-badge {
    background: #ff3333;
    color: white;
    font-size: 0.75rem;
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
    font-weight: bold;
}

.notif-menu {
    display: none;
    position: absolute;
    top: 120%;
    left: 0; /* Show to the left of the button in RTL layout */
    width: 320px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
}

.notif-panel:hover .notif-menu, .notif-menu:hover {
    display: block;
}

.notif-item {
    padding: 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: var(--transition);
}

.notif-item:hover {
    background: rgba(199, 147, 70, 0.05);
}

.notif-item.unread {
    border-right: 3px solid var(--gold-primary); /* RTL border right */
    background: rgba(199, 147, 70, 0.02);
}

.notif-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.3rem;
}

/* Layout Utilities */
.flex-modal[style*="display: block"] {
    display: flex !important;
}

/* Animators */
.animate-fade-in {
    animation: fadeIn 0.5s ease forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: none; }
    to { opacity: 1; transform: none; }
}

/* -------------------------------------
   Mobile Responsiveness 
--------------------------------------*/
@media screen and (max-width: 900px) {
    body {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        right: 0;
        z-index: 1000;
        padding: 0.5rem;
        flex-direction: row;
        justify-content: space-around;
        background: rgba(10,10,10,0.95);
        backdrop-filter: blur(10px);
        border-right: none;
        border-top: 1px solid var(--border-color);
    }
    
    .sidebar .sidebar-logo {
        display: none;
    }
    
    .sidebar .nav-links {
        display: flex;
        flex-direction: row;
        width: 100%;
        justify-content: flex-start; /* Changed to allow scrolling */
        gap: 15px;
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 5px; /* For scrollbar space */
    }
    
    .sidebar .nav-links::-webkit-scrollbar {
        height: 4px;
    }
    .sidebar .nav-links::-webkit-scrollbar-thumb {
        background: rgba(255,255,255,0.2);
        border-radius: 4px;
    }
    
    .sidebar .nav-links li {
        margin: 0;
        flex: 0 0 auto; /* Prevent shrinking */
    }
    
    .sidebar .nav-links a {
        padding: 0.5rem;
        font-size: 0.75rem;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        text-align: center;
        width: 70px; /* Fixed width for better look */
    }
    
    .sidebar .nav-links a i {
        font-size: 1.2rem;
        margin: 0;
    }
    
    .sidebar .nav-links li:last-child {
        display: block; /* Show logout button again */
    }

    .main-wrapper {
        margin-right: 0 !important;
        margin-bottom: 80px; /* Increased space for the bottom nav bar with scrollbar */
        padding: 0.5rem;
    }
    
    .top-header {
        padding: 1rem;
    }
    
    .content-area {
        padding: 0 1rem 1rem 1rem;
    }
    
    /* Modals & Forms */
    .modal-content {
        width: 95%;
        padding: 1.5rem;
        margin-top: 2rem;
    }
    
    div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }
    
    /* Tables */
    .table-container {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    table {
        font-size: 0.9rem;
    }
    
    th, td {
        padding: 0.75rem;
    }
    
    /* Cards */
    .grid-cards {
        grid-template-columns: 1fr;
    }
    
    /* Headers */
    h1 {
        font-size: 1.8rem;
    }
}
