:root {
    /* Color Palette - Premium & Modern */
    --primary-color: #2c3e50;
    --primary-gradient: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
    --secondary-color: #34495e;
    --accent-color: #e74c3c;
    --success-color: #2ecc71;
    --warning-color: #f1c40f;
    --info-color: #3498db;

    /* Backgrounds */
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;

    /* Text */
    --text-main: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-light: #ecf0f1;

    /* Layout */
    --sidebar-width: 300px;
    --header-height: 70px;
    --border-radius: 12px;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 5px 15px rgba(0, 0, 0, 0.08);
    /* Softer, deeper shadow */
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);

    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    box-sizing: border-box;
    outline: none;
}

body {
    font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.5px;
}

a {
    text-decoration: none;
    color: inherit;
    transition: var(--transition);
}

/* Layout Structure */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    position: relative;
}

/* Sidebar - Modern Dark Gradient */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary-gradient);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    /* Fixed sidebar */
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    transition: transform var(--transition);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 25px;
    font-size: 1.4rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    letter-spacing: 0.5px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 10px;
}

/* Custom Scrollbar for Sidebar */
.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    /* Very subtle track */
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    margin-bottom: 8px;
    color: rgba(255, 255, 255, 0.7);
    border-radius: var(--border-radius);
    transition: var(--transition);
    font-weight: 500;
}

.menu-item:hover,
.menu-item.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.15);
    transform: translateX(5px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.menu-item i {
    margin-right: 15px;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.menu-section-title {
    padding: 20px 20px 10px 20px;
    margin-top: 15px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    align-items: center;
}

.menu-section-title:first-of-type {
    margin-top: 0;
}

.menu-section-title i {
    margin-right: 8px;
    font-size: 0.9rem;
}


/* Main Content Area */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
    /* Offset for fixed sidebar */
    width: calc(100% - var(--sidebar-width));
    transition: margin-left var(--transition), width var(--transition);
}

/* Top Header */
.top-header {
    height: var(--header-height);
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 900;
}

.toggle-btn {
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: var(--text-main);
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: background 0.2s;
}

.toggle-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

/* Page Content */
.content-body {
    padding: 30px;
    min-height: calc(100vh - var(--header-height));
    background-color: var(--bg-body);
}

/* Modern Card */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0, 0, 0, 0.02);
    margin-bottom: 25px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    /* transform: translateY(-2px); Optional float effect */
}

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

.stat-card {
    background: #fff;
    padding: 25px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px;
    top: -20px;
    width: 100px;
    height: 100px;
    background: currentColor;
    opacity: 0.05;
    border-radius: 50%;
    pointer-events: none;
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-right: 20px;
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 1.25rem;
    margin-bottom: 2px;
    color: var(--text-main);
    white-space: nowrap;
}

.stat-info p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 24px;
    border-radius: 30px;
    /* Pill shape */
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn i {
    margin-right: 8px;
}

.btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #fff;
}

.btn-primary:hover {
    box-shadow: 0 7px 14px rgba(50, 50, 93, 0.1), 0 3px 6px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

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

.form-control {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #eef2f7;
    border-radius: 8px;
    font-size: 1rem;
    background-color: #fcfcfc;
    transition: var(--transition);
    color: var(--text-main);
    min-height: 48px;
    /* Fixed height to accommodate text */
    /* Remove display flex here as it breaks textarea */
}

/* Specific fix for select elements which might mishandle padding */
select.form-control {
    appearance: none;
    /* Modern Reset */
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    padding-right: 2.5rem;
    /* Space for arrow */
}

.form-control:focus {
    border-color: #3498db;
    background-color: #fff;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.1);
}

.form-label {
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-main);
}

/* Picture Box Styling */
.photo-upload-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 25px;
    padding: 20px;
    background: #fcfcfc;
    border: 2px dashed #eef2f7;
    border-radius: var(--border-radius);
    transition: all 0.3s;
}

.photo-upload-container:hover {
    border-color: var(--info-color);
    background: #f8fbfe;
}

.photo-preview {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    /* Circle */
    object-fit: cover;
    margin-bottom: 15px;
    border: 4px solid #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    background-color: #eee;
}

.photo-label {
    cursor: pointer;
    color: var(--info-color);
    font-weight: 600;
    transition: color 0.2s;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
}

.photo-label:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.photo-label i {
    margin-right: 8px;
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: left;
    padding: 15px;
    background-color: #f8f9fa;
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid #eef2f7;
}

td {
    padding: 15px;
    border-bottom: 1px solid #f1f3f5;
    vertical-align: middle;
}

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

/* ============================
   Login Page Styles
   ============================ */
.login-page {
    /* Override global body background */
    background: var(--primary-gradient);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    background: #fff;
    width: 100%;
    max-width: 400px;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
    text-align: center;
    animation: fadeInUp 0.6s ease-out;
}

.login-header {
    margin-bottom: 30px;
}

.login-logo {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    background: -webkit-linear-gradient(#2c3e50, #3498db);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 5px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Input group icons for login */
.input-icon-wrapper {
    position: relative;
    margin-bottom: 20px;
    text-align: left;
}

.input-icon-wrapper i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #bdc3c7;
    transition: color 0.3s;
}

.input-icon-wrapper input {
    padding-left: 45px;
    /* Space for icon */
}

.input-icon-wrapper input:focus+i {
    color: var(--info-color);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================
   Responsive & Mobile Fixes
   ============================ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 100%;
        /* Full width sidebar on mobile or customized */
        max-width: 280px;
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 100vw 0 0 rgba(0, 0, 0, 0.5);
        /* Backdrop hack using shadow */
    }

    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 0;
    }

    .content-body {
        padding: 15px;
    }

    /* Force Grid Columns to Stack */
    .dashboard-grid {
        grid-template-columns: 1fr !important;
    }

    /* Stack form groups if they are side-by-side */
    .form-row,
    .d-flex {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* Responsive Tables - Card View Pattern (Flexbox Improved) */
    .responsive-table table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table th,
    .responsive-table td,
    .responsive-table tr {
        display: block;
    }

    .responsive-table thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    .responsive-table tr {
        background: #fff;
        border-radius: var(--border-radius);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        /* More distinct card shadow */
        margin-bottom: 20px;
        padding: 0;
        /* Remove padding from TR, rely on TD */
        border: 1px solid #eef2f7;
        overflow: hidden;
        /* rounded corners */
    }

    .responsive-table td {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 15px;
        border: none;
        border-bottom: 1px solid #f1f3f5;
        text-align: right;
        min-height: 50px;
        /* Ensure touch target size */
    }

    .responsive-table td:last-child {
        border-bottom: none;
        justify-content: center;
        /* Actions usually centered */
        padding: 20px 15px;
        background-color: #fcfcfc;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--primary-color);
        text-align: left;
        flex-basis: 40%;
        /* Take up 40% of space */
        flex-shrink: 0;
        /* Don't shrink */
        padding-right: 15px;
        font-size: 0.9rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    /* Fix image alignment */
    .responsive-table img {
        margin-left: auto;
        /* Push to right */
    }

    .responsive-table .btn {
        margin: 0 5px;
        /* Spacing for buttons */
        width: auto;
        /* Buttons occupy auto width */
        display: inline-flex;
    }

    /* Specific adjustment for Permissions checkboxes in mobile */
    .responsive-table input[type="checkbox"] {
        width: 20px;
        height: 20px;
        margin-left: auto;
        /* Push to right */
    }

    /* Form specific adjustments */
    .d-flex h2,
    .d-flex .btn {
        width: 100%;
        justify-content: center;
    }
}