/* General Styles */
:root {
    --primary-color: #4a90e2;
    --secondary-color: #50e3c2;
    --accent-color: #f5a623;
    --background-light: #f8f9fa;
    --background-dark: #e9ecef;
    --text-dark: #343a40;
    --text-light: #ffffff;
    --border-color: #dee2e6;
    --shadow-light: rgba(0, 0, 0, 0.05);
    --shadow-medium: rgba(0, 0, 0, 0.1);
    --header-height: 60px; /* New variable for header height */
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif; /* Modern font */
    background-color: var(--background-light);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column; /* Stack header and main-wrapper vertically */
}

/* Main Wrapper for Sidebar and Content */
.main-wrapper {
    display: flex;
    flex-grow: 1; /* Allow it to take remaining vertical space */
}

.header {
    background-color: var(--text-light);
    padding: 15px 30px;
    box-shadow: 0 2px 10px var(--shadow-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    height: var(--header-height); /* Explicitly set header height */
}

.header h1 {
    color: var(--primary-color);
    font-size: 1.8rem;
    display: flex;
    align-items: center;
}

.header h1 .icon {
    margin-right: 10px;
    font-size: 1.5em;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.95rem;
}

.user-info .btn {
    padding: 8px 15px;
    font-size: 0.85rem;
}

.sidebar {
    width: 250px;
    background-color: var(--text-light);
    box-shadow: 2px 0 10px var(--shadow-light);
    padding-top: 20px;
    flex-shrink: 0;
    position: sticky;
    top: var(--header-height); /* Stick below the header */
    height: calc(100vh - var(--header-height)); /* Take remaining height */
    overflow-y: auto;
}

.sidebar .nav-item {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: var(--text-dark);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    font-size: 1rem;
}

.sidebar .nav-item .icon {
    margin-right: 15px;
    font-size: 1.2em;
}

.sidebar .nav-item:hover,
.sidebar .nav-item.active {
    background-color: var(--background-dark);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.content {
    flex-grow: 1;
    padding: 30px;
    background-color: var(--background-light);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.card {
    background: var(--text-light);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px var(--shadow-medium);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-left: 5px solid var(--primary-color); /* Default border */
}

.card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 30px var(--shadow-medium);
}

.card h3 {
    color: var(--text-dark);
    font-size: 1rem;
    margin-bottom: 10px;
    opacity: 0.8;
}

.card .number {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--primary-color); /* Use primary color for numbers */
}

/* Specific card colors */
.card.icon-1 { border-left-color: #4a90e2; } /* Primary Blue */
.card.icon-2 { border-left-color: #f5a623; } /* Orange */
.card.icon-3 { border-left-color: #bd10e0; } /* Purple */
.card.icon-4 { border-left-color: #7ed321; } /* Green */
.card.icon-5 { border-left-color: #50e3c2; } /* Teal */
.card.icon-6 { border-left-color: #9013fe; } /* Dark Purple */
.card.icon-7 { border-left-color: #f8e71c; } /* Yellow */
.card.icon-8 { border-left-color: #4a4a4a; } /* Dark Gray */


/* Table Styles */
.table-container {
    background: var(--text-light);
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 20px var(--shadow-medium);
    overflow-x: auto; /* For responsive tables */
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-top: 20px;
}

th, td {
    padding: 15px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--primary-color);
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.9rem;
}

th:first-child { border-top-left-radius: 8px; }
th:last-child { border-top-right-radius: 8px; }

tr:last-child td {
    border-bottom: none;
}

tr:nth-child(even) {
    background-color: var(--background-dark);
}

tr:hover {
    background-color: var(--background-dark);
    transition: background-color 0.2s ease;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s ease;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--text-light);
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.btn-primary:hover {
    background-color: #3a7bd5;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.btn-danger {
    background-color: #d0021b;
    color: var(--text-light);
    box-shadow: 0 4px 15px rgba(208, 2, 27, 0.3);
}

.btn-danger:hover {
    background-color: #a00115;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(208, 2, 27, 0.4);
}

.btn-edit {
    background-color: var(--accent-color);
    color: var(--text-light);
    box-shadow: 0 4px 15px rgba(245, 166, 35, 0.3);
}

.btn-edit:hover {
    background-color: #e0951f;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 166, 35, 0.4);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-dark);
    background-color: var(--text-light);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    appearance: none; /* Remove default arrow */
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23000000%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-6.5%200-12.3%203.2-16.1%208.1-3.8%204.9-4.6%2011-2.9%2016.8l130.6%20130.6c2.8%202.8%206.7%204.3%2010.6%204.3s7.8-1.5%2010.6-4.3L289.9%2091c1.7-5.8.9-12-2.9-16.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 12px;
    padding-right: 35px;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.page-header h2 {
    color: var(--text-dark);
    font-size: 2rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Alerts */
.alert {
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Login Page Specific Styles */
.login-container {
    background-color: var(--text-light);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 30px var(--shadow-medium);
    width: 100%;
    max-width: 450px;
    text-align: center;
    margin: auto; /* Center the login box */
}

.login-container h2 {
    margin-bottom: 30px;
    color: var(--primary-color);
    font-size: 2rem;
}

/* Utility Classes */
.text-center { text-align: center; }
.mb-3 { margin-bottom: 1rem; }
.mt-3 { margin-top: 1rem; }

/* Responsive Design */
@media (max-width: 992px) {
    .sidebar {
        width: 80px; /* Collapse sidebar */
    }
    .sidebar .nav-item {
        justify-content: center;
        padding: 15px 0;
    }
    .sidebar .nav-item span {
        display: none; /* Hide text */
    }
    .sidebar .nav-item .icon {
        margin-right: 0;
    }
    .content {
        margin-left: 80px;
    }
    .header h1 {
        font-size: 1.5rem;
    }
    .user-info {
        gap: 10px;
    }
}

@media (max-width: 768px) {
    .main-wrapper {
        flex-direction: column;
    }
    .header {
        position: relative;
        padding: 15px 20px;
        height: auto; /* Allow header to adjust height */
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        box-shadow: none;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        overflow-x: auto;
        white-space: nowrap;
        padding: 0;
    }
    .sidebar .nav-item {
        flex-shrink: 0;
        width: auto;
        border-left: none;
        border-bottom: 4px solid transparent;
    }
    .sidebar .nav-item:hover,
    .sidebar .nav-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--primary-color);
    }
    .sidebar .nav-item span {
        display: inline;
        margin-left: 10px;
    }
    .content {
        margin-left: 0;
        padding: 20px;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    .page-header h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .header {
        flex-direction: column;
        gap: 10px;
    }
    .header h1 {
        font-size: 1.3rem;
    }
    .user-info {
        flex-direction: column;
        gap: 5px;
    }
    .login-container {
        padding: 30px;
    }
    .login-container h2 {
        font-size: 1.5rem;
    }
}