/* HRMS Modern Dark Sidebar Design */

:root {
    --sidebar-width: 260px;
    --topbar-height: 52px;

    /* Colors */
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --primary-darker: #3730a3;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    --danger-dark: #dc2626;
    --warning-dark: #d97706;
    --info-dark: #2563eb;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    /* Transitions */
    --transition: all 0.2s ease;
    --transition-fast: all 0.15s ease;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100vh;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 8px;
    background: white;
    color: var(--gray-900);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-md);
    z-index: 2000;
}

.skip-link:focus {
    left: 16px;
}

/* ========== DARK SIDEBAR ========== */
#sidebar.ui.sidebar.inverted {
    width: var(--sidebar-width);
    background: #1b1c1d;
    padding: 0;
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow: hidden;
    transform: translateX(0);
    border-right: none;
    display: block;
    visibility: visible;
}

/* Sidebar scrollable content area */
#sidebar .sidebar-menu-content {
    height: calc(100vh - var(--topbar-height));
    height: calc(100dvh - var(--topbar-height));
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 1rem;
    overscroll-behavior: contain;
}

#sidebar.ui.sidebar.inverted.visible {
    transform: translateX(0);
}

/* Sidebar Section Headers */
#sidebar.ui.inverted.menu > .item {
    padding: 0.5rem 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

#sidebar.ui.inverted.menu > .item > .header {
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem 0.5rem !important;
    margin: 0 !important;
}

/* Sidebar Menu Items */
#sidebar.ui.inverted.menu .menu {
    margin: 0 !important;
    padding: 0 !important;
}

#sidebar.ui.inverted.menu .menu .item {
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 0.75rem 1rem !important;
    margin: 0 !important;
    border-radius: 0 !important;
    transition: var(--transition-fast);
    font-weight: 400;
    font-size: 0.9rem;
    background: transparent !important;
}

#sidebar.ui.inverted.menu .menu .item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: white !important;
}

#sidebar.ui.inverted.menu .menu .item.active {
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
}

#sidebar.ui.inverted.menu .menu .item div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#sidebar.ui.inverted.menu .menu .item i.icon {
    color: rgba(255, 255, 255, 0.6);
    margin: 0 !important;
    width: 1.25rem;
    text-align: center;
}

#sidebar.ui.inverted.menu .menu .item:hover i.icon {
    color: rgba(255, 255, 255, 0.9);
}

/* Sidebar Progress/Language */
#sidebar .sidebar-progress {
    margin: 0 !important;
    padding: 1rem !important;
    background: rgba(0, 0, 0, 0.2) !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    flex-shrink: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

#sidebar .sidebar-progress .menu {
    max-height: 40vh;
    overflow-y: auto;
}

#sidebar .sidebar-progress .ui.dropdown {
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
}

#sidebar .sidebar-progress .ui.dropdown .menu {
    background: #2d2e2f;
}

/* Sidebar Overlay */
#sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

/* ========== DARK TOP NAVBAR ========== */
#topnav.ui.top.fixed.inverted.menu {
    left: 0;
    right: 0;
    width: 100%;
    height: var(--topbar-height);
    border: none;
    background: #1b1c1d !important;
    box-shadow: none;
    z-index: 1001;
    border-radius: 0;
    margin: 0;
}

#topnav.ui.inverted.menu .left.menu,
#topnav.ui.inverted.menu .right.menu {
    display: flex;
    align-items: center;
}

#topnav.ui.inverted.menu .item {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    padding: 0.875rem 1rem;
}

#topnav .sidebar-menu-toggler {
    display: none;
}

#topnav.ui.inverted.menu .item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

#topnav.ui.inverted.menu .header.item {
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.02em;
    color: white !important;
}

#topnav.ui.inverted.menu .header.item:hover {
    background: transparent !important;
}

#topnav .sidebar-menu-toggler i.icon {
    font-size: 1.1rem;
    margin: 0 !important;
}

#topnav .dropdown .menu {
    background: #2d2e2f !important;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    margin-top: 0.5rem;
}

#topnav .dropdown .menu .item {
    color: rgba(255, 255, 255, 0.85) !important;
    padding: 0.75rem 1rem !important;
}

#topnav .dropdown .menu .item:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

#topnav .dropdown .menu .item i.icon {
    color: rgba(255, 255, 255, 0.6);
    margin-right: 0.5rem !important;
}

/* ========== MAIN LAYOUT ========== */
.main-wrapper {
    margin-left: 0;
    padding-left: var(--sidebar-width);
    padding-top: var(--topbar-height);
    min-height: 100vh;
    background: var(--gray-100);
}

.main-content {
    padding: 1.5rem;
    max-width: 100%;
}

/* Messages */
.messages-container {
    margin-bottom: 1.5rem;
}

.ui.message {
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: none;
}

/* Toasts */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
    width: min(360px, calc(100vw - 2rem));
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    padding: 0.75rem 1rem;
    pointer-events: auto;
    animation: toast-in 0.2s ease;
}

.toast.hide {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast i.icon {
    margin: 0;
    font-size: 1.1rem;
}

.toast-body {
    flex: 1;
}

.toast-title {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--gray-900);
    margin-bottom: 0.2rem;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--gray-700);
    white-space: pre-line;
}

.toast-close {
    background: transparent;
    border: 0;
    color: var(--gray-400);
    font-size: 1.1rem;
    cursor: pointer;
    margin-left: 0.25rem;
}

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-success i.icon {
    color: var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-error i.icon {
    color: var(--danger);
}

.toast-warning {
    border-left: 4px solid var(--warning);
}

.toast-warning i.icon {
    color: var(--warning);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========== MOBILE BOTTOM NAV ========== */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: none;
    align-items: center;
    justify-content: space-around;
    gap: 0.25rem;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid var(--gray-200);
    padding: 0.5rem 0.35rem calc(0.75rem + env(safe-area-inset-bottom));
    z-index: 998;
    backdrop-filter: blur(8px);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    color: var(--gray-500);
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
    padding: 0.4rem 0.5rem;
    border-radius: 0.75rem;
    min-width: 52px;
}

.mobile-nav-item i {
    font-size: 1.1rem;
    margin: 0;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

/* ========== CARDS ========== */
.ui.card, .ui.cards > .card {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.ui.card:hover, .ui.cards > .card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    transition: var(--transition);
}

/* ========== SEGMENTS ========== */
.ui.segment {
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

/* ========== STAT CARDS ========== */
.stat-card {
    text-align: center;
    padding: 1.5rem !important;
    background: white;
}

.stat-card .icon-wrapper {
    width: 3rem;
    height: 3rem;
    border-radius: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.stat-card .icon-wrapper.primary { background: rgba(79, 70, 229, 0.1); }
.stat-card .icon-wrapper.primary i { color: var(--primary); }

.stat-card .icon-wrapper.success { background: rgba(16, 185, 129, 0.1); }
.stat-card .icon-wrapper.success i { color: var(--success); }

.stat-card .icon-wrapper.warning { background: rgba(245, 158, 11, 0.1); }
.stat-card .icon-wrapper.warning i { color: var(--warning); }

.stat-card .icon-wrapper.danger { background: rgba(239, 68, 68, 0.1); }
.stat-card .icon-wrapper.danger i { color: var(--danger); }

.stat-card .icon-wrapper.info { background: rgba(59, 130, 246, 0.1); }
.stat-card .icon-wrapper.info i { color: var(--info); }

.stat-card .value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    line-height: 1;
}

.stat-card .label {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    font-weight: 500;
}

/* ========== BUTTONS ========== */
.ui.button {
    border-radius: var(--radius);
    font-weight: 500;
    transition: var(--transition);
}

.ui.primary.button {
    background: var(--primary);
}

.ui.primary.button:hover {
    background: var(--primary-dark);
}

/* Button loading state */
.ui.button.loading {
    position: relative;
    cursor: default;
    pointer-events: none;
    color: transparent !important;
}

.ui.button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1.2em;
    height: 1.2em;
    margin: -0.6em 0 0 -0.6em;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: button-spin 0.6s linear infinite;
}

.ui.button.loading i.icon {
    visibility: hidden;
}

.ui.button:not(.primary):not(.red):not(.green):not(.secondary).loading::after {
    border-color: rgba(0, 0, 0, 0.15);
    border-top-color: var(--gray-600);
}

@keyframes button-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== PAGE HEADER ========== */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0;
    letter-spacing: -0.025em;
}

.page-header .sub-header {
    color: var(--gray-500);
    font-size: 0.9375rem;
    margin-top: 0.25rem;
}

/* Page Header Section */
.page-header-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.5rem;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.page-header-section h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.page-header-section .actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ========== WELCOME SECTION ========== */
.welcome-section {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 1rem;
    padding: 2rem;
    color: white;
    margin-bottom: 2rem;
}

.welcome-section h1 {
    color: white;
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0 0 0.5rem;
}

.welcome-section p {
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}

/* ========== EMPLOYEE HOME ========== */
.employee-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(16, 185, 129, 0.16) 100%);
    border: 1px solid rgba(15, 23, 42, 0.08);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    gap: 2rem;
}

.employee-hero::before,
.employee-hero::after {
    content: "";
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    z-index: 0;
}

.employee-hero::before {
    top: -120px;
    right: -60px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.35), rgba(59, 130, 246, 0));
}

.employee-hero::after {
    bottom: -140px;
    left: -80px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.28), rgba(16, 185, 129, 0));
}

.employee-hero-content {
    position: relative;
    z-index: 1;
}

.employee-kicker {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--gray-600);
    margin-bottom: 0.75rem;
}

.employee-hero h1 {
    margin: 0 0 0.75rem;
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    letter-spacing: -0.02em;
}

.employee-hero p {
    margin: 0 0 1.5rem;
    color: var(--gray-600);
    font-size: 1rem;
}

.employee-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.employee-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.employee-pill i {
    color: var(--primary-dark);
    margin: 0;
}

.employee-card {
    position: relative;
    z-index: 1;
    background: white;
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
}

.employee-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.employee-avatar {
    width: 72px;
    height: 72px;
    border-radius: 1rem;
    overflow: hidden;
    border: 2px solid rgba(59, 130, 246, 0.2);
    background: var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
}

.employee-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.employee-avatar-fallback {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-dark);
    text-transform: uppercase;
}

.employee-card-title .name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--gray-900);
}

.employee-card-title .sub {
    color: var(--gray-500);
    font-size: 0.875rem;
}

.employee-status {
    margin-left: auto;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.employee-status.active {
    background: var(--success-light);
    color: var(--success);
}

.employee-status.inactive {
    background: var(--danger-light);
    color: var(--danger);
}

.employee-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem 1.25rem;
}

.employee-meta-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.employee-meta-item .label {
    font-size: 0.72rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-500);
    font-weight: 600;
}

.employee-meta-item .value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--gray-800);
    word-break: break-word;
}

/* ========== QUICK ACTIONS ========== */
.quick-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ========== TABLES ========== */
.ui.table {
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.ui.table thead th {
    background: var(--gray-50);
    color: var(--gray-600);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
}

.ui.table tbody td {
    border-color: var(--gray-100);
}

/* ========== LOGIN PAGE ========== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    padding: 1rem;
}

.login-box {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: white;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    padding: 2.5rem;
    border: 1px solid var(--gray-200);
}

.login-card .logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .logo-icon {
    width: 3.5rem;
    height: 3.5rem;
    background: var(--primary);
    border-radius: 0.75rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.login-card .logo-icon i {
    color: white;
    font-size: 1.5rem;
    margin: 0;
}

.login-card .logo h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 0.25rem;
    letter-spacing: -0.025em;
}

.login-card .logo p {
    color: var(--gray-500);
    font-size: 0.875rem;
    margin: 0;
}

.login-card .ui.form .field > label {
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.login-card .ui.form .field .ui.input input {
    border-radius: 0.5rem;
    border: 1px solid var(--gray-300);
    padding: 0.75rem 1rem 0.75rem 2.75rem;
    transition: var(--transition);
}

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

.login-card .ui.form .field .ui.input i.icon {
    color: var(--gray-400);
}

.login-card .ui.checkbox label {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.login-card .ui.primary.button {
    background: var(--primary);
    border-radius: 0.5rem;
    padding: 0.875rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.login-card .ui.primary.button:hover {
    background: var(--primary-dark);
}

.login-card .language-select {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

.login-card .language-select .ui.menu {
    box-shadow: none;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
}

/* ========== LANDING PAGE ========== */
.landing-hero {
    text-align: center;
    padding: 4rem 2rem;
}

.landing-hero .icon-wrapper {
    width: 5rem;
    height: 5rem;
    background: var(--primary);
    border-radius: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.landing-hero .icon-wrapper i {
    color: white;
    font-size: 2rem;
    margin: 0;
}

.landing-hero h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
    margin: 0 0 0.5rem;
    letter-spacing: -0.025em;
}

.landing-hero p {
    color: var(--gray-500);
    font-size: 1.125rem;
    margin: 0 0 2rem;
}

/* ========== HTMX ========== */
.htmx-request {
    opacity: 0.6;
    transition: opacity 200ms ease-in;
}

/* ========== DROPDOWN ========== */
.ui.dropdown .menu {
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow-lg);
}

.ui.dropdown .menu .item {
    font-size: 0.875rem;
    padding: 0.625rem 1rem !important;
}

.ui.dropdown .menu .item:hover {
    background: var(--gray-50);
}

/* ========== FILTER SECTION ========== */
.filter-section {
    padding: 1.25rem;
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 1.5rem;
    position: relative;
    z-index: 2;
    overflow: visible;
}

.filter-section .ui.form .fields {
    margin-bottom: 0;
}

.filter-section .filter-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.filter-section .ui.dropdown .menu {
    z-index: 1005;
}

.calendar-filters {
    position: relative;
    z-index: 2;
    overflow: visible;
}

.calendar-filters .ui.dropdown .menu {
    z-index: 1005;
}

/* Global dropdown z-index fix */
.ui.form .ui.dropdown .menu,
.data-section .ui.dropdown .menu,
.ui.form .ui.selection.dropdown .menu {
    z-index: 1005 !important;
}

.data-section .ui.form {
    padding: 1.5rem;
}

/* Charts container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.chart-container canvas {
    max-height: 300px;
}

/* ========== DATA SECTION ========== */
.data-section {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    /* No overflow:hidden — it clips dropdown menus.
       Table corner rounding handled by first/last cell radius below. */
}

.data-section .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-section .ui.table {
    border: none;
    border-radius: 0;
    margin: 0;
}

/* Round top corners of first header row to match .data-section border-radius */
.data-section > .ui.table thead tr:first-child th:first-child,
.data-section > .table-wrapper .ui.table thead tr:first-child th:first-child {
    border-top-left-radius: var(--radius-md);
}
.data-section > .ui.table thead tr:first-child th:last-child,
.data-section > .table-wrapper .ui.table thead tr:first-child th:last-child {
    border-top-right-radius: var(--radius-md);
}

.data-section .ui.table thead th {
    position: sticky;
    top: 0;
    background: var(--gray-50);
    z-index: 1;
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--gray-500);
}

.empty-state i.icon {
    font-size: 3rem;
    color: var(--gray-300);
    margin-bottom: 1rem;
}

.empty-state h3 {
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state p {
    margin-bottom: 1.5rem;
}

/* ========== STATUS BADGES ========== */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-badge.success {
    background: var(--success-light);
    color: #065f46;
}

.status-badge.danger {
    background: var(--danger-light);
    color: #991b1b;
}

.status-badge.warning {
    background: var(--warning-light);
    color: #92400e;
}

.status-badge.info {
    background: var(--info-light);
    color: #1e40af;
}

/* ========== ACTION BUTTONS ========== */
.action-buttons {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.action-buttons .ui.button {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

/* ========== FORM IMPROVEMENTS ========== */
.ui.form .field > label {
    color: var(--gray-700);
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.ui.form input[type="text"],
.ui.form input[type="email"],
.ui.form input[type="password"],
.ui.form input[type="date"],
.ui.form input[type="number"],
.ui.form textarea,
.ui.form select {
    border-radius: var(--radius);
    border: 1px solid var(--gray-300);
    transition: var(--transition-fast);
}

.ui.form input:focus,
.ui.form textarea:focus,
.ui.form select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Checkbox improvements */
.ui.checkbox label {
    color: var(--gray-700);
}

.ui.checkbox input:checked ~ label:before {
    background: var(--primary);
    border-color: var(--primary);
}

/* ========== PAGINATION ========== */
.pagination-wrapper {
    display: flex;
    justify-content: center;
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
}

.ui.pagination.menu {
    border: none;
    box-shadow: none;
    background: transparent;
}

.ui.pagination.menu .item {
    border-radius: var(--radius);
    margin: 0 0.125rem;
    min-width: 2.5rem;
    justify-content: center;
}

.ui.pagination.menu .item:hover {
    background: var(--gray-100);
}

.ui.pagination.menu .active.item {
    background: var(--primary);
    color: white;
}

/* ========== RESPONSIVE - TABLET ========== */
@media only screen and (max-width: 991px) {
    .page-header-section {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .page-header-section .actions {
        justify-content: center;
    }

    .filter-section .ui.form .fields {
        flex-direction: column;
    }

    .filter-section .ui.form .field {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }

    .filter-section .filter-actions {
        width: 100%;
        justify-content: center;
    }

    .ui.stackable.cards > .card {
        width: 100% !important;
    }

    .employee-hero {
        grid-template-columns: 1fr;
    }
}

/* ========== RESPONSIVE - MOBILE ========== */
@media only screen and (max-width: 768px) {
    #sidebar.ui.sidebar.inverted {
        transform: translateX(-100%);
        width: 280px;
        top: 0;
        bottom: 0;
        z-index: 1002;
        display: block;
    }

    #sidebar.ui.sidebar.inverted.visible {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    #sidebar .sidebar-menu-content {
        height: 100vh;
        height: 100dvh;
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 1rem;
        overscroll-behavior: contain;
    }

    #sidebar-overlay {
        top: 0;
        z-index: 1001;
    }

    .main-wrapper {
        margin-left: 0;
        padding-left: 0;
        padding-bottom: 4.75rem;
    }

    .main-content {
        padding: 1rem 0.75rem 5.5rem;
    }

    #topnav .user-name {
        display: none !important;
    }

    #topnav .sidebar-menu-toggler {
        display: flex;
    }

    .toast-container {
        bottom: calc(3.5rem + env(safe-area-inset-bottom));
        width: calc(100vw - 1.5rem);
    }

    /* Stat cards: 2-column grid on mobile */
    .ui.stackable.four.cards {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem;
    }

    .ui.stackable.four.cards > .card {
        width: 100% !important;
        margin: 0 !important;
    }

    .stat-card {
        padding: 1rem !important;
    }

    .stat-card .value {
        font-size: 1.5rem;
    }

    .stat-card .icon-wrapper {
        width: 2.5rem;
        height: 2.5rem;
        margin-bottom: 0.5rem;
    }

    /* Page header: stack on mobile */
    .page-header-section {
        padding: 1rem;
    }

    .page-header-section h2 {
        font-size: 1.15rem;
    }

    .page-header-section .actions {
        width: 100%;
    }

    .page-header-section .actions .ui.button {
        flex: 1;
        justify-content: center;
        font-size: 0.8125rem;
        padding: 0.65rem 0.75rem;
    }

    /* Table mobile styling */
    .data-section .table-wrapper {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
    }

    .data-section .ui.table {
        min-width: 600px;
    }

    .ui.table td,
    .ui.table th {
        padding: 0.6rem 0.5rem !important;
        font-size: 0.8125rem;
    }

    /* Form mobile */
    .ui.form .fields {
        flex-direction: column;
    }

    .ui.form .fields > .field {
        width: 100% !important;
        margin: 0 0 1rem 0 !important;
    }

    /* Fomantic grid columns stack on mobile */
    .ui.stackable.grid > .column:not(.row),
    .ui.stackable.grid > .row > .column {
        width: 100% !important;
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }

    /* Button mobile */
    .ui.button {
        padding: 0.75rem 1rem;
    }

    .ui.mini.button {
        padding: 0.5rem 0.75rem;
    }

    /* Cards mobile */
    .ui.cards {
        margin: -0.5rem !important;
    }

    .ui.cards > .card {
        margin: 0.5rem !important;
    }

    /* Segment mobile */
    .ui.segment {
        padding: 1rem !important;
    }

    /* Data section padding */
    .data-section > div[style*="padding"] {
        padding: 0.75rem !important;
    }

    /* Calendar filters mobile */
    .calendar-filters {
        padding: 0.75rem;
    }

    .calendar-filters .ui.stackable.grid > .column {
        margin-bottom: 0.5rem;
    }

    /* Overview date picker (forecast) mobile */
    .overview-date-picker {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .overview-date-picker > * {
        width: 100%;
    }

    .overview-date-picker input[type="text"] {
        width: 100% !important;
    }

    .period-tab {
        width: 100%;
        display: flex;
    }

    .period-tab .tab-btn {
        flex: 1;
        text-align: center;
        font-size: 0.75rem;
        padding: 0.5rem 0.5rem;
    }

    /* Welcome section mobile */
    .welcome-section {
        padding: 1.5rem;
        border-radius: var(--radius-md);
    }

    .welcome-section h1 {
        font-size: 1.25rem;
    }

    .employee-hero {
        padding: 1.75rem;
        border-radius: var(--radius-lg);
    }

    .employee-hero h1 {
        font-size: 1.5rem;
    }

    .employee-card {
        padding: 1.5rem;
    }

    .employee-meta-grid {
        grid-template-columns: 1fr;
    }

    .mobile-nav {
        display: flex;
    }

    /* Landing page mobile */
    .landing-hero {
        padding: 2rem 1rem;
    }

    .landing-hero h1 {
        font-size: 1.5rem;
    }

    .landing-hero p {
        font-size: 1rem;
    }

    /* Quick actions mobile */
    .quick-actions {
        flex-direction: column;
    }

    .quick-actions .ui.button {
        width: 100%;
        justify-content: center;
    }

    /* Hide less important columns on mobile */
    .hide-mobile {
        display: none !important;
    }

    /* Pagination mobile */
    .ui.pagination.menu .item {
        min-width: 2rem;
        padding: 0.5rem !important;
        font-size: 0.8125rem;
    }

    /* Chart section mobile */
    .chart-section {
        padding: 1rem;
    }

    .chart-wrapper {
        height: 200px !important;
    }

    .chart-wrapper canvas {
        max-height: 200px;
    }

    /* Factory overview cards mobile */
    .factory-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .factory-overview-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* Legend mobile */
    .legend-item {
        font-size: 0.8rem;
    }

    /* Modal mobile */
    .ui.modal {
        width: 95% !important;
        margin: 0 auto;
    }

    /* FullCalendar mobile */
    .fc .fc-toolbar {
        flex-direction: column;
        gap: 0.5rem;
    }

    .fc .fc-toolbar-title {
        font-size: 1rem !important;
    }

    .fc .fc-button {
        padding: 0.3rem 0.5rem !important;
        font-size: 0.75rem !important;
    }
}

/* ========== RESPONSIVE - SMALL MOBILE ========== */
@media only screen and (max-width: 480px) {
    .main-content {
        padding: 0.75rem 0.5rem 5rem;
    }

    .page-header-section {
        padding: 0.75rem;
    }

    .page-header-section h2 {
        font-size: 1.1rem;
    }

    .page-header-section .actions {
        flex-direction: column;
    }

    .page-header-section .actions .ui.button {
        width: 100%;
    }

    .filter-section {
        padding: 0.75rem;
    }

    /* Stat cards single column on very small screens */
    .ui.stackable.four.cards {
        grid-template-columns: 1fr !important;
    }

    .stat-card .value {
        font-size: 1.25rem;
    }

    .stat-card .label {
        font-size: 0.75rem;
    }

    .employee-hero {
        padding: 1.25rem;
    }

    .employee-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .employee-status {
        margin-left: 0;
    }

    .mobile-nav-item {
        min-width: 46px;
        font-size: 0.7rem;
    }

    /* Data sections */
    .data-section .ui.table {
        min-width: 500px;
    }

    /* Calendar smaller */
    .fc .fc-daygrid-day-number {
        font-size: 0.75rem;
        padding: 2px 4px;
    }

    .fc-event {
        font-size: 0.65rem !important;
    }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

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

/* Dark scrollbar for sidebar */
#sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ========== HTMX MODAL FORMS ========== */
#htmx-modal {
    overflow: visible !important;
}
#htmx-modal .content,
#htmx-modal .scrolling.content {
    padding: 1.5rem !important;
    overflow: visible !important;
}
#htmx-modal .modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 1.25rem;
    margin-top: 1.25rem;
    border-top: 1px solid var(--gray-200);
}
#htmx-modal .ui.form .field {
    margin-bottom: 1rem;
}
#htmx-modal .ui.dropdown .menu {
    z-index: 1020 !important;
}

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .ui.card:hover, .ui.cards > .card:hover {
        transform: none;
    }
}

/* ========== TOOLTIP FIX ========== */
/* Suppress Fomantic UI CSS-only tooltips (::before/::after pseudo-elements).
   JS .popup({inline:false}) in base.html handles tooltips instead,
   appending them to <body> so they are never clipped by overflow:hidden. */
[data-tooltip]::before,
[data-tooltip]::after {
    display: none !important;
}
