:root {
    --background: hsl(0, 0%, 97%);
    --foreground: hsl(20, 14.3%, 4.1%);
    --muted: hsl(60, 4.8%, 95.9%);
    --muted-foreground: hsl(25, 5.3%, 44.7%);
    --popover: hsl(0, 0%, 100%);
    --popover-foreground: hsl(20, 14.3%, 4.1%);
    --card: hsl(0, 0%, 100%);
    --card-foreground: hsl(20, 14.3%, 4.1%);
    --border: hsl(214, 32%, 91%);
    --input: hsl(214, 32%, 91%);
    --primary: hsl(0, 0%, 0%);
    --primary-foreground: hsl(0, 0%, 100%);
    --secondary: hsl(60, 4.8%, 95.9%);
    --secondary-foreground: hsl(24, 9.8%, 10%);
    --accent: hsl(60, 4.8%, 95.9%);
    --accent-foreground: hsl(24, 9.8%, 10%);
    --radius: 0.75rem;
    --sidebar-width: 280px;
    --font-inter: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--background);
    color: var(--foreground);
    font-family: var(--font-inter);
    min-height: 100vh;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* Grain texture overlay */
.grain-texture::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.08;
    z-index: 100;
    background: url("images/texture-background.jpg");
    background-size: cover;
    background-position: center;
}

/* Sidebar Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: transparent;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    max-height: 100vh;
    border-right: 1px solid var(--border);
    z-index: 10;
    overflow: hidden;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 700;
    padding: 24px 32px 32px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 0 16px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--muted-foreground);
}

.nav-group {
    margin-bottom: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    padding: 0 16px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-radius: 8px;
    color: var(--foreground);
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 4px;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.nav-item:hover {
    background-color: var(--accent);
}

.logout-link:hover {
    background-color: #fef2f2 !important;
    color: #b91c1c !important;
}

.btn-primary:hover {
    background: #000;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    width: 100%;
    max-width: 550px;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    animation: modal-in 0.3s ease-out;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--muted-foreground);
    font-size: 20px;
    cursor: pointer;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Material Shadcn Active Item Style */
.nav-item.active {
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    background: linear-gradient(to bottom, #44403c, #1c1917);
    /* bg-stone-800 to stone-900 approx */
    border: 1px solid #0c0a09;
    color: white;
    font-weight: 500;
    position: relative;
}

.nav-item i {
    width: 20px;
    margin-right: 12px;
    font-size: 16px;
    opacity: 0.7;
}

.nav-item.active i {
    opacity: 1;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    position: relative;
    z-index: 5;
}

/* Hero Component */
.hero-card {
    position: relative;
    height: 280px;
    background-size: cover;
    background-position: top;
    border-radius: 1rem;
    overflow: hidden;
    margin-bottom: 32px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    padding: 40px;
}

.hero-content {
    max-width: 500px;
    color: white;
}

.hero-content h2 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 12px;
}

.hero-content p {
    font-size: 16px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
    margin-bottom: 24px;
}

.btn-hero {
    display: inline-block;
    padding: 12px 24px;
    background: linear-gradient(to bottom, #44403c, #1c1917);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    border: 1px solid #0c0a09;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Grid & Cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.card-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-content {
    padding: 24px;
}

.stat-card-inner {
    display: flex;
    flex-direction: column;
}

.stat-card-inner .label {
    font-size: 13px;
    color: var(--muted-foreground);
    margin-bottom: 4px;
}

.stat-card-inner .value {
    font-size: 24px;
    font-weight: 700;
}

/* Table Styles */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 24px;
    background: #fafafa;
    font-size: 12px;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--foreground);
    background: var(--accent);
}

/* Login Page Redesign */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--background);
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px;
    background: white;
    border-radius: 16px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--input);
    font-size: 14px;
}

.btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(to bottom, #1c1917, #0c0a09);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Mobile Responsiveness */
.mobile-header {
    display: none;
}

.sidebar-overlay-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 90;
}

.mobile-only {
    display: none;
}

.btn-icon-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon-ghost:hover {
    background: var(--accent);
    color: var(--foreground);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 16px;
}

@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        top: 12px;
        left: 12px;
        bottom: 12px;
        height: auto;
        width: 320px;
        max-width: calc(100vw - 24px);
        background: white;
        border: 1px solid var(--border);
        border-radius: 16px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
        transform: translateX(calc(-100% - 24px));
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 100;
        overflow: hidden;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-header {
        padding: 16px 16px 16px 20px;
    }

    .mobile-only {
        display: inline-flex;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 8px 12px;
        background: white;
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 50;
        height: 64px;
    }

    .mobile-header-left, .mobile-header-right {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-logo {
        font-size: 20px;
    }

    .mobile-title {
        font-weight: 600;
        font-size: 15px;
        color: var(--foreground);
    }

    .mobile-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: radial-gradient(circle at 30% 30%, #fecaca, #ef4444);
        border: 1px solid var(--border);
    }

    .sidebar-overlay-backdrop.active {
        display: block;
    }
}