/* PayrollShare — Design System */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --font: 'Inter', system-ui, -apple-system, sans-serif;

    --sidebar-w: 260px;
    --header-h: 60px;

    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    --slate-950: #020617;

    --teal-50: #f0fdfa;
    --teal-100: #ccfbf1;
    --teal-500: #14b8a6;
    --teal-600: #0d9488;
    --teal-700: #0f766e;

    --green-50: #f0fdf4;
    --green-600: #16a34a;
    --green-700: #15803d;

    --amber-50: #fffbeb;
    --amber-600: #d97706;

    --red-50: #fef2f2;
    --red-600: #dc2626;

    --blue-50: #eff6ff;
    --blue-600: #2563eb;

    --bg: var(--slate-100);
    --surface: #ffffff;
    --ink: var(--slate-900);
    --muted: var(--slate-500);
    --border: var(--slate-200);
    --brand: var(--teal-600);
    --brand-dark: var(--teal-700);
    --sidebar-bg: var(--slate-900);
    --sidebar-text: var(--slate-300);
    --sidebar-active: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

img, svg { display: block; max-width: 100%; }

/* ─── App Shell ─── */

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

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.55);
    z-index: 40;
    opacity: 0;
    transition: opacity var(--transition);
}

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

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar.is-open { transform: translateX(0); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--teal-500), var(--teal-700));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand-icon svg { width: 20px; height: 20px; color: #fff; }

.sidebar-brand-text {
    font-weight: 700;
    font-size: 1.05rem;
    color: #fff;
    letter-spacing: -0.02em;
}

.sidebar-brand-text small {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--slate-400);
    letter-spacing: 0;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 14px 10px;
}

.nav-section-label {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--slate-500);
    padding: 8px 12px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--slate-300);
    font-weight: 500;
    font-size: 0.875rem;
    transition: background var(--transition), color var(--transition);
    margin-bottom: 2px;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.75;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.nav-link.is-active {
    background: var(--sidebar-active);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--teal-500);
}

.nav-link.is-active svg { opacity: 1; color: var(--teal-500); }

.sidebar-footer {
    padding: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-locale {
    padding: 0 14px 12px;
}

.locale-switcher {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.locale-switcher-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.55);
}

.locale-select {
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: var(--radius-sm);
}

.login-card .locale-switcher {
    margin-bottom: 16px;
}

.login-card .locale-switcher-label {
    color: var(--slate-500);
}

.login-card .locale-select {
    background: var(--surface);
    color: var(--slate-800);
    border-color: var(--slate-200);
}

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    margin-bottom: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--teal-600), var(--slate-700));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    flex-shrink: 0;
}

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

.user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: var(--slate-400);
    text-transform: capitalize;
}

.btn-logout {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--slate-300);
    font-family: var(--font);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.btn-logout svg { width: 16px; height: 16px; }

/* ─── Main Content ─── */

.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.top-header {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--header-h);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 20px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    color: var(--slate-700);
    transition: background var(--transition);
}

.menu-toggle:hover { background: var(--slate-50); }
.menu-toggle svg { width: 20px; height: 20px; }

.page-title-bar {
    flex: 1;
    min-width: 0;
}

.page-title-bar h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.page-title-bar p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--muted);
}

.main-content {
    flex: 1;
    padding: 20px;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
}

/* ─── Cards & Layout ─── */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: 16px; }

.page-header { margin-bottom: 20px; }

.page-header h1 {
    margin: 0 0 4px;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.page-header p {
    margin: 0;
    color: var(--muted);
    font-size: 0.875rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 4px;
}

.stack { display: grid; gap: 14px; }

.mb-16 { margin-bottom: 16px; }

/* ─── KPI Cards ─── */

.kpi {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    padding: 18px 18px 18px 20px;
    overflow: hidden;
    transition: box-shadow var(--transition), transform var(--transition);
}

.kpi::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(180deg, var(--teal-500), var(--teal-700));
    border-radius: 4px 0 0 4px;
}

.kpi:hover {
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.kpi-label {
    color: var(--muted);
    display: block;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.03em;
    line-height: 1.2;
    word-break: break-word;
}

.kpi-value.kpi-sm {
    font-size: 0.9375rem;
    font-weight: 600;
    letter-spacing: 0;
}

/* ─── Buttons ─── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    padding: 10px 18px;
    cursor: pointer;
    font-family: var(--font);
    font-size: 0.875rem;
    font-weight: 600;
    transition: background var(--transition), transform 0.1s ease;
    white-space: nowrap;
}

.btn:hover {
    background: var(--brand-dark);
    color: #fff;
}

.btn:active { transform: scale(0.98); }

.btn-secondary {
    background: var(--surface);
    color: var(--slate-700);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--slate-50);
    color: var(--ink);
}

.btn-danger {
    background: var(--red-600);
}

.btn-danger:hover { background: #b91c1c; }

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--brand);
    font-weight: 600;
    font-size: 0.875rem;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: var(--font);
}

.btn-link:hover { color: var(--brand-dark); text-decoration: underline; }

.btn-link-danger { color: var(--red-600); }
.btn-link-danger:hover { color: #b91c1c; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding-top: 4px;
}

.card-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

/* ─── Forms ─── */

.field { display: block; }

.field-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--slate-700);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: var(--font);
    font-size: 0.875rem;
    color: var(--ink);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.input::placeholder,
.textarea::placeholder { color: var(--slate-400); }

.textarea { resize: vertical; min-height: 100px; }

.field-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--slate-700);
}

.field-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
}

.field-hint {
    font-size: 0.75rem;
    color: var(--muted);
    margin-top: 4px;
}

.file-input {
    font-size: 0.875rem;
    color: var(--slate-600);
}

.import-panel {
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 18px;
    background: var(--slate-50);
    margin-bottom: 20px;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

/* ─── Alerts ─── */

.alert {
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
}

.alert-success {
    border: 1px solid #bbf7d0;
    background: var(--green-50);
    color: var(--green-700);
}

.alert-error {
    border: 1px solid #fecaca;
    background: var(--red-50);
    color: var(--red-600);
}

/* ─── Badges ─── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-neutral { background: var(--slate-200); color: var(--slate-700); }
.badge-success { background: #dcfce7; color: var(--green-700); }
.badge-warning { background: #fef9c3; color: var(--amber-600); }
.badge-danger { background: #fee2e2; color: var(--red-600); }
.badge-info { background: var(--blue-50); color: var(--blue-600); }

/* ─── Tables ─── */

.ui-table-wrap {
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    -webkit-overflow-scrolling: touch;
}

.ui-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 640px;
    background: var(--surface);
    font-size: 0.875rem;
}

.ui-table thead { background: var(--slate-50); }

.ui-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--slate-500);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.ui-table td {
    text-align: left;
    padding: 12px 14px;
    border-top: 1px solid var(--slate-100);
    vertical-align: middle;
    color: var(--slate-700);
}

.ui-table tbody tr:hover { background: var(--slate-50); }

.actions-cell {
    white-space: nowrap;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 24px !important;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.pagination-link {
    color: var(--brand);
    font-weight: 600;
    font-size: 0.875rem;
}

.pagination-link.is-disabled {
    color: var(--muted);
    pointer-events: none;
}

.pagination-info {
    font-size: 0.8125rem;
    color: var(--muted);
}

.nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--red-600);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.filter-bar .field { min-width: 160px; }

/* ─── Messages / Tickets ─── */

.message-bubble {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--slate-50);
}

.message-author {
    font-weight: 600;
    font-size: 0.8125rem;
    margin-bottom: 4px;
    color: var(--ink);
}

.message-body {
    color: var(--slate-600);
    font-size: 0.875rem;
}

.status-row {
    color: var(--muted);
    font-size: 0.875rem;
    margin-top: -8px;
}

/* ─── Guest / Login Layout ─── */

.guest-body {
    min-height: 100vh;
    display: flex;
    background: var(--slate-900);
}

.guest-panel {
    display: none;
    flex: 1;
    position: relative;
    overflow: hidden;
    background: linear-gradient(145deg, var(--slate-900) 0%, #134e4a 100%);
}

.guest-panel-inner {
    position: relative;
    z-index: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 48px;
    color: #fff;
}

.guest-panel h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 0 0 12px;
    line-height: 1.2;
}

.guest-panel p {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.75);
    max-width: 400px;
    margin: 0 0 32px;
    line-height: 1.6;
}

.guest-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 14px;
}

.guest-features li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.85);
}

.guest-features svg {
    width: 20px;
    height: 20px;
    color: var(--teal-500);
    flex-shrink: 0;
}

.guest-panel-bg {
    position: absolute;
    inset: 0;
    opacity: 0.15;
    background:
        radial-gradient(circle at 20% 80%, var(--teal-500) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, #6366f1 0%, transparent 40%);
}

.guest-form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-brand-mobile {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
}

.login-brand-mobile .sidebar-brand-icon { width: 40px; height: 40px; }

.login-brand-mobile span {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--ink);
}

.demo-accounts {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.demo-accounts-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 10px;
}

.demo-account {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--slate-50);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 0.8125rem;
}

.demo-account code {
    font-family: ui-monospace, monospace;
    font-size: 0.75rem;
    color: var(--slate-600);
}

.demo-account span {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--teal-700);
    background: var(--teal-50);
    padding: 2px 8px;
    border-radius: 999px;
}

/* ─── Responsive ─── */

@media (min-width: 1024px) {
    .sidebar {
        transform: translateX(0);
        position: sticky;
    }

    .sidebar-overlay { display: none !important; }

    .menu-toggle { display: none; }

    .main-wrapper { margin-left: 0; }

    .guest-panel { display: flex; }

    .guest-form-side {
        flex: 0 0 480px;
        max-width: 480px;
    }
}

@media (max-width: 1023px) {
    .main-content { padding: 16px; }

    .card { padding: 18px; }

    .page-header h1 { font-size: 1.2rem; }

    .grid { grid-template-columns: 1fr 1fr; gap: 12px; }

    .kpi-value { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .grid { grid-template-columns: 1fr; }

    .top-header { padding: 0 14px; }

    .form-actions { flex-direction: column; align-items: stretch; }

    .form-actions .btn { width: 100%; }

    .inline-form { flex-direction: column; align-items: stretch; }

    .inline-form .select,
    .inline-form .btn { width: 100%; }
}
