/* ═══════════════════════════════════════════════════════════════════════════
   LT Identity — theme
   Green/white palette shared with LivingTree HRM (source of truth for the hue
   values: the HRM frontend's globals.css oklch tokens, converted to hex).
   One sheet owns every token; legacy variable names used by older views are
   aliased at the bottom of :root so nothing renders unstyled mid-migration.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    /* Brand (from LT HRM) */
    --lt-green: #1b6241;
    --lt-green-dark: #124a30;
    --lt-green-lemon: #15b81a;
    --lt-mint: #14f59b;

    /* Greys, biased slightly warm-green like the HRM background */
    --bg: #f9f9f9;
    --surface: #ffffff;
    --surface-2: #f2f6f4;
    --surface-3: #e9efec;
    --border: #e5e5e5;
    --border-mid: #d6d6d6;

    --text-1: #17201b;
    --text-2: #45514a;
    --text-3: #6f7d75;
    --text-4: #a4aca7;

    /* Accent = brand green, with tints for backgrounds and borders */
    --accent: var(--lt-green);
    --accent-hover: var(--lt-green-dark);
    --accent-dim: #e7f1ec;
    --accent-bdr: #bcd9cb;

    /* Semantic */
    --danger: #b90202;
    --danger-dim: #fbeaea;
    --danger-bdr: #efc4c4;
    --success: #1b7d43;
    --success-dim: #e4f4ea;
    --warn: #9a6a10;
    --warn-dim: #fcf3e0;
    --warn-bdr: #ecd9ae;

    /* Type — Rubik, same as LT HRM */
    --font-body: 'Rubik', -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Rubik', -apple-system, 'Segoe UI', sans-serif;

    /* Nav (light, white on green-tinted white) */
    --nav-height: 58px;
    --nav-bg: #ffffff;
    --nav-border: var(--border);
    --nav-text: var(--text-2);
    --nav-text-muted: var(--text-3);
    --nav-hover-bg: var(--surface-2);
    --nav-active-bg: var(--accent-dim);
    --nav-active-text: var(--accent);

    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(23, 32, 27, 0.05);
    --shadow-md: 0 8px 28px rgba(23, 32, 27, 0.12);

    /* ── Legacy aliases (older inline styles still reference these) ── */
    --page-bg: var(--bg);
    --bg-2: var(--surface-2);
    --text-primary: var(--text-1);
    --text-secondary: var(--text-3);
    --text-muted: var(--text-4);
    --fd: var(--font-display);
    --fb: var(--font-body);
    --nav-h: var(--nav-height);
    --danger-color: var(--danger);
    --danger-subtle: var(--danger-dim);
    --success-color: var(--success);
    --accent-warm: var(--lt-green-lemon);
    --accent-subtle: var(--accent-dim);
    --accent-border: var(--accent-bdr);
    --border-hover: var(--accent-bdr);
    --border-focus: var(--accent);
    --purple: var(--lt-green);
}

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-1);
    margin: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Slim scrollbar, mint thumb — matches the HRM sidebar treatment. */
.scrollbar-slim {
    scrollbar-width: thin;
    scrollbar-color: #d0eadc transparent;
}
.scrollbar-slim::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar-slim::-webkit-scrollbar-track { background: transparent; }
.scrollbar-slim::-webkit-scrollbar-thumb { background: #d0eadc; border-radius: 3px; }
.scrollbar-slim::-webkit-scrollbar-thumb:hover { background: #a1d5bb; }

/* ═══ TOP NAV ═══ */

body.with-topnav { padding-top: var(--nav-height); }

.topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-height);
    background: var(--nav-bg);
    border-bottom: 1px solid var(--nav-border);
    display: flex;
    align-items: center;
    z-index: 1000;
    padding: 0 1.25rem;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 1.25rem;
    min-width: 0;
}
.nav-brand:hover { text-decoration: none; }

.nav-brand-icon {
    width: 32px; height: 32px;
    background: var(--lt-green);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: #fff;
    letter-spacing: 0.02em;
    flex-shrink: 0;
    overflow: hidden;
}
.nav-brand-icon img { width: 100%; height: 100%; object-fit: contain; }
/* The LivingTree mark is green-on-transparent — on the solid green tile it would
   disappear, so a tile that holds a real logo goes white. */
.nav-brand-icon:has(img) { background: #ffffff; border: 1px solid var(--border); padding: 2px; }

.nav-brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.nav-brand-name {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text-1);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-brand-product {
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--accent);
}

.nav-divider { width: 1px; height: 24px; background: var(--border); margin: 0 0.75rem; flex-shrink: 0; }

.nav-items { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }

.nav-link-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border-radius: 8px;
    color: var(--nav-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 400;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.nav-link-item svg { width: 15px; height: 15px; opacity: 0.75; flex-shrink: 0; }
.nav-link-item:hover { background: var(--nav-hover-bg); color: var(--text-1); text-decoration: none; }
.nav-link-item.active { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 500; }
.nav-link-item.active svg { opacity: 1; }

.admin-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-4);
    padding: 0 8px;
}

.nav-right { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }

.nav-launcher-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 12px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-2);
    font-size: 13.5px;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
}
.nav-launcher-btn svg { width: 15px; height: 15px; opacity: 0.8; }
.nav-launcher-btn:hover { background: var(--accent-dim); border-color: var(--accent-bdr); color: var(--accent); text-decoration: none; }

/* Profile dropdown */
.profile-dropdown { position: relative; }
.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px 4px 10px;
    border-radius: 9px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-2);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 13.5px;
    transition: background 0.15s, border-color 0.15s;
}
.profile-btn:hover { background: var(--nav-hover-bg); border-color: var(--border); }

.profile-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--lt-green);
    display: flex; align-items: center; justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-chevron { width: 14px; height: 14px; opacity: 0.5; transition: transform 0.2s; }
.profile-dropdown.open .profile-chevron { transform: rotate(180deg); }

.dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px;
    display: none;
    box-shadow: var(--shadow-md);
    z-index: 200;
}
.profile-dropdown.open .dropdown-panel { display: block; }

.dp-header { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.dp-name { font-weight: 500; font-size: 13.5px; color: var(--text-1); }
.dp-email { font-size: 12px; color: var(--text-3); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; }

.dp-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--text-2);
    font-size: 13.5px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.1s;
    border: none;
    background: none;
    width: 100%;
    font-family: var(--font-body);
    text-align: left;
}
.dp-item svg { width: 15px; height: 15px; opacity: 0.65; flex-shrink: 0; }
.dp-item:hover { background: var(--nav-hover-bg); color: var(--text-1); text-decoration: none; }
.dp-item.danger { color: var(--danger); }
.dp-item.danger:hover { background: var(--danger-dim); }

.dp-sep { height: 1px; background: var(--border); margin: 5px 0; }

/* App Launcher (sheet from top) */
.launcher-overlay {
    position: fixed;
    inset: 0;
    background: rgba(23, 32, 27, 0.35);
    z-index: 900;
    display: none;
    cursor: pointer;
}
.launcher-panel {
    position: fixed;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    z-index: 901;
    display: none;
    padding: 1.5rem;
    max-height: calc(100vh - var(--nav-height));
    overflow-y: auto;
}
.launcher-overlay.open, .launcher-panel.open { display: block; }

.launcher-title {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
    margin-bottom: 1rem;
}
.launcher-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    max-width: 760px;
}
.launcher-app {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 9px;
    padding: 1rem 0.75rem;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-1);
    transition: background 0.15s, border-color 0.15s, transform 0.1s, box-shadow 0.15s;
    text-align: center;
}
.launcher-app:hover {
    background: var(--accent-dim);
    border-color: var(--accent-bdr);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--text-1);
}
.launcher-app-icon {
    width: 42px; height: 42px;
    border-radius: 10px;
    background: var(--lt-green);
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.launcher-app-name { font-size: 12.5px; font-weight: 500; line-height: 1.3; }
.launcher-app-desc { font-size: 11px; color: var(--text-3); line-height: 1.3; }

.page-content { min-height: calc(100vh - var(--nav-height)); }

/* ═══ AUTH LAYOUT (sign-in and friends) ═══ */

.auth-body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(1200px 500px at 50% -10%, var(--accent-dim) 0%, transparent 60%),
        var(--bg);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.5rem;
    text-decoration: none;
}
.auth-brand:hover { text-decoration: none; }
.auth-brand-icon {
    width: 52px; height: 52px;
    background: var(--lt-green);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 20px;
    color: #fff;
    overflow: hidden;
}
.auth-brand-icon img { width: 100%; height: 100%; object-fit: contain; }
.auth-brand-icon:has(img) { background: #ffffff; border: 1px solid var(--border); padding: 4px; }
/* Medium weight + a touch of tracking: Rubik's SemiBold gets cramped and its bar-shaped
   capital I makes a bold "LT Identity" read ambiguously ("ldentity"); the lighter, more
   open setting keeps it legible. */
.auth-brand-name { font-size: 19px; font-weight: 500; letter-spacing: 0.01em; color: var(--text-1); text-align: center; }
.auth-brand-product {
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-3);
    text-align: center;
    margin-top: 3px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.75rem;
}
.auth-card-wide { max-width: 560px; }

.auth-title { font-size: 19px; font-weight: 600; color: var(--text-1); margin: 0 0 4px; }
.auth-subtitle { font-size: 13.5px; color: var(--text-3); margin: 0 0 1.25rem; }

.auth-footer {
    margin-top: 1.5rem;
    font-size: 12.5px;
    color: var(--text-4);
    text-align: center;
}
.auth-footer a { color: var(--text-3); }

/* ═══ RESPONSIVE ═══ */

@media (max-width: 768px) {
    .admin-label, .nav-link-item span { display: none; }
    .nav-link-item { padding: 7px 9px; }
    .nav-brand-product { display: none; }
    .profile-btn .profile-name { display: none; }
    .topnav { padding: 0 0.75rem; }
    .launcher-panel { padding: 1rem; }
}

@media (max-width: 480px) {
    .nav-brand-name { max-width: 120px; }
    .auth-card { padding: 1.25rem; }
}
