:root {
    --primary-color: #4a90e2; /* Modern blue */
    --secondary-color: #50e3c2; /* Accent green */
    --background-color: #f8fafc; /* Lighter, cleaner background */
    --card-background: #ffffff;
    --text-color-dark: #1e293b; /* Darker text for better contrast */
    --text-color-light: #64748b; /* Softer light text */
    --border-color: #e0e0e0;
    --input-background: #f9f9f9;
    --button-hover-darken: 10%;
    --danger-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f39c12;
    --sidebar-width: 280px;
}

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color-dark);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-y: auto; /* Enable scrolling for the entire body if content overflows */
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--secondary-color);
}

.container {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    flex-grow: 1; /* Allow container to grow and push footer down */
    display: flex;
    flex-direction: column;
}

/* New Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}
.header .brand {
    font-weight: 700;
    font-size: 28px;
    color: var(--primary-color);
}
.header .brand em {
    color: var(--secondary-color);
    font-style: normal;
}
.header .nav-link {
    margin-left: 15px;
    font-weight: 500;
}


/* General Card Styles */
.card {
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02), 0 4px 12px rgba(0, 0, 0, 0.05);
    padding: 30px;
    margin-bottom: 30px;
    min-height: 300px; /* Ensure cards have a minimum height */
    overflow: visible; /* Ensure content within cards is not clipped */
    position: relative; /* Ensure z-index works correctly for children */
}

.card h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-color-dark);
    margin-top: 0;
    margin-bottom: 25px;
    border-bottom: 1px solid #eef2f7;
    padding-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Grid Layouts */
.grid {
    display: grid;
    gap: 30px;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.card-header-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Form Styles */
form {
    margin-top: 20px;
}

label {
    display: block;
    margin: 15px 0 8px;
    color: var(--text-color-light);
    font-weight: 500;
    font-size: 14px;
    clear: both; /* Ensure labels don't float */
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="file"],
select {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--input-background);
    color: var(--text-color-dark);
    font-family: 'Poppins', sans-serif;
    font-size: 15px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    /* Ensure visibility and proper stacking */
    display: block;
    opacity: 1;
    z-index: 1;
    position: relative;
    box-sizing: border-box; /* Ensure consistent sizing */
    height: auto; /* Ensure elements are not collapsed */
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.2);
}

.btn {
    background: var(--primary-color);
    border: none;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    width: 100%;
    margin-top: 20px;
    transition: background 0.3s ease, transform 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    z-index: 2; /* Ensure buttons are on top */
    position: relative; /* Ensure z-index works */
}

.btn:hover {
    background: #3579d0;
    transform: translateY(-2px);
}

.btn-small {
    padding: 8px 15px;
    font-size: 14px;
    margin-top: 0;
    z-index: 2; /* Ensure buttons are on top */
    position: relative; /* Ensure z-index works */
}

.btn-small.search-btn {
    width: auto;
    flex-shrink: 0;
}

.btn.secondary {
    background: #6c757d;
}

.btn.secondary:hover {
    background: color-mix(in srgb, #6c757d, black var(--button-hover-darken));
}

/* Table Styles */
.table-responsive {
    width: 100%;
    overflow-x: auto; /* Allows horizontal scrolling on smaller screens */
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Prevents table from squeezing too much */
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

th {
    background: #f9fafb;
    font-weight: 600;
    color: var(--text-color-light);
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
}

tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background-color: #f9fafb;
}

td .btn {
    margin-top: 0;
}

/* Badges */
.badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}
/* This is a generic badge, specific status badges can be added */
.badge {
    background-color: #eef2ff;
    color: #4338ca;
}
.badge.success {
    background-color: #f0fdf4;
    color: #166534;
}

/* Flash Messages */
.flash-message {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 500;
    border: 1px solid transparent;
}

.flash-message.warning {
    background: #fefce8;
    color: #a16207;
    border-color: #fde047;
}

.flash-message.error {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fecaca;
}

.flash-message.success {
    background: #f0fdf4;
    color: #166534;
    border-color: #bbf7d0;
}

/* Search and Pagination */
.search-form {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-form input {
    flex-grow: 1;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 25px;
}

.pagination .btn {
    margin-top: 0;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .container {
        max-width: 100%;
    }
}

@media (max-width: 1024px) {
    .grid {
        gap: 20px;
    }
}

@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
    }
    .header .brand {
        margin-bottom: 10px;
    }
    .container {
        padding: 20px;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .card h2 {
        font-size: 20px;
    }
    .search-form {
        flex-direction: column;
    }
    .search-form .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }
    .card {
        padding: 15px;
    }
    .card h2 {
        font-size: 18px;
    }
}

/* Auth page specific styles */
.auth-page-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 80px); /* Adjust based on header height */
    flex-grow: 1; /* Allow it to take available space */
}
.auth-card {
    width: 100%;
    max-width: 420px;
    margin: auto; /* Center the card within its flex container */
}
.auth-card h2 {
    text-align: center;
    border-bottom: none;
    padding-bottom: 0;
}
.auth-card .form-group {
    margin-bottom: 15px;
}
.auth-card .tip {
    margin-top: 20px;
    text-align: center;
    font-size: 14px;
}
/* The .header styles are already defined globally, no need to repeat here */

/* Customer Layout */
.customer-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

.customer-wrapper .sidebar {
    width: var(--sidebar-width);
    background: #111827; /* Darker, more professional sidebar */
    color: #9ca3af;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 1001;
    transition: transform 0.3s ease-in-out;
}

.customer-wrapper .sidebar .brand {
    font-weight: 700;
    font-size: 28px;
    color: #fff;
    text-align: center;
    padding: 25px;
    border-bottom: 1px solid #1f2937;
}

.customer-wrapper .sidebar .brand em {
    color: var(--secondary-color);
    font-style: normal;
}

.customer-wrapper .sidebar nav {
    flex-grow: 1;
    padding: 20px 15px;
}

.customer-wrapper .sidebar nav a {
    color: #d1d5db;
    font-weight: 500;
    padding: 12px 15px;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 5px;
}

.customer-wrapper .sidebar nav a:hover,
.customer-wrapper .sidebar nav a.active {
    background: #374151;
    color: #fff;
}

.customer-wrapper .logout {
    margin: 20px 15px;
    font-weight: 500;
    color: #fca5a5;
    padding: 12px 15px;
    border-radius: 8px;
    transition: background 0.2s ease, color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.customer-wrapper .logout:hover {
    background: #ef4444;
    color: #fff;
}

.customer-wrapper .main-content {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    margin-top: 60px; /* Account for the height of the top-navbar */
    transition: margin-left 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 60px);
    overflow-y: auto;
}

.customer-wrapper .top-navbar {
    background: var(--card-background);
    padding: 15px 30px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 999;
    display: flex;
    width: calc(100% - var(--sidebar-width)); /* Adjust width for sidebar */
    margin-left: var(--sidebar-width); /* Position after sidebar */
}

.customer-wrapper .top-navbar .brand {
    font-weight: 700;
    font-size: 22px;
    color: var(--primary-color);
}
.customer-wrapper .top-navbar .brand em {
    color: var(--secondary-color);
    font-style: normal;
}

.customer-wrapper .menu-toggle {
    display: none; /* Hidden on desktop */
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color-dark);
}

.customer-wrapper .overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
}
.customer-wrapper .overlay.active {
    display: block;
}

/* Responsive Design for Customer */
@media (max-width: 768px) {
    .customer-wrapper .sidebar {
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    }
    .customer-wrapper .sidebar.active {
        transform: translateX(0);
    }
    .customer-wrapper .main-content {
        margin-left: 0;
        margin-top: 60px;
        min-height: calc(100vh - 60px);
    }
    .customer-wrapper .top-navbar {
        width: 100%;
        margin-left: 0;
    }
    .customer-wrapper .menu-toggle {
        display: block;
    }
}
