/* HRMS - Main Stylesheet (Matsya-inspired design system) */

/* ============================================================
   CSS Variables / Design Tokens
   ============================================================ */
:root {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --primary-light: #60A5FA;
    --secondary: #64748B;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --info: #06B6D4;

    --dark: #1E293B;
    --darker: #0F172A;
    --light: #F8FAFC;
    --white: #FFFFFF;

    --gray-100: #F1F5F9;
    --gray-200: #E2E8F0;
    --gray-300: #CBD5E1;
    --gray-400: #94A3B8;
    --gray-500: #64748B;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1E293B;

    --sidebar-width: 250px;
    --topbar-height: 60px;

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--light);
    color: var(--gray-800);
    font-size: 0.9375rem;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
    position: fixed;
    left: 0; top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--darker);
    color: var(--white);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--white);
    text-decoration: none;
}
.sidebar .logo:hover { text-decoration: none; }

.sidebar .logo img {
    height: 32px;
    width: auto;
}

/* Sidebar org name */
.sidebar-org {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-400);
}
.sidebar-org i {
    font-size: 0.875rem;
    color: var(--primary-light);
}
.sidebar-org span {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Sidebar user card */
.sidebar-user {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-user .user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(59,130,246,0.2);
    color: var(--primary-light);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.875rem;
    flex-shrink: 0;
}

.sidebar-user .user-details { flex: 1; min-width: 0; }

.sidebar-user .user-name {
    font-size: 0.875rem; font-weight: 600; color: var(--white);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-user .user-role {
    font-size: 0.75rem; color: var(--gray-400);
}

/* Sidebar navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: scroll;
    padding: 0.75rem 0;
    scrollbar-width: auto;
    scrollbar-color: rgba(255,255,255,0.5) rgba(255,255,255,0.1);
    scrollbar-gutter: stable;
}
.sidebar-nav::-webkit-scrollbar { width: 10px; }
.sidebar-nav::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.45); border-radius: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.45); }

.nav-section-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    padding: 0.75rem 1.25rem 0.375rem;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.08);
    margin: 0.5rem 1.25rem;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--gray-400);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
    font-size: 0.875rem;
}
.sidebar .nav-link:hover {
    color: var(--white);
    background: rgba(255,255,255,0.05);
    text-decoration: none;
}
.sidebar .nav-link.active {
    color: var(--white);
    background: rgba(59, 130, 246, 0.15);
    border-left-color: var(--primary);
}
.sidebar .nav-link i {
    width: 20px; text-align: center; font-size: 0.9375rem;
}

.nav-badge {
    display: inline-block;
    margin-left: auto;
    font-size: 0.6875rem;
    padding: 0.125rem 0.375rem;
    background: var(--danger);
    color: white;
    border-radius: 0.625rem;
    font-weight: 600;
}

/* Sidebar footer */
.sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-footer .nav-link { padding: 0.5rem 0; color: var(--gray-400); font-size: 0.875rem; }
.sidebar-footer .nav-link:hover { color: var(--danger); }

/* ============================================================
   Main Content Area
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top bar */
.topbar {
    display: flex;
    align-items: center;
    height: var(--topbar-height);
    padding: 0 1.5rem;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar .sidebar-toggle {
    display: none;
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius);
    color: var(--gray-700);
    font-size: 1.125rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-right: 0.75rem;
}
.topbar .sidebar-toggle:hover { background: var(--gray-200); }

.topbar-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--dark);
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.topbar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
}

.topbar-user-name {
    font-weight: 500;
}

/* Page content */
.page-content {
    flex: 1;
    padding: 1.5rem;
}

/* ============================================================
   Cards
   ============================================================ */
.card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    word-break: break-word;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title { font-size: 1rem; font-weight: 600; margin: 0; }

.card-body { padding: 1.5rem; }

/* ============================================================
   Typography — inside page content
   ============================================================ */
.page-content h1 {
    font-size: 1.375rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
    color: var(--gray-800);
    letter-spacing: -0.01em;
}

/* Hide h1 if it duplicates the topbar title — first h1 in page-content is hidden */
.page-content > h1:first-child { display: none; }
.page-content > .card > .card-body > h1:first-child { display: none; }

.page-content h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
    color: var(--gray-800);
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.page-content h2:first-child { margin-top: 0; }

.page-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.375rem 0;
    color: var(--gray-700);
}

.page-content h4 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: var(--gray-700);
}

.page-content p {
    margin: 0 0 0.75rem 0;
    color: var(--gray-600);
    line-height: 1.6;
}

.page-content section {
    margin-bottom: 1.5rem;
}

.page-content section:last-child { margin-bottom: 0; }

/* Navigation links (home page quick links) */
.page-content nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    color: var(--gray-700);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    text-decoration: none;
}
.page-content nav a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #EFF6FF;
    text-decoration: none;
}
.page-content nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ============================================================
   Tables
   ============================================================ */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: 0.875rem;
}

thead tr { background: var(--gray-100); }

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8125rem;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: 2px solid var(--gray-200);
}

td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
    color: var(--gray-700);
}

tbody tr { transition: background 0.15s; }
tbody tr:hover { background: var(--gray-100); }
tbody tr:last-child td { border-bottom: none; }

/* Table responsive wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    margin: 0.75rem 0;
}
.table-responsive table { margin-bottom: 0; border: none; }

/* Leaves table (used in admin/leaves view) */
.leaves-table { width: 100%; border-collapse: collapse; }
.leaves-table th,
.leaves-table td { padding: 0.75rem 1rem; border-bottom: 1px solid var(--gray-100); text-align: left; font-size: 0.875rem; }
.leaves-table thead tr { background: var(--gray-100); }
.leaves-table th { font-weight: 600; font-size: 0.8125rem; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.025em; border-bottom: 2px solid var(--gray-200); }
.leaves-table tbody tr:hover { background: var(--gray-100); }

/* Ensure buttons in tables are always visible */
.table-responsive td .btn,
.table-responsive td a.btn,
td .btn, td a.btn {
    opacity: 1; visibility: visible;
}

/* ============================================================
   Forms
   ============================================================ */

/* Constrain forms to readable width — and centre them (so they align with other centred content). */
.page-content > form,
.page-content > section > form,
.page-content > div > form:not(.top-bar-search),
.page-content form.form-constrained {
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

label, .form-label {
    font-weight: 500;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    color: var(--gray-700);
    display: block;
}

label span {
    display: block;
    font-size: 0.8125rem;
    color: var(--gray-600);
    font-weight: 500;
    margin-bottom: 0.375rem;
}

/* Two-column form grid: direct child labels of a form sit in 2 cols */
.page-content > form,
.page-content > section > form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 1.25rem;
}

/* Elements that should span full width in the grid */
.page-content > form > h2,
.page-content > form > h3,
.page-content > form > p,
.page-content > form > div,
.page-content > form > a,
.page-content > form > article,
.page-content > form > hr,
.page-content > form > input[type="hidden"],
.page-content > form > .form-row,
.page-content > form > .form-content,
.page-content > form > .form-title,
.page-content > section > form > h2,
.page-content > section > form > h3,
.page-content > section > form > p,
.page-content > section > form > div,
.page-content > section > form > a,
.page-content > section > form > article,
.page-content > section > form > hr,
.page-content > section > form > input[type="hidden"],
.page-content > section > form > .form-row,
.page-content > section > form > .form-content,
.page-content > section > form > .form-title {
    grid-column: 1 / -1;
}

/* Buttons inside form grid: don't stretch, align left */
.page-content > form > button,
.page-content > section > form > button {
    grid-column: 1 / -1;
    justify-self: start;
}

/* Textarea labels span full width */
.page-content > form > label:has(textarea),
.page-content > form > label:has(select[multiple]),
.page-content > section > form > label:has(textarea),
.page-content > section > form > label:has(select[multiple]) {
    grid-column: 1 / -1;
}

input, select, textarea {
    border: 1px solid var(--gray-300) !important;
    border-radius: var(--radius) !important;
    padding: 0.625rem 0.875rem !important;
    font-size: 0.875rem !important;
    transition: all 0.2s;
    width: 100%;
    font-family: inherit;
    color: var(--gray-800);
    background: var(--white);
    line-height: 1.5;
    height: auto !important;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input[type="checkbox"], input[type="radio"] {
    width: auto; height: auto !important;
    margin-right: 0.5rem;
    padding: 0 !important;
}

input[type="hidden"] { display: none; }

textarea { min-height: 100px; resize: vertical; }
select { cursor: pointer; }
select[multiple] { min-height: 140px; }

/* Form layout helpers */
.form-row {
    display: flex; gap: 1rem; align-items: flex-start;
    flex-wrap: wrap; margin-bottom: 1rem;
}
.form-row .form-group {
    display: flex; flex-direction: column;
    flex: 1 1 200px; min-width: 160px;
}
.form-row.full-width .form-group { flex: 1 1 100%; }

/* Form grid class for explicit 2-column layout */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    max-width: 640px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 0.25rem; }

/* Inline pairs */
.inline-pair {
    display: inline-flex; gap: 0.5rem; align-items: center;
    font-size: 0.875rem; color: var(--gray-800);
}
.inline-pair label { font-weight: 600; color: var(--gray-500); margin: 0; font-size: 0.8125rem; white-space: nowrap; }

.readonly-field {
    padding: 0.5rem 0.75rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    display: inline-block;
    font-size: 0.875rem;
    color: var(--gray-700);
}
.readonly-field.inline { background: transparent; border: none; padding: 0; }

/* Validation */
.invalid-message { color: var(--danger); font-size: 0.8125rem; margin-top: 0.25rem; display: block; }
input.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1); }

/* Width trims for table inputs */
table input[type="number"],
table input[type="text"],
table select { max-width: 140px; padding: 0.375rem 0.5rem !important; font-size: 0.8125rem !important; }

/* ============================================================
   Buttons
   ============================================================ */
button, .btn {
    display: inline-flex;
    align-items: center; justify-content: center; gap: 0.375rem;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.5;
    text-decoration: none;
    color: var(--white);
    background: var(--primary);
    border-color: var(--primary);
    height: auto;
    width: auto;
}
button:hover, .btn:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; }

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; border-color: #DC2626; }

.btn-success { background: var(--success); border-color: var(--success); }
.btn-success:hover { background: #059669; border-color: #059669; }

.btn-warning { background: var(--warning); border-color: var(--warning); color: var(--gray-800); }

.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: var(--white); }

.btn-light { background: var(--gray-100); border-color: var(--gray-200); color: var(--gray-700); }
.btn-light:hover { background: var(--gray-200); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }

/* btn-primary class for explicit primary (Bootstrap pattern used in views) */
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-icon {
    width: 36px; height: 36px; padding: 0;
    border-radius: 50%;
    background: transparent; border: none;
    color: var(--gray-600);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-800); }

/* Add/Remove row buttons */
.btn-add {
    background: linear-gradient(180deg, var(--primary), var(--primary-dark));
    border-color: var(--primary-dark);
    padding: 0.5rem 1rem; font-weight: 600;
}
.btn-add::before { content: "+"; margin-right: 0.375rem; font-weight: 700; }

.btn-remove {
    background: transparent; color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.375rem 0.75rem;
}
.btn-remove:hover { background: rgba(239, 68, 68, 0.05); color: var(--danger); }

/* Action cell */
.action-cell { display: flex; gap: 0.5rem; align-items: center; }

.action-edit {
    background: var(--primary); border-color: var(--primary); color: var(--white);
    padding: 0.375rem 0.75rem; font-size: 0.8125rem; border-radius: var(--radius-sm);
}
.action-edit:hover { background: var(--primary-dark); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-block;
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    border-radius: 1rem;
    font-weight: 500;
    line-height: 1.2;
}
.badge-primary { background: rgba(59,130,246,0.1); color: var(--primary-dark); }
.badge-success { background: #D1FAE5; color: #059669; }
.badge-warning { background: #FEF3C7; color: #D97706; }
.badge-danger { background: #FEE2E2; color: #DC2626; }
.badge-info { background: #CFFAFE; color: #0891B2; }
.badge-secondary { background: var(--gray-200); color: var(--gray-600); }

/* ============================================================
   Flash / Alerts — article[role="alert"] and article[role="status"]
   ============================================================ */
article[role="alert"],
article[role="status"] {
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid;
    line-height: 1.5;
}

article[role="alert"] {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #991B1B;
}

article[role="status"] {
    background: #F0FDF4;
    border-color: #BBF7D0;
    color: #166534;
}

/* ============================================================
   Leave cards dashboard (admin/leaves view)
   ============================================================ */
.leave-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.leave-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s;
}

.leave-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--gray-300);
}

.leave-card h3 {
    margin: 0 0 0.375rem;
    font-size: 0.8125rem;
    color: var(--gray-500);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    border-bottom: none;
    padding-bottom: 0;
}

.leave-card .big {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
}

.leave-card .muted {
    font-size: 0.8125rem;
    color: var(--gray-400);
    margin-top: 0.25rem;
}

.leave-type-list {
    display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 0.75rem;
}
.leave-type {
    background: var(--gray-100);
    padding: 0.375rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.8125rem;
    color: var(--gray-600);
    font-weight: 500;
}

/* ============================================================
   Modals
   ============================================================ */
#activity-details-modal {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    align-items: center; justify-content: center;
    z-index: 9999;
}
#activity-details-modal .modal-card {
    background: var(--white); max-width: 700px; width: 92%;
    padding: 1.5rem; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
#activity-details-modal .modal-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;
}

/* ============================================================
   Wide multiselect
   ============================================================ */
.wide-multiselect {
    min-width: 420px;
    max-width: 90%;
    height: auto !important;
    min-height: 140px;
}

/* ============================================================
   Utilities
   ============================================================ */
.muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.stack { display: grid; gap: 1rem; }
.row { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

.fw-600 { font-weight: 600; }
.text-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Empty state */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--gray-500); }
.empty-state i { font-size: 2.5rem; color: var(--gray-300); margin-bottom: 1rem; display: block; }
.empty-state h3 { font-size: 1.125rem; color: var(--gray-600); margin-bottom: 0.5rem; }

/* Loading spinner */
.spinner { width: 40px; height: 40px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Date helper */
.dmY-helper { display: inline-block; margin-left: 0.5rem; vertical-align: middle; width: 150px; padding: 0.375rem 0.5rem; }

/* Section containers within page content */
.page-content > section {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

/* Articles used as task cards / inline items in views */
.page-content article:not([role]) {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: box-shadow 0.2s;
}
.page-content article:not([role]):hover {
    box-shadow: var(--shadow);
}

/* HR separator */
hr {
    border: none;
    border-top: 1px solid var(--gray-200);
    margin: 1.5rem 0;
}

/* Container class used in some views */
.page-content .container {
    max-width: 100%;
    padding: 0;
}

/* Tables in page-content — wrap in card-like container */
.page-content > table,
.page-content > .table-responsive {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

/* Images */
img { max-width: 100%; height: auto; }

/* Small text helper used in views */
small { font-size: 0.8125rem; }
small.muted { color: var(--gray-400); }

/* ============================================================
   Sidebar overlay for mobile
   ============================================================ */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1040;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active { display: block; opacity: 1; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); z-index: 1050; }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .topbar .sidebar-toggle { display: flex; }
    .topbar { padding: 0 1rem; }
    .topbar-title { font-size: 1rem; }
    .topbar-user-name { display: none; }
}

@media (max-width: 767.98px) {
    .page-content { padding: 1rem; }
    .card-body { padding: 1rem; }
    .form-row { flex-direction: column; }
    .form-row .form-group { min-width: 100%; }
    .wide-multiselect { min-width: 0; max-width: 100%; }
    table { font-size: 0.8125rem; }

    /* Collapse form grids to single column on tablet/mobile */
    .page-content > form,
    .page-content > section > form,
    .form-grid {
        grid-template-columns: 1fr;
    }
    th, td { padding: 0.5rem 0.625rem; }
    .leave-cards { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 575.98px) {
    .page-content { padding: 0.75rem; }
    .btn { padding: 0.5rem 0.875rem; }
    .btn-sm { padding: 0.375rem 0.625rem; }
    #activity-details-modal .modal-card { width: 96%; }
    #activity-details-modal .modal-grid { grid-template-columns: 1fr; }
    .leave-cards { grid-template-columns: 1fr; }
}

/* Responsive tables */
@media (max-width: 767.98px) {
    .table-responsive table { display: block; width: 100%; }
    .table-responsive thead,
    .table-responsive tbody,
    .table-responsive tr { display: table; width: 100%; table-layout: fixed; }
}


/* Sidebar scroll fix - ensure nav area scrolls within viewport */
.sidebar {
    display: flex !important;
    flex-direction: column !important;
    height: 100vh !important;
    overflow: hidden !important;
}
.sidebar-nav {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

/* ============================================================
   UI Polish v2 (Jul 2026) — cohesive world-class refresh.
   Appended last so it layers over the base; delete this block to revert.
   ============================================================ */

/* Cooler app canvas so white surfaces lift off the page */
body { background-color: #F4F6FB; }

/* Cards: refined hairline border, soft layered shadow, lift on clickable cards */
.card {
    border-color: #E8ECF3;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.03);
    transition: box-shadow .18s ease, border-color .18s ease, transform .18s ease;
}
a.card:hover, .card.clickable:hover, .card-hover:hover {
    box-shadow: 0 12px 28px -12px rgba(16,24,40,.20);
    border-color: #DCE3EF;
    transform: translateY(-2px);
    text-decoration: none;
}
.card-header { padding: 1rem 1.5rem; border-bottom-color: #EEF1F6; }
.card-title { font-size: 1.02rem; font-weight: 650; letter-spacing: -.01em; }

/* Tables: crisper header, whisper-soft zebra, gentle row hover, cooler borders */
.table-responsive { border-color: #E8ECF3; border-radius: 14px; box-shadow: 0 1px 2px rgba(16,24,40,.03); }
thead tr { background: #F7F9FC; }
th { color: #64748B; border-bottom-color: #E8ECF3; font-size: .72rem; }
td { border-bottom-color: #F0F3F8; color: #334155; }
tbody tr:nth-child(even) { background: #FCFDFE; }
tbody tr:hover { background: #F1F6FE; }

/* Inputs: cooler resting/hover border, softer placeholder (focus ring already themed) */
input, select, textarea { border-color: #D8E0EC !important; }
input::placeholder, textarea::placeholder { color: #9AA6B8; }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: #C2CDDD !important; }

/* Buttons: subtle depth, tactile press, accessible keyboard focus ring */
button, .btn { box-shadow: 0 1px 2px rgba(16,24,40,.06); }
button:active, .btn:active { transform: translateY(1px); }
.btn-light, .btn-outline, .btn-icon { box-shadow: none; }
button:focus-visible, .btn:focus-visible, a.btn:focus-visible {
    outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.32);
}

/* Badges: pill with a hairline for crisper definition */
.badge { padding: .28rem .66rem; box-shadow: inset 0 0 0 1px rgba(16,24,40,.05); }

/* Refined thin scrollbars within the content area */
.main-content ::-webkit-scrollbar { width: 10px; height: 10px; }
.main-content ::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
.main-content ::-webkit-scrollbar-thumb:hover { background: #94A3B8; background-clip: padding-box; }

/* Topbar: cleaner divider + firmer title */
.topbar { border-bottom: 1px solid #E8ECF3; box-shadow: 0 1px 2px rgba(16,24,40,.03); }
.topbar-title { font-weight: 700; letter-spacing: -.01em; color: #0F172A; }

/* ============================================================
   UI Polish v3 (Jul 2026) — chrome & micro-interactions.
   Appended last; delete this block to revert.
   ============================================================ */

/* Gentle page entrance (respects reduced-motion) */
@media (prefers-reduced-motion: no-preference) {
    .page-content { animation: hrmsFadeUp .26s cubic-bezier(.4,0,.2,1) both; }
    @keyframes hrmsFadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* Auto-styled content sections match the refreshed card surface */
.page-content > section {
    border-color: #E8ECF3;
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.03);
}

/* Flash / alerts — accent bar + softer premium look */
article[role="alert"], article[role="status"] {
    border-left-width: 4px;
    border-radius: 12px;
    box-shadow: 0 1px 2px rgba(16,24,40,.05);
    font-weight: 500;
}

/* Topbar: gradient avatar, hoverable user row, deeper dropdown */
.topbar-avatar { background: linear-gradient(135deg, var(--primary-light), var(--primary-dark)); box-shadow: 0 2px 6px rgba(59,130,246,.35); }
.topbar-user { padding: .3rem .5rem; border-radius: 10px; transition: background .15s ease; cursor: pointer; }
.topbar-user:hover { background: var(--gray-100); }
.user-dropdown { border-radius: 12px; box-shadow: 0 16px 40px -12px rgba(16,24,40,.28); }

/* Empty state as a soft dashed card */
.empty-state { border: 1px dashed #D8E0EC; border-radius: 14px; background: #FBFCFE; }

/* Accessible focus ring for content links */
.page-content a:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,.30); border-radius: 4px; }

/* ============================================================
   UI Polish v4 (Jul 2026) — form controls & states.
   Appended last; delete this block to revert.
   ============================================================ */

/* Disabled controls read clearly as disabled */
button:disabled, .btn:disabled, button[disabled], .btn.disabled {
    opacity: .55; cursor: not-allowed; box-shadow: none; pointer-events: none;
}
input:disabled, select:disabled, textarea:disabled {
    background: #F1F5F9 !important; color: #94A3B8; cursor: not-allowed;
}

/* Consistent custom chevron on single selects across browsers */
select:not([multiple]):not([size]) {
    -webkit-appearance: none; -moz-appearance: none; appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat; background-position: right .8rem center; background-size: 15px;
    padding-right: 2.3rem !important;
}

/* Refined rule + code blocks inside content */
.page-content hr { border: none; border-top: 1px solid #E8ECF3; margin: 1.25rem 0; }
.page-content code { background: #F1F5F9; color: #0F172A; padding: .12rem .4rem; border-radius: 6px; font-size: .85em; }
.page-content pre { background: #0F172A; color: #E2E8F0; padding: 1rem 1.25rem; border-radius: 12px; overflow-x: auto; font-size: .85rem; line-height: 1.5; }

/* ============================================================
   UI Polish v5 (Jul 2026) — app-wide centered content column.
   Every page's cards / forms / sections / tables sit in ONE centred
   column so nothing is left-aligned. Add class "full-width" (or
   "full-bleed") to a direct child of .page-content to opt a block out.
   ============================================================ */
.page-content > * { margin-left: auto !important; margin-right: auto !important; max-width: 900px; }
.page-content > form { max-width: 640px; }
/* A page that contains a table is a full-width (list) page: its filters, headers
   and the table all span the width and line up. Form/card-only pages stay centred. */
.page-content:has(table) > * { max-width: none; }
/* ...but keep add/edit forms (and form-only wrappers) narrow & left-aligned with the table. */
.page-content:has(table) > form,
.page-content:has(table) > *:has(form):not(:has(table)) {
    max-width: 640px;
    margin-left: 0 !important;
    margin-right: auto !important;
}
/* A form that WRAPS a table is an editable grid (e.g. the weekly timesheet) — centre it at 900.
   A data LIST with inline action forms inside its cells is table>form (NOT form>table), so it is
   NOT matched here and stays full-width — fixes clipping on Trial Management and similar tables. */
.page-content:has(form table) > * {
    max-width: 900px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}
/* Explicit opt-out — always wins over the centering rules above. */
.page-content > .full-width,
.page-content > .full-bleed,
.page-content:has(table) > .full-width,
.page-content:has(table) > .full-bleed,
.page-content:has(form table) > .full-width,
.page-content:has(form table) > .full-bleed {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}
