/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette */
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #3b82f6;

    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;

    /* Spacing & sizing */
    --border-radius: 0.75rem;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    --font-sans: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar Style Overrides */
.navbar {
    background-color: var(--surface-color) !important;
    box-shadow: var(--shadow-sm);
    padding: 1rem 0;
}

.navbar-brand {
    font-weight: 700;
    color: var(--primary-color) !important;
    font-size: 1.5rem;
}

.navbar-nav .nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    transition: color 0.2s;
}

.navbar-nav .nav-link:hover {
    color: var(--primary-color) !important;
}

/* Footer */
footer {
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 1.5rem 0;
    margin-top: auto;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Main Container */
.main-content {
    padding: 2rem 0;
    flex: 1;
}

/* Cards */
.card-custom {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    padding: 2rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-custom:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-title {
    color: var(--text-primary);
    font-weight: 700;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

/* Buttons */
.btn-custom {
    border-radius: 0.5rem;
    font-weight: 500;
    padding: 0.625rem 1.25rem;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary-custom {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary-custom:hover {
    background-color: var(--primary-hover);
    color: white;
    transform: translateY(-1px);
}

.btn-secondary-custom {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary-custom:hover {
    background-color: var(--bg-color);
    color: var(--text-primary);
}

.btn-action-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
}

/* Forms */
.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.form-control {
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Tables */
.table-custom {
    width: 100%;
    margin-bottom: 1rem;
    background-color: transparent;
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom th {
    background-color: var(--bg-color);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.table-custom td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
}

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

.table-custom tr:hover td {
    background-color: rgba(248, 250, 252, 0.5);
}

.table-container {
    background: var(--surface-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

/* Alerts */
.alert {
    border-radius: var(--border-radius);
    border: none;
    font-weight: 500;
}

/* Utilities */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-color), #818cf8);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Sidebar Navigation */
.offcanvas {
    border-right: none;
    box-shadow: var(--shadow-lg);
}

.offcanvas-header {
    padding: 1.5rem;
}

.offcanvas-body {
    padding: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    list-style: none;
    padding: 0 1rem;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-link-custom {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.nav-link-custom:hover {
    background-color: #f1f5f9;
    /* Slate-100 */
    color: var(--primary-color);
    transform: translateX(4px);
}

.nav-link-custom.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
}

.nav-link-custom i {
    width: 1.5rem;
    text-align: center;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.sidebar-footer {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card-custom {
        padding: 1.25rem;
        /* Reduced padding on mobile */
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        /* Smooth scrolling on iOS */
    }

    .card-title {
        font-size: 1.25rem;
        /* Smaller titles on mobile */
        margin-bottom: 1rem;
    }

    .btn-custom {
        width: 100%;
        /* Full width buttons on mobile usually look better */
        justify-content: center;
        margin-bottom: 0.5rem;
    }

    /* Adjust navbar spacing */
    .navbar-brand {
        font-size: 1.25rem;
    }
}

@media (max-width: 576px) {
    .btn-group {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
        margin-bottom: 0.25rem;
        border-radius: 0.5rem !important;
        /* Reset border radius for stacked buttons */
    }
}

/* Sidebar Buttons */
.sidebar-btn {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
}

.sidebar-btn:hover {
    background-color: #f1f5f9;
    color: var(--primary-color);
    transform: translateX(4px);
}

.sidebar-btn i {
    width: 1.5rem;
    text-align: center;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

/* Logout Button Premium Style */
.btn-logout-custom {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1rem;
    /* Match nav link padding */
    border-radius: 0.5rem;
    /* Match nav link radius */
    border: none;
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.2);
    transition: all 0.3s ease;
    display: flex;
    /* Changed from inline-flex to flex */
    align-items: center;
    justify-content: flex-start;
    /* Align left */
    width: 100%;
    text-decoration: none;
}

.btn-logout-custom i {
    width: 1.5rem;
    text-align: center;
    margin-right: 0.75rem;
    /* Match nav link spacing */
    font-size: 1.1rem;
}

.btn-logout-custom:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(220, 38, 38, 0.3);
    color: white;
}

/* Dark Mode Variables */
body.dark-mode {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --border-color: #334155;
    --shadow-sm: 0 1px 2px 0 rgb(255 255 255 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(255 255 255 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(255 255 255 / 0.1);
}

body.dark-mode .card-custom {
    background: var(--surface-color);
    border-color: var(--border-color);
}

body.dark-mode .navbar {
    background-color: var(--surface-color) !important;
    border-bottom: 1px solid var(--border-color);
}

body.dark-mode .table-custom th {
    background-color: #1e293b;
    /* Match surface */
    color: var(--text-secondary);
}

body.dark-mode .table-custom td {
    color: var(--text-primary);
}

body.dark-mode .form-control {
    background-color: #334155;
    border-color: #475569;
    color: #f1f5f9;
}

body.dark-mode .form-control:focus {
    background-color: #334155;
    color: #ffffff;
}

body.dark-mode .form-label {
    color: var(--text-primary);
}

/* Dark Mode Sidebar Overrides */
.offcanvas.text-bg-dark .nav-link {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Dark Mode Sidebar Specifics */
body.dark-mode .nav-link-custom {
    color: var(--text-secondary);
}

body.dark-mode .nav-link-custom:hover {
    background-color: #334155;
    /* Slate-700 */
    color: #ffffff;
}

body.dark-mode .nav-link-custom.active {
    background-color: var(--primary-color);
    color: white;
}

body.dark-mode .sidebar-footer {
    border-color: var(--border-color);
}

body.dark-mode .offcanvas {
    background-color: var(--surface-color);
    color: var(--text-primary);
}

body.dark-mode .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}