:root {
    --primary: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --secondary: #64748b;
    --accent: #f43f5e;
    --background: #fdf2f8; /* Light pinkish background for warmth */
    --surface: rgba(255, 255, 255, 0.8);
    --sidebar-bg: rgba(255, 255, 255, 0.9);
    --text-main: #0f172a;
    --text-muted: #64748b;
    --white: #ffffff;
    --border: rgba(226, 232, 240, 0.5);
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 10px 15px -3px rgb(0 0 0 / 0.05), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --radius: 1rem;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar with Glassmorphism */
.sidebar {
    width: 280px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    box-shadow: 10px 0 30px rgba(0,0,0,0.03);
    
    /* Elegant vertical scrollability */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.2) transparent;
}

/* Custom scrollbar styling for Webkit browsers */
.sidebar::-webkit-scrollbar {
    width: 5px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 10px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.4);
}

.logo {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 3rem;
    padding-left: 0.5rem;
}

.logo i {
    color: #6366f1; /* Fallback */
    -webkit-text-fill-color: initial;
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1; /* Keep Sign Out pushed to bottom when not overflowing */
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    text-decoration: none;
    color: var(--text-muted);
    border-radius: var(--radius);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    border: 1px solid transparent;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.05);
    color: var(--primary);
    transform: translateX(5px);
}

.nav-item.active {
    background: var(--primary-gradient);
    color: var(--white);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
}

.nav-item i {
    width: 20px;
    height: 20px;
}

/* Main Content Area */
.content {
    flex: 1;
    margin-left: 280px;
    padding: 2.5rem;
    max-width: calc(100vw - 280px);
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    animation: fadeInDown 0.6s ease-out;
}

.header-search {
    position: relative;
    width: 450px;
}

.header-search i {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    pointer-events: none;
}

.header-search input {
    width: 100%;
    padding: 0.875rem 1.25rem 0.875rem 3.25rem;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    outline: none;
    transition: all 0.3s;
    box-shadow: var(--shadow-sm);
    font-size: 0.95rem;
}

.header-search input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    width: 110%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: var(--white);
    padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    border-radius: 2rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

.user-profile span {
    font-weight: 600;
    font-size: 0.9rem;
}

.avatar {
    width: 38px;
    height: 38px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

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

.stat-card {
    background: var(--white);
    padding: 2rem;
    border-radius: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    transition: all 0.3s;
    border: 1px solid var(--border);
    animation: fadeInUp 0.6s ease-out backwards;
}

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

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

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-info p {
    font-size: 1.75rem;
    font-weight: 800;
    background: #0f172a;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Stat card colors */
.bg-blue { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); color: #2563eb; }
.bg-green { background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%); color: #16a34a; }
.bg-orange { background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%); color: #ea580c; }
.bg-purple { background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%); color: #9333ea; }

/* Data Table Card */
.data-card {
    background: var(--white);
    border-radius: 2rem;
    box-shadow: var(--shadow);
    padding: 2rem;
    border: 1px solid var(--border);
    animation: fadeInUp 0.8s ease-out backwards;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 1rem;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.75rem;
}

th {
    text-align: left;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1.25rem 1.5rem;
    background: transparent;
    transition: all 0.2s;
    font-size: 0.95rem;
}

tbody tr {
    transition: all 0.3s;
}

tbody tr:hover td {
    background: #f8fafc;
}

tbody tr td:first-child { border-radius: 1rem 0 0 1rem; }
tbody tr td:last-child { border-radius: 0 1rem 1rem 0; }

/* Badges */
.badge {
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-size: 0.8rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
}

.badge-present { background: #dcfce7; color: #15803d; }
.badge-absent { background: #fee2e2; color: #b91c1c; }

/* Forms */
.form-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    padding: 3rem;
    border-radius: 2.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 1.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #475569;
}

.form-control {
    width: 100%;
    padding: 1rem 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    outline: none;
    font-family: inherit;
    transition: all 0.3s;
    font-size: 1rem;
    background: #f8fafc;
}

.form-control:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Profile specific */
.profile-header {
    display: flex;
    gap: 2rem;
    align-items: center;
    margin-bottom: 3rem;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    background: var(--primary-gradient);
    border-radius: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    font-weight: 800;
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.2);
}

.profile-info h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

/* --- Mobile Sidebar Overlay --- */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 90;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* --- Mobile Menu Button --- */
.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.3s;
}

.mobile-menu-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

/* Responsive */
@media (max-width: 1024px) {
    /* Enable Hamburger Menu */
    .mobile-menu-btn { display: block; }
    
    /* Sidebar Slides off screen */
    .sidebar {
        width: 260px;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        padding: 2rem 1.25rem;
        align-items: stretch;
    }
    
    /* Restore text and layout for sliding sidebar */
    .sidebar span, .logo span, .sidebar p { display: inline-block !important; }
    .logo { justify-content: flex-start; padding-left: 0.5rem; }
    .nav-item { justify-content: flex-start; padding: 1rem 1.25rem; }
    .nav-item i { margin-right: 1rem; }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .content { margin-left: 0; width: 100%; max-width: 100%; padding: 1rem; overflow-x: hidden; }
    header { flex-direction: column; gap: 1rem; align-items: stretch; margin-bottom: 2rem; }
    .header-search { width: 100%; flex: none !important; }
    .header-search input:focus { width: 100%; /* Prevent horizontal overflow on mobile focus */ }
    .user-profile { align-self: flex-start; width: 100%; justify-content: flex-start; }
    .form-container { padding: 1.5rem; border-radius: 1.5rem; }
    
    .welcome-banner { padding: 1.8rem 1.5rem; margin-bottom: 2rem; border-radius: 1.5rem; }
    .welcome-banner h1 { font-size: 1.8rem; }
    .welcome-banner p { font-size: 0.95rem; }
    .welcome-banner i.bg-icon { right: -15px; bottom: -15px; font-size: 6rem; }
    
    .stats-grid { grid-template-columns: 1fr; gap: 1rem; }
    .stat-card { padding: 1.25rem 1.5rem; border-radius: 1.25rem; }
    .stat-icon { width: 50px; height: 50px; font-size: 1.25rem; }
    
    .data-card { padding: 1.25rem; border-radius: 1.25rem; overflow-x: auto; width: 100%; }
    .card-header { flex-direction: column; align-items: flex-start; gap: 1rem; border-bottom: none; padding-bottom: 0; margin-bottom: 1rem; }
    .card-header > div { width: 100%; display: flex; flex-wrap: wrap; gap: 0.5rem; }
    .card-header h2 { font-size: 1.2rem; margin-bottom: 0.5rem; }
    
    /* Action Buttons Stack */
    .btn-primary { padding: 0.6rem 1rem; font-size: 0.85rem; flex: 1; text-align: center; justify-content: center; }
    
    .profile-header { flex-direction: column; text-align: center; gap: 1rem; }
    .profile-info h1 { font-size: 1.8rem; }
    
    /* Table Fixes */
    table { min-width: 600px; /* Forces tables to be scrollable horizontally */ }
    th, td { padding: 0.8rem; font-size: 0.85rem; white-space: nowrap; }
    
    /* Form fields stretch */
    form[action="index.php"] { flex-direction: column; align-items: stretch; width: 100%; }
    .input-field { width: 100%; }
}

@media (max-width: 480px) {
    /* Extreme small screen adjustments */
    .user-profile span { font-size: 0.8rem; }
    .avatar { width: 32px; height: 32px; font-size: 0.9rem; }
    .content { padding: 1rem 0.5rem; }
    table { font-size: 0.8rem; }
}


body.webview-mode .sidebar { display: none !important; }
body.webview-mode .header { display: none !important; }
body.webview-mode .app-container { margin-left: 0 !important; padding: 0 !important; }
body.webview-mode .main-content { margin-left: 0 !important; padding: 10px !important; } .webview-mode .sidebar-overlay { display: none !important; }
