:root {
    --primary: #1e40af;
    --primary-hover: #1e3a8a;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #1e293b;
    --border: #e2e8f0;
    --glass: rgba(0, 0, 0, 0.02);
    --radius: 12px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --transition: all 0.2s ease;
    --shadow-premium: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --gradient-primary: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    --gradient-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --gradient-warning: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --gradient-danger: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gradient-info: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    --glass-bg: rgba(255, 255, 255, 0.8);
    --glass-border: #e2e8f0;
    --nav-height: 72px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    background-image:
        radial-gradient(at 0% 0%, hsla(210, 40%, 98%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(220, 30%, 96%, 0.5) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(215, 25%, 95%, 0.3) 0, transparent 50%);
}

.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-premium);
    transition: var(--transition);
}

.glass-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    font-size: 0.95rem;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(30, 64, 175, 0.4);
}

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

.btn-secondary:hover {
    background: var(--bg-main);
    border-color: var(--secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-premium);
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-main);
    transition: var(--transition);
}

.input-group select option {
    background-color: #ffffff;
    color: var(--text-main);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pending {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-active {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.badge-closed {
    background: rgba(100, 116, 139, 0.2);
    color: var(--secondary);
}

.badge-priority-high {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.badge-priority-medium {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.badge-priority-low {
    background: rgba(14, 165, 233, 0.2);
    color: var(--info);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}

.card-vibrant {
    position: relative;
    overflow: hidden;
}

.card-vibrant::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--accent-color, var(--primary));
}

/* Layouts */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 768px) {

    .grid-cols-2,
    .grid-cols-3 {
        grid-template-columns: 1fr;
    }

    .hero h1 {
        font-size: 2.5rem !important;
    }
}

/* Navbar */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    height: var(--nav-height);
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 1001;
}

/* Center navbar content on desktop for landing page */
@media (min-width: 769px) {
    body:has(.hero) nav {
        justify-content: center;
        gap: 2rem;
    }

    body:has(.hero) nav .logo {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
    }

    body:has(.hero) nav .nav-links {
        position: absolute;
        right: 1.5rem;
    }
}

@media (max-width: 768px) {
    nav {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        background: var(--bg-card);
    }
}

.logo {
    display: flex;
    align-items: center;
    font-weight: 700;
    color: var(--primary);
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

.logo img {
    height: 48px;
    width: auto;
    object-fit: contain;
    transition: var(--transition);
}

@media (max-width: 768px) {
    .logo img {
        height: 38px;
    }
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: var(--transition);
}

.menu-toggle:hover {
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

@media (max-width: 768px) {
    .nav-links {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg-card);
        padding: 0.75rem 1rem;
        justify-content: space-around;
        border-top: 1px solid var(--border);
        gap: 0;
    }

    .nav-links a span {
        display: none;
    }

    .logo {
        font-size: 1.25rem;
    }

    .logo img {
        height: 70px;
    }

    .container {
        padding: 1rem;
        /* margin-bottom to be handled by layout specific media queries */
    }

    .menu-toggle {
        display: block;
    }
}

/* Responsive Table cards for mobile */
@media (max-width: 768px) {
    .responsive-table tr {
        display: block;
        background: var(--glass);
        margin-bottom: 1rem;
        padding: 1rem;
        border-radius: var(--radius);
        border: 1px solid var(--border);
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none !important;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 700;
        color: var(--text-muted);
    }
}

/* Admin Layout */
.admin-grid {
    display: block;
    padding-left: var(--sidebar-width);
    transition: var(--transition);
    min-height: calc(100vh - 80px);
    width: 100%;
    position: relative;
    box-sizing: border-box;
}

.admin-grid.sidebar-collapsed {
    padding-left: var(--sidebar-collapsed-width);
}

.sidebar {
    position: fixed;
    left: 0;
    top: 73px;
    /* Height of nav */
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 2rem 1rem;
    z-index: 1000;
    transition: var(--transition);
    overflow-y: auto;
    display: block;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-link span {
    display: none;
}

.sidebar.collapsed .sidebar-link {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    transition: var(--transition);
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.sidebar-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.2);
}

/* Sidebar Submenu */
.sidebar-group {
    display: flex;
    flex-direction: column;
}

.group-trigger {
    cursor: pointer;
    justify-content: space-between !important;
}

.group-trigger i.chevron {
    font-size: 0.8rem;
    transition: transform 0.3s ease;
}

.sidebar-group.open .group-trigger i.chevron {
    transform: rotate(90deg);
}

.sidebar-submenu {
    display: none;
    flex-direction: column;
    padding-left: 1.5rem;
    margin-top: -0.25rem;
    margin-bottom: 0.5rem;
    border-left: 1px solid var(--border);
    margin-left: 1.5rem;
}

.sidebar-group.open .sidebar-submenu {
    display: flex;
}

.sidebar-submenu .sidebar-link {
    font-size: 0.9rem;
    padding: 0.6rem 1rem;
    margin-bottom: 0.25rem;
}

.sidebar.collapsed .sidebar-submenu {
    position: absolute;
    left: 100%;
    top: 0;
    background: var(--bg-card);
    width: 200px;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0 var(--radius) var(--radius) 0;
    box-shadow: var(--shadow-premium);
    display: none !important;
    /* Disable submenu in collapsed mode for simplicity or use hover */
}

.sidebar.collapsed .sidebar-group:hover .sidebar-submenu {
    display: flex !important;
}



.main-content {
    padding: 2rem;
    width: 100%;
    box-sizing: border-box;
    padding-bottom: 5rem;
    /* Space for mobile nav if needed */
}

/* Sidebar Footer */
.sidebar {
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    flex: 1;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: auto;
}

.sidebar.collapsed .sidebar-footer {
    flex-direction: column;
    padding: 1rem 0.5rem;
}

.user-role-display {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    background: rgba(30, 64, 175, 0.1);
    padding: 0.4rem 0.75rem;
    border-radius: 40px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar.collapsed .user-role-display {
    display: none;
}

.btn-logout-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.1rem;
}

.btn-logout-icon:hover {
    background: var(--danger);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-profile-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(30, 64, 175, 0.1);
    color: var(--primary);
    border: 1px solid rgba(30, 64, 175, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1.25rem;
    text-decoration: none;
}

.btn-profile-icon:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.3);
}

/* Stats Section Enhancements */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.hero {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--nav-height) - 4rem);
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    line-height: 1.2;
    color: #1e293b;
}

.hero p {
    font-size: 1.125rem;
    max-width: 650px;
    color: var(--text-muted);
    margin-bottom: 3rem;
    margin-left: auto;
    margin-right: auto;
}

.hero-btns {
    max-width: 500px;
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.hero-btns .btn {
    justify-content: center;
    padding: 1rem 1.5rem;
    font-size: 1.1rem;
}

.stat-info {
    flex: 1;
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-info .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-light);
}

.stat-card.primary .stat-icon {
    background: rgba(79, 70, 229, 0.2);
    color: #818cf8;
}

.stat-card.warning .stat-icon {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.stat-card.success .stat-icon {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.stat-card.danger .stat-icon {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

/* Sidebar Toggle Functionality Managed via active/collapsed classes */

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        top: 0;
        z-index: 2000;
        height: 100vh;
        width: 280px;
        padding-top: 4rem;
        display: block !important;
        /* Ensure visibility for transform */
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 1999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    .admin-grid {
        padding-left: 0 !important;
        grid-template-columns: 1fr;
    }

    .sidebar.collapsed .sidebar-link span {
        display: block;
    }

    .main-content {
        padding: 1.25rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Scrollbar for Glassmorphism */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}