/* ====================
   GLOBAL & LAYOUT
==================== */
:root {
    --primary-color: #880808;
    --primary-color-dark: #6a0606;
    --primary-color-light: #fbeaea;
    --primary-color-border: #e08e8e;
    --sidebar-width: 240px;
    --top-bar-height: 60px;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    background-color: #f4f7f9;
    color: #333;
    margin: 0;
    padding: 0;
    padding-top: var(--top-bar-height); 
}
.app-container {
    display: flex;
    position: relative;
    min-height: calc(100vh - var(--top-bar-height));
}
hr, .settings-hr {
    border: 0;
    border-top: 1px solid #eee;
    margin: 25px 0;
}

/* ====================
   TOP BAR (Desktop & Mobile)
==================== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-bar-height);
    background: #fff;
    border-bottom: 1px solid #e7e7e7;
    display: flex;
    align-items: center;
    padding: 0 15px;
    z-index: 1001;
    box-sizing: border-box;
}
.top-bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.top-bar-left {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: flex-start;
}
.top-bar-center {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
    display: none; /* Hidden on desktop */
}
.top-bar-right {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: flex-end;
}
.top-bar-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--primary-color);
}
.top-bar-logo {
    height: 35px;
    width: auto;
}
.top-bar-title {
    font-size: 1.2rem;
    font-weight: 700;
}

/* --- Profile Dropdown (Desktop Only) --- */
.profile-dropdown {
    position: relative;
    display: block;
    padding-top: 10px;
    padding-bottom: 10px;
    margin-top: -10px;
    margin-bottom: -10px;
}
.profile-dropbtn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 0.9rem;
    color: #333;
    padding: 5px;
    border-radius: 5px;
    transition: background-color 0.2s;
}
.profile-dropdown:hover {
    background-color: #f4f4f4;
}
.profile-dropbtn i {
    font-size: 1.5rem;
    margin-right: 8px;
    color: #777;
}
.profile-dropbtn span {
    margin-right: 5px;
    font-weight: 500;
}
.profile-dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background-color: #fff;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 8px;
    z-index: 1002;
    padding: 10px 0;
    margin-top: 0;
}
.profile-dropdown:hover .profile-dropdown-content {
    display: block;
}
.profile-dropdown-content a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}
.profile-dropdown-content a i {
    width: 25px;
    margin-right: 10px;
    color: #777;
    text-align: center;
}
.profile-dropdown-content a:hover {
    background-color: #f4f4f4;
    color: var(--primary-color);
}
.dropdown-divider {
    height: 1px;
    background: #eee;
    margin: 8px 0;
}

/* --- Mobile Icons --- */
.mobile-menu-toggle {
    display: none;
    font-size: 1.5rem;
    color: #333;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 10px;
}
.mobile-profile-toggle {
    display: none;
    font-size: 1.5rem;
    color: #333;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 10px;
}
.mobile-logo-link {
    display: none; 
}
.desktop-logo-link {
    display: flex; 
}
.mobile-profile-dropdown {
    display: none; 
    position: fixed;
    top: var(--top-bar-height);
    right: 10px;
    background-color: #fff;
    min-width: 200px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
    border-radius: 8px;
    z-index: 1004;
    padding: 10px 0;
}
.mobile-profile-dropdown.is-open {
    display: block;
}
.mobile-profile-dropdown a {
    color: #333;
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}
.mobile-profile-dropdown a i {
    width: 25px;
    margin-right: 10px;
    color: #777;
    text-align: center;
}

/* ====================
   DESKTOP SIDEBAR (SCROLL FIX)
==================== */
.sidebar {
    width: var(--sidebar-width);
    position: fixed;
    top: var(--top-bar-height);
    left: 0;
    height: calc(100vh - var(--top-bar-height)); 
    background-color: #ffffff;
    border-right: 1px solid #e7e7e7;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}
.sidebar-brand {
    display: none;
}
.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    height: 100%;
    overflow-y: auto;
    padding-top: 10px;
    padding-bottom: 20px;
}
.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
    font-size: 1rem;
    border-left: 4px solid transparent;
}
.sidebar-menu li a:hover { background-color: #f4f4f4; color: var(--primary-color); }
.sidebar-menu li a.active { background-color: #f4f4f4; border-left-color: var(--primary-color); font-weight: 600; }
.sidebar-menu li a i { width: 30px; margin-right: 15px; text-align: center; font-size: 1.1rem; }
.sidebar-menu .menu-header { padding: 10px 25px; font-size: 0.8em; color: #999; text-transform: uppercase; font-weight: 600; margin-top: 15px; }

/* ====================
   MOBILE SIDEBAR
==================== */
.mobile-sidebar {
    position: fixed;
    top: 0; 
    left: 0;
    width: 280px;
    height: 100vh;
    background: #fff;
    z-index: 1003;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    display: none;
    flex-direction: column;
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
}
.mobile-sidebar.is-open { transform: translateX(0); }
.mobile-sidebar .sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    height: var(--top-bar-height);
    border-bottom: 1px solid #eee;
    padding: 0 20px;
    text-decoration: none;
    color: var(--primary-color);
}
.mobile-sidebar .sidebar-logo { max-height: 35px; }
.mobile-sidebar .sidebar-menu { height: calc(100% - var(--top-bar-height)); overflow-y: auto; padding-top: 10px; }
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0,0,0,0.5);
    z-index: 1002;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.is-open { display: block; opacity: 1; }

/* ====================
   MAIN CONTENT AREA (LAYOUT FIX)
==================== */
.content-wrapper {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: calc(100vh - var(--top-bar-height));
}
.main-content {
    width: 100%;
    padding: 30px;
    box-sizing: border-box;
    flex-grow: 1;
    background-color: #f4f7f9; /* This is the main content background color */
}
.footer {
    width: 100%;
    text-align: center;
    padding: 20px 30px;
    background-color: #e9ecef;
    color: #6c757d;
    font-size: 0.9em;
    box-sizing: border-box;
    margin-top: auto;
}

/* ====================
   COMPONENT STYLES
==================== */

/* --- Forms & "Bordered Box" --- */
.form-container, 
.admin-container { 
    background: #fff; 
    padding: 20px 30px; 
    border-radius: 8px; 
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); 
    margin-bottom: 20px; 
    border: 1px solid #e9ecef; /* This is the "bordered box" style */
}
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.admin-header h1 {
    margin: 0;
    font-size: 2rem;
}
.admin-header .btn {
    width: auto;
    display: inline-block;
}
.form-container h2 { text-align: center; color: var(--primary-color); }
.form-row { display: flex; gap: 20px; }
.form-group { flex: 1; margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 600; }
.form-group label sup { color: #dc3545; }
.form-control { width: 100%; padding: 10px 12px; font-size: 1rem; border: 1px solid #ddd; border-radius: 5px; box-sizing: border-box; transition: border-color 0.2s, box-shadow 0.2s; }
.form-control:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(136,8,8,.1); outline: 0; }
.form-control.is-invalid { border-color: #dc3545; }
.invalid-feedback { color: #dc3545; font-size: .875em; display: none; margin-top: 5px; }
.is-invalid + .invalid-feedback { display: block; }
.btn, button { padding: 10px 15px; font-size: 1rem; border-radius: 5px; cursor: pointer; text-decoration: none; border: none; font-weight: 500; display: inline-block; transition: background-color .2s ease-in-out, border-color 0.2s; }
.btn-success { background-color: #28a745; color: #fff; } .btn-success:hover { background-color: #218838; }
.btn-light { background-color: #f8f9fa; color: #333; border: 1px solid #ddd; } .btn-light:hover { background-color: #e2e6ea; }
.btn-block { width: 100%; text-align: center; box-sizing: border-box; }

/* --- Tables & Actions --- */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 12px rgba(0,0,0,0.05); }
.data-table th, .data-table td { text-align: left; padding: 12px 15px; border-bottom: 1px solid #ddd; vertical-align: middle;}
.data-table th { background-color: #f8f9fa; font-size: 0.9em; text-transform: uppercase; color: #555; }
.data-table tbody tr:hover { background-color: #f1f1f1; }
.actions-group { display: flex; gap: 8px; align-items: center; }
.actions-group form { margin: 0; }
.action-btn { border: none; background: none; cursor: pointer; padding: 6px 10px; border-radius: 4px; font-size: 0.9em; text-decoration: none; display: inline-flex; align-items: center; gap: 5px; color: #fff; white-space: nowrap; }
.action-btn i { font-size: 0.9em; }
.edit-btn { background-color: #ffc107; color: #fff; } .edit-btn:hover { background-color: #e0a800; }
.delete-btn { background-color: #dc3545; color: #fff; } .delete-btn:hover { background-color: #c82333; }
.assign-btn { background-color: #007bff; } .assign-btn:hover { background-color: #0069d9; }
.disable-btn { background-color: #6c757d; } .disable-btn:hover { background-color: #5a6268; }

/* --- Badges --- */
.status-badge, .role-badge { padding: 4px 10px; border-radius: 12px; font-size: 0.8em; color: #fff; font-weight: 600; text-transform: capitalize; }
.status-active { background-color: #28a745; }
.status-pending-approval, .status-pending-verification { background-color: #ffc107; color: #333; }
.status-disabled { background-color: #6c757d; }
.status-expired { background-color: #dc3545; }
.role-admin { background-color: var(--primary-color); }
.role-user { background-color: #6c757d; }

/* --- Settings Page --- */
.settings-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; }
.settings-grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 30px; }
.preview-img { max-height: 80px; max-width: 150px; background: #eee; padding: 10px; border-radius: 5px; margin-top: 5px; display: block; border: 1px solid #ddd; }
.weekday-selector { display: flex; flex-wrap: wrap; gap: 15px; background: #f8f9fa; padding: 15px; border-radius: 5px; }
.weekday-selector label { user-select: none; }

/* --- Dashboard: Banner Slider --- */
.banner-slider-container { position: relative; width: 100%; height: auto; overflow: hidden; border-radius: 8px; margin-bottom: 30px; background-color: #222; }
.slider-progress-container { position: absolute; top: 0; left: 0; width: 100%; height: 4px; background-color: rgba(255, 255, 255, 0.3); z-index: 20; }
.slider-progress-bar { height: 100%; width: 0%; background-color: #fff; }
.banner-slider { display: flex; height: auto; }
.banner-slide { min-width: 100%; box-sizing: border-box; transition: opacity 0.7s ease-in-out; opacity: 0; position: absolute; top: 0; left: 0; width: 100%; height: auto; }
.banner-slide.active { opacity: 1; position: relative; z-index: 1; }
.banner-slide a { display: block; line-height: 0; height: auto; }
.banner-slide img { width: 100%; height: auto; max-height: 247px; object-fit: contain; display: block; }
.slider-nav { position: absolute; top: 50%; transform: translateY(-50%); background-color: rgba(0, 0, 0, 0.3); color: white; border: none; padding: 10px 15px; font-size: 1.2rem; cursor: pointer; border-radius: 0 3px 3px 0; z-index: 21; }
.slider-nav.prev { left: 0; border-radius: 3px 0 0 3px; }
.slider-nav.next { right: 0; }
.slider-nav:hover { background-color: rgba(0, 0, 0, 0.6); }

/* --- Dashboard: Package Stats --- */
.package-stats-box { background: #fff; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.05); border: 1px solid #e9ecef; margin-bottom: 30px; overflow: hidden; }
.stat-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; border-bottom: 1px solid #eee; }
.stat-header h3 { margin: 0; color: var(--primary-color); }
.stat-days-left { text-align: right; min-width: 80px; }
.stat-days-left strong { font-size: 1.5em; color: #333; display: block; line-height: 1; }
.stat-days-left span { font-size: 0.9em; color: #777; text-transform: uppercase; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background-color: #eee; }
.stat-item { background: #fff; padding: 15px; }
.stat-item span { display: block; font-size: 0.9em; color: #777; margin-bottom: 5px; text-transform: uppercase; }
.stat-item strong { display: block; font-size: 1.4em; color: #333; font-weight: 600; }
.stat-item small { color: #888; font-style: italic; font-size: 0.9em; }
.stat-footer { background: #f8f9fa; padding: 15px 20px; border-top: 1px solid #eee; font-size: 0.9em; color: #555; }

/* --- Dashboard: Calendar --- */
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding: 10px; background-color: #f8f9fa; border-radius: 5px; }
.calendar-header h2 { margin: 0; color: var(--primary-color); }
.nav-arrow { text-decoration: none; color: var(--primary-color); font-weight: bold; padding: 5px 10px; }
.calendar-table { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; }
.calendar-table th, .calendar-table td { border: 1px solid #ddd; height: 120px; vertical-align: top; padding: 5px; }
.calendar-table th { background-color: #eee; text-align: center; height: auto; padding: 10px 5px; }
.calendar-table td.empty { background-color: #f9f9f9; }
.day-number { font-weight: bold; text-align: right; margin-bottom: 5px; color: #555; font-size: 0.9em; }
.design-link { display: block; background-color: var(--primary-color-light); border: 1px solid var(--primary-color-border); color: var(--primary-color); text-decoration: none; padding: 5px; border-radius: 3px; font-size: 0.85em; text-align: center; margin-top: 5px; font-weight: bold; }
.design-link:hover { background-color: var(--primary-color); color: #fff; }

/* --- Design Grid (by_date page) --- */
.designs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-top: 20px; }
.design-card { background: #fff; border: 1px solid #e9ecef; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05); overflow: hidden; display: flex; flex-direction: column; }
.design-thumbnail { width: 100%; height: 250px; object-fit: cover; background-color: #f4f4f4; }
.design-card-footer { padding: 15px; display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #eee; }
.design-card-footer h4 { margin: 0; font-size: 1.1em; flex-grow: 1; margin-right: 10px; }
.btn-sm-view { background-color: var(--primary-color); color: #fff; padding: 8px 15px; border-radius: 5px; text-decoration: none; font-size: 0.9em; white-space: nowrap; }
.btn-sm-view:hover { background-color: var(--primary-color-dark); }

/* --- Permission Checkboxes (Roles & Register) --- */
.subcategory-list, .permissions-grid { max-height: 200px; overflow-y: auto; background: #f8f9fa; padding: 15px; border-radius: 5px; }
.permissions-grid { grid-template-columns: repeat(3, 1fr); gap: 15px; }
.permission-label { display: block; background: #fff; padding: 8px 12px; border-radius: 5px; border: 1px solid #eee; margin-bottom: 5px; user-select: none; }
.permission-label input { margin-right: 8px; }

/* ====================
   NEW: AUTH LAYOUT STYLES
==================== */
body.auth-page {
    padding-top: 0 !important; /* Override main body padding */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

.auth-container {
    width: 100%;
    max-width: 500px; /* Max width for login/register forms */
}

.auth-header {
    text-align: center;
    margin-bottom: 20px;
}
.auth-header .auth-logo {
    max-height: 60px;
    width: auto;
}
.auth-header .auth-title {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin: 10px 0 0 0;
}

/* Override .form-container for auth pages */
.auth-page .form-container {
    margin: 0;
}

/* Style for the 'pending' page */
.pending-container {
    padding-top: 0; /* Override default */
}
.pending-box {
    width: 100%;
    max-width: 600px;
    background: #fff;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.pending-box .icon {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}
.pending-box h1 {
    color: #333;
    margin-top: 0;
}
.pending-box p {
    font-size: 1.1rem;
    color: #555;
    line-height: 1.6;
}

/* Message boxes for verify page */
.message {
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    font-weight: 500;
    border: 1px solid transparent;
}
.message.success {
    background-color: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}
.message.error {
    background-color: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* ====================
   RESPONSIVE: MOBILE VIEW
==================== */
@media (max-width: 768px) {
    body {
        padding-top: var(--top-bar-height);
    }
    .sidebar {
        display: none; /* Hide desktop sidebar */
    }
    .content-wrapper {
        width: 100%;
        margin-left: 0;
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 15px;
    }
    .footer {
        margin-left: 0;
        padding-left: 15px;
        padding-right: 15px;
    }
    
    .form-row { flex-direction: column; gap: 15px; }
    
    /* **FIX**: This rule was removed to keep the header aligned */
    /* .admin-header { flex-direction: column; align-items: flex-start; gap: 10px; } */
    
    /* Responsive Grids */
    .settings-grid-2, .settings-grid-3, .designs-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    
    /* Responsive Calendar */
    .calendar-table td { height: 80px; font-size: 0.8em; }
    .calendar-header h2 { font-size: 1.2em; }
    
    /* Responsive Banner */
    .banner-slider-container { height: auto; max-height: 225px; }
    .banner-slider { height: auto; }
    
    /* --- **FIX**: Show Mobile Toggles & Layout --- */
    .mobile-menu-toggle {
        display: block;
    }
    .top-bar-left .desktop-logo-link {
        display: none; /* Hide desktop logo */
    }
    .top-bar-center {
        display: flex; /* Show mobile logo */
    }
    .top-bar-right .profile-dropdown {
        display: none; /* Hide desktop profile dropdown */
    }
    .top-bar-right .mobile-profile-toggle {
        display: block; /* Show mobile profile icon */
    }
    .mobile-sidebar {
        display: flex; /* Make mobile sidebar available */
    }
}