/* Import Google Fonts - Luxury Collection */
/* English: Playfair Display (Headings), Montserrat (Body) */
/* Arabic: El Messiri (Headings), Cairo (Body) */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700&family=El+Messiri:wght@400;500;600;700&family=Montserrat:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* Define Color & Font Variables */
:root {
    /* --- RovaCore Royal Blue Theme --- */
    --sidebar-bg: #0A3D62; /* Royal Blue */
    --sidebar-color: #cbd5e1; /* Light Gray Text */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px; /* Width when collapsed */
    --sidebar-border: #1e4b75; 
    
    --brand-primary: #0A3D62; 
    --brand-accent: #ffffff;  
    --active-bg: rgba(255, 255, 255, 0.15); /* Glass effect for active items */
    --hover-bg: rgba(255, 255, 255, 0.05);
    
    --header-height: 70px;
    --bg-body: #f8f9fa; /* Slightly lighter, cleaner background */

    /* --- Google Home / Material Font Stacks --- */
    --font-heading-en: 'Outfit', sans-serif;
    --font-heading-ar: 'Readex Pro', sans-serif;
    --font-body-en: 'Roboto', sans-serif;
    --font-body-ar: 'Almarai', sans-serif;
}

body {
    /* Default to English Body + Arabic Body */
    font-family: var(--font-body-en), var(--font-body-ar);
    background-color: var(--bg-body);
    color: #334155;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    font-weight: 400;
}

/* Apply Luxury Headings */
h1, h2, h3, h4, h5, h6, .brand-text {
    font-family: var(--font-heading-en), var(--font-heading-ar);
    font-weight: 700;
    letter-spacing: -0.5px; /* Tighter tracking for elegance */
}

/* RTL Support for Headings */
html[dir="rtl"] h1, 
html[dir="rtl"] h2, 
html[dir="rtl"] h3, 
html[dir="rtl"] h4, 
html[dir="rtl"] h5, 
html[dir="rtl"] h6,
html[dir="rtl"] .brand-text {
    font-family: var(--font-heading-ar), var(--font-heading-en);
    letter-spacing: 0;
}

/* --- SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    color: var(--sidebar-color);
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1050;
    transition: width 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0,0,0,0.15); /* Slightly deeper shadow */
    overflow: hidden; 
}

/* Sidebar Header */
.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center; 
    padding: 0 1rem; 
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background-color: rgba(0,0,0,0.2); 
    white-space: nowrap;
}

/* Toggler inside Sidebar */
.sidebar-toggler {
    background: none;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%; 
}
.sidebar-toggler:hover {
    background-color: rgba(255,255,255,0.1);
}

/* Logo Images */
.logo-img {
    max-width: 150px;
    width: auto;
    object-fit: contain;
    display: block; 
}
.logo-img2 {
    max-height: 40px;
    width: auto;
    object-fit: contain;
    display: none; 
}

/* Menu */
.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 0.8rem;
    list-style: none;
    margin: 0;
}

/* Custom Scrollbar */
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 3px; }

.menu-label {
    /* Luxury label style */
    font-family: var(--font-body-en), var(--font-body-ar);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px; /* More spacing for luxury feel */
    color: #94a3b8; 
    margin: 1.5rem 0 0.5rem 1rem;
    font-weight: 600;
    opacity: 0.8;
    white-space: nowrap;
    transition: opacity 0.2s;
}
html[dir="rtl"] .menu-label { letter-spacing: 0; }
.menu-label:first-child { margin-top: 0; }

.nav-link-custom {
    display: flex;
    align-items: center;
    padding: 0.75rem 0.8rem;
    color: var(--sidebar-color);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    white-space: nowrap;
}

/* HOVER STATE */
.nav-link-custom:hover {
    background-color: var(--hover-bg);
    color: #ffffff;
    border-left-color: rgba(255,255,255,0.5);
}

/* ACTIVE STATE */
.nav-link-custom.active {
    background-color: var(--active-bg);
    color: #ffffff;
    font-weight: 600;
    border-left-color: #ffffff; 
}

.nav-icon {
    min-width: 24px; 
    margin-right: 12px;
    font-size: 1.1rem;
    text-align: center;
    opacity: 0.9;
}

.nav-text {
    transition: opacity 0.2s;
}

/* Submenus */
.collapse-menu {
    list-style: none;
    padding-left: 0;
    margin-top: 0.25rem;
    background-color: rgba(0,0,0,0.15); 
    border-radius: 8px;
}

.submenu-link {
    display: block;
    padding: 0.6rem 1rem 0.6rem 3.25rem; 
    color: #cbd5e1;
    text-decoration: none;
    font-size: 0.9rem;
    white-space: nowrap;
}
.submenu-link:hover { color: #ffffff; background-color: var(--hover-bg); }
.submenu-link.active { color: #ffffff; background-color: var(--active-bg); font-weight: 600; }

.submenu-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.nav-link-custom[aria-expanded="true"] .submenu-arrow {
    transform: rotate(180deg);
}

/* --- COLLAPSED STATE (DESKTOP) --- */
body.sidebar-closed .sidebar {
    width: var(--sidebar-collapsed-width);
}

body.sidebar-closed .menu-label,
body.sidebar-closed .nav-text,
body.sidebar-closed .submenu-arrow {
    opacity: 0;
    display: none;
}

/* Toggle Logo Visibility on Collapse */
body.sidebar-closed .logo-img {
    display: none;
}
body.sidebar-closed .logo-img2 {
    display: block;
}

body.sidebar-closed .sidebar-header {
    justify-content: center;
    padding: 0;
}

body.sidebar-closed .sidebar-toggler {
    margin: 0;
}

body.sidebar-closed .nav-link-custom {
    justify-content: center;
    padding: 0.75rem 0;
}

body.sidebar-closed .nav-icon {
    margin-right: 0;
}

body.sidebar-closed .collapse-menu {
    display: none !important; /* Force hide submenus when collapsed */
}

/* --- MAIN CONTENT AREA --- */
.wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease-in-out;
}

/* Wrapper adjustment when collapsed */
body.sidebar-closed .wrapper {
    margin-left: var(--sidebar-collapsed-width);
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background-color: #707070;
    border-bottom: 1px solid #aeaeae;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 1040;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* Mobile Header Toggler (Only visible on mobile) */
.mobile-header-toggler {
    display: none; 
    border: none;
    background: none;
    font-size: 1.5rem;
    color: #334155;
    padding: 5px;
}

.user-menu { display: flex; align-items: center; gap: 1rem; }
.icon-btn {
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
    border-radius: 50%; color: #64748b; text-decoration: none; position: relative;
    transition: all 0.2s;
}
.icon-btn:hover { background-color: #f1f5f9; color: var(--brand-primary); }
.badge-notif { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; background-color: #ef4444; border-radius: 50%; border: 1px solid #fff; }

.content-body {
    padding: 2rem;
    flex: 1;
    background-color: var(--bg-body);
}

/* --- MOBILE RESPONSIVE --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1045;
}

@media (max-width: 991.98px) {
    .sidebar { 
        transform: translateX(-100%); 
        width: var(--sidebar-width); 
    }
    html[dir="rtl"] .sidebar { transform: translateX(100%); }
    
    .wrapper { margin-left: 0 !important; margin-right: 0 !important; }
    
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-overlay { display: block; }
    
    .mobile-header-toggler { display: block; } 
    .sidebar-toggler { display: none; } 
    
    .brand-container { display: flex !important; }
    .brand-text { display: block !important; opacity: 1 !important; }
}

/* RTL Handling */
html[dir="rtl"] .sidebar {
    left: auto; right: 0; border-right: none; border-left: 1px solid var(--sidebar-border);
}
html[dir="rtl"] .wrapper {
    margin-left: 0; margin-right: var(--sidebar-width);
}
html[dir="rtl"] body.sidebar-closed .wrapper {
    margin-right: var(--sidebar-collapsed-width);
}

/* Basic Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


/* Table Styling for Luxury Feel */
/* Tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: #FFFFFF; /* White background for tables */
    vertical-align: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); 
}

/* FIX: Removed default background from all table cells */
table, th, td {
    border: 1px solid #ddd; 
    vertical-align: middle; 
}

th {
    background-color: var(--rovacore-blue); /* Use new primary blue */
    color: var(--platinum-white);
    padding: 10px; 
    font-size: 14px; 
    text-align: center;
    vertical-align: center;
}

/* FIX: Removed default background from tr */
tr {
    color: var(--rich-black);
    padding: 10px; 
    font-size: 14px; 
    text-align: center;
    vertical-align: center;
}
td {
    padding: 10px;
    text-align: center;
    font-size: 14px; 
    vertical-align: center;
}
    .btn-sort {
        padding: 0.1rem 0.3rem;
        font-size: 0.6rem;
        margin-left: 0.2rem;
    }

/* Preserve Your Row Background Colors */
.tablenew tr:nth-child(even) {
    background-color: var(--platinum-white); /* Use new light background */
}

.tablenew tr:nth-child(odd) {
    background-color: #FFFFFF; /* White for odd rows */
}

.tablenew tr:hover {
    background-color: #e9ecef; /* Standard Bootstrap hover */
}
.tablenew td, .tablenew th {
    vertical-align: middle;
    background-color: initial !important; /* Let striping control the color */
    color: var(--rich-black) !important; /* Use new dark text color */
}

/* Buttons - Elegant Style */
.btn, .btnnew, .apply-filters-btn {
    padding: 10px 20px; 
    background-color: var(--brand-primary); 
    color: var(--brand-accent);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-size: 0.9rem; 
    font-weight: 500;
    border: none; 
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(10, 61, 98, 0.2);
    font-family: var(--font-body-en), var(--font-body-ar);
}

.btn:hover, .btnnew:hover, .apply-filters-btn:hover {
    background-color: #144f7a; 
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(10, 61, 98, 0.3);
}

/* Cards - Elegant Style */
.card {
    background-color: #FFFFFF; 
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 24px; 
    margin-bottom: 24px;
    border: 1px solid #f1f5f9;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Inputs */
input, select, textarea {
    padding: 10px 15px; 
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem; 
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: var(--font-body-en), var(--font-body-ar);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(10, 61, 98, 0.1);
}

/* Flash Messages */
.flash {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-size: 0.95rem; 
    border-left: 4px solid transparent;
}

.flash.success {
    background-color: #dcfce7;
    color: #166534;
    border-left-color: #166534;
}

.flash.error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left-color: #991b1b;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    background-color: #ffffff;
    color: #64748b;
    font-size: 0.85rem; 
    margin-top: auto;
    border-top: 1px solid #e2e8f0;
}

/* RTL Helpers */
html[dir="rtl"] .sidebar-toggler { margin-right: 0; margin-left: 10px; }
html[dir="rtl"] .nav-icon { margin-right: 0; margin-left: 12px; }
html[dir="rtl"] .brand-text { margin-left: 0; margin-right: 10px; }
html[dir="rtl"] .nav-link-custom { border-left: none; border-right: 3px solid transparent; }
html[dir="rtl"] .nav-link-custom:hover { border-right-color: rgba(255,255,255,0.5); }
html[dir="rtl"] .nav-link-custom.active { border-right-color: #ffffff; }
html[dir="rtl"] .submenu-link { padding: 0.6rem 3.25rem 0.6rem 1rem; }
html[dir="rtl"] .submenu-arrow { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .nav-link-custom[aria-expanded="true"] .submenu-arrow { transform: rotate(-180deg); }
html[dir="rtl"] .flash { border-left: none; border-right: 4px solid transparent; }
html[dir="rtl"] .flash.success { border-right-color: #166534; }
html[dir="rtl"] .flash.error { border-right-color: #991b1b; }
