@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --nav-dark: #0f2744;
    --nav-mid: #1e3a5f;
    --accent: #06b6d4;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 16px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body.hrm-app {
    font-family: 'Inter', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    padding-top: 0;
    min-height: 100vh;
}

:root {
    --sidebar-width: 260px;
    --topbar-height: 56px;
}

/* ── Sidebar layout ── */
body.hrm-has-sidebar {
    padding-left: var(--sidebar-width);
}
body.hrm-has-sidebar .hrm-main {
    padding-top: calc(var(--topbar-height) + 28px);
    min-height: calc(100vh - var(--topbar-height));
}
body.hrm-has-sidebar .hrm-container {
    max-width: 1280px;
}

.hrm-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--nav-mid) 0%, var(--nav-dark) 100%);
    color: #fff;
    z-index: 1040;
    overflow-y: auto;
    box-shadow: 2px 0 20px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
}
.hrm-sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}
.hrm-sidebar-brand a {
    font-weight: 700;
    font-size: 1.45rem;
    color: #fff !important;
    text-decoration: none;
    letter-spacing: -0.03em;
}
.hrm-sidebar-brand a span { color: var(--accent); }

.hrm-sidebar-search {
    position: relative;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}
.hrm-sidebar-search-icon {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.45);
    pointer-events: none;
    font-size: 12px;
    z-index: 1;
}
.hrm-sidebar-search-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #fff;
    padding-left: 32px;
    height: 36px;
    font-size: 13px;
    box-shadow: none;
}
.hrm-sidebar-search-input::placeholder {
    color: rgba(255, 255, 255, 0.45);
}
.hrm-sidebar-search-input:focus {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: #fff;
    box-shadow: none;
    outline: none;
}

.hrm-sidebar-nav {
    padding: 12px 0 24px;
    flex: 1;
}
.hrm-nav-group { margin-bottom: 8px; }
.hrm-nav-group-title {
    padding: 14px 20px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.45);
}
.hrm-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.hrm-nav-list > li > a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255, 255, 255, 0.82) !important;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
}
.hrm-nav-list > li > a .glyphicon {
    font-size: 14px;
    width: 18px;
    text-align: center;
    opacity: 0.85;
}
.hrm-nav-list > li > a:hover,
.hrm-nav-list > li > a:focus {
    background: rgba(255, 255, 255, 0.1);
    color: #fff !important;
    text-decoration: none;
}
.hrm-nav-list > li.active > a {
    background: rgba(255, 255, 255, 0.14);
    color: #fff !important;
    border-left-color: var(--accent);
    font-weight: 600;
}
.hrm-nav-group.hrm-nav-hidden,
.hrm-nav-list > li.hrm-nav-hidden {
    display: none !important;
}
.hrm-sidebar-search-empty {
    display: none;
    padding: 8px 20px 16px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}
.hrm-sidebar-search-empty.is-visible {
    display: block;
}

.hrm-topbar {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    z-index: 1030;
    box-shadow: 0 1px 8px rgba(15, 23, 42, 0.06);
}
.hrm-sidebar-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
}
.hrm-sidebar-toggle .icon-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    margin: 3px 0;
    border-radius: 1px;
}
.hrm-topbar-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hrm-topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}
.hrm-topbar-user {
    font-size: 13px;
    color: var(--text-muted);
}
.hrm-topbar-link {
    font-size: 13px;
    font-weight: 500;
    color: var(--primary) !important;
    text-decoration: none;
}
.hrm-topbar-link:hover { text-decoration: underline; }
.hrm-logout-form { display: inline; margin: 0; }

.hrm-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 1035;
}

@media (max-width: 991px) {
    body.hrm-has-sidebar { padding-left: 0; }
    .hrm-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    body.hrm-sidebar-open .hrm-sidebar {
        transform: translateX(0);
    }
    body.hrm-sidebar-open .hrm-sidebar-backdrop {
        display: block;
    }
    .hrm-topbar {
        left: 0;
        padding: 0 16px;
    }
    .hrm-sidebar-toggle { display: block; }
    .hrm-topbar-user { display: none; }
}

@media (max-width: 575px) {
    .hrm-topbar-actions .hrm-topbar-link:not(:last-child) { display: none; }
}

/* ── Legacy navbar (login page unused) ── */
.hrm-navbar {
    background: linear-gradient(135deg, var(--nav-mid) 0%, var(--nav-dark) 100%);
    border: none;
    border-radius: 0;
    margin-bottom: 0;
    min-height: 56px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.2);
}
.hrm-navbar .navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    color: #fff !important;
    letter-spacing: -0.03em;
    padding: 16px 15px;
}
.hrm-navbar .navbar-brand span { color: var(--accent); }
.hrm-navbar .navbar-toggle { border-color: rgba(255,255,255,0.3); margin-top: 11px; }
.hrm-navbar .navbar-toggle .icon-bar { background-color: #fff; }
.hrm-navbar .nav > li > a {
    color: rgba(255, 255, 255, 0.88) !important;
    font-weight: 500;
    font-size: 13px;
    padding: 18px 11px;
    transition: background 0.15s, color 0.15s;
}
.hrm-navbar .nav > li > a:hover,
.hrm-navbar .nav > li > a:focus {
    background: rgba(255, 255, 255, 0.12) !important;
    color: #fff !important;
}
.hrm-navbar .navbar-text {
    color: rgba(255, 255, 255, 0.75) !important;
    padding: 18px 12px;
    font-size: 13px;
}
.hrm-navbar .navbar-right > li > a {
    color: rgba(255, 255, 255, 0.88) !important;
    padding: 18px 14px;
}

/* ── Layout ── */
.hrm-main { padding: 28px 0 40px; }
body.hrm-has-sidebar .hrm-footer {
    margin-left: 0;
}
.hrm-container { max-width: 1140px; }

/* ── Page header ── */
.page-header-bar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}
.page-header-bar h1 {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.page-header-bar .subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 6px;
    font-weight: 400;
}

/* ── Cards ── */
.hrm-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
    overflow: hidden;
}
.hrm-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 14px;
    background: #f8fafc;
    color: var(--text);
}
.hrm-card-body { padding: 20px; }

/* ── Tables ── */
.hrm-table { margin-bottom: 0; background: #fff; }
.hrm-table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border) !important;
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 13px 16px !important;
    white-space: nowrap;
}
.hrm-table tbody td {
    padding: 14px 16px !important;
    vertical-align: middle !important;
    border-color: var(--border) !important;
    font-size: 14px;
}
.hrm-table tbody tr:hover { background: #f8fafc; }
.hrm-table code {
    background: #f1f5f9;
    color: var(--primary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

/* ── Buttons ── */
.btn-hrm-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff !important;
    font-weight: 600;
    border-radius: 8px;
    padding: 9px 18px;
    font-size: 13px;
    transition: background 0.15s, transform 0.1s;
}
.btn-hrm-primary:hover,
.btn-hrm-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff !important;
    transform: translateY(-1px);
}
.btn-action {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: 6px;
    margin-right: 4px;
}

/* ── Labels ── */
.label { border-radius: 20px; font-weight: 600; padding: 4px 10px; font-size: 11px; }

/* ── Alerts ── */
.alert {
    border-radius: var(--radius);
    border: none;
    font-size: 14px;
    box-shadow: var(--shadow);
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger { background: #fee2e2; color: #991b1b; }

/* ── Dashboard hero ── */
.dashboard-hero {
    background: linear-gradient(135deg, var(--nav-mid) 0%, var(--primary) 100%);
    color: #fff;
    border-radius: var(--radius);
    padding: 36px 40px;
    margin-bottom: 28px;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.25);
}
.dashboard-hero h1 {
    font-size: 2.1rem;
    font-weight: 700;
    margin: 0 0 10px;
    letter-spacing: -0.03em;
}
.dashboard-hero p {
    opacity: 0.92;
    margin: 0;
    font-size: 16px;
    font-weight: 400;
}

/* ── Stat cards (dashboard grid) ── */
.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px 24px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
}
.dashboard-stat-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    position: relative;
    z-index: 2;
}
.dashboard-stat-link:hover,
.dashboard-stat-link:focus {
    text-decoration: none;
    color: inherit;
    outline: none;
}
.dashboard-stat-link .stat-card {
    height: 100%;
    margin: 0;
}
.dashboard-stat-col {
    position: relative;
    z-index: 1;
}
.stat-card-link {
    display: flex;
    text-decoration: none;
    color: inherit;
}
.stat-card-link:hover,
.stat-card-link:focus {
    text-decoration: none;
    color: inherit;
}
.stat-card .icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-size: 1.5rem;
}
.stat-card .icon-wrap.blue { background: #dbeafe; color: #2563eb; }
.stat-card .icon-wrap.green { background: #d1fae5; color: #059669; }
.stat-card .icon-wrap.cyan { background: #cffafe; color: #0891b2; }
.stat-card .icon-wrap.amber { background: #fef3c7; color: #d97706; }
.stat-card .icon-wrap.red { background: #fee2e2; color: #dc2626; }
.stat-card .icon-wrap.indigo { background: #e0e7ff; color: #4f46e5; }
.stat-card .icon-wrap .glyphicon {
    font-size: 1.5rem;
    line-height: 1;
}
.stat-card h4 {
    font-weight: 700;
    margin: 0 0 8px;
    font-size: 16px;
    color: var(--text);
}
.stat-card p {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 18px;
    flex-grow: 1;
    line-height: 1.5;
}
.stat-card .btn-hrm-primary { width: 100%; }

.dashboard-grid { margin-left: -10px; margin-right: -10px; }
.dashboard-grid > [class*="col-"] { padding-left: 10px; padding-right: 10px; margin-bottom: 20px; }

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--nav-mid) 0%, var(--nav-dark) 45%, #1e40af 100%);
}
.login-box {
    background: #fff;
    border-radius: 16px;
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}
.login-box .brand {
    font-weight: 700;
    font-size: 1.6rem;
    margin-bottom: 28px;
    color: var(--text);
}
.login-box .brand span { color: var(--accent); }
.login-box h2 { font-weight: 700; margin: 0 0 6px; font-size: 1.4rem; }

/* ── Forms ── */
.form-control {
    border-radius: 8px;
    border: 1px solid var(--border);
    box-shadow: none;
    height: 42px;
    font-size: 14px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
textarea.form-control { height: auto; }
.form-group label { font-weight: 500; font-size: 13px; color: var(--text); }

/* ── Footer ── */
.hrm-footer {
    text-align: center;
    padding: 22px;
    color: var(--text-muted);
    font-size: 13px;
    background: #fff;
    border-top: 1px solid var(--border);
}

/* ── Misc ── */
.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state .glyphicon { font-size: 3rem; margin-bottom: 16px; opacity: 0.35; display: block; }

.checkin-card {
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 1px solid #a7f3d0;
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.hrm-table-search-bar {
    position: relative;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #fafbfc;
}
.hrm-table-search-icon {
    position: absolute;
    left: 26px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.hrm-table-search-input {
    padding-left: 32px;
    max-width: 320px;
}

.hrm-ai-chat-log {
    min-height: 200px;
    max-height: 420px;
    overflow-y: auto;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid var(--border);
}
.hrm-ai-messages-page {
    min-height: 360px;
    max-height: 520px;
}
.hrm-ai-msg {
    display: flex;
    margin-bottom: 10px;
}
.hrm-ai-msg-user {
    justify-content: flex-end;
}
.hrm-ai-msg-assistant {
    justify-content: flex-start;
}
.hrm-ai-bubble {
    max-width: 92%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}
.hrm-ai-msg-user .hrm-ai-bubble {
    background: linear-gradient(135deg, #1a8cff 0%, #0d6efd 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.hrm-ai-msg-assistant .hrm-ai-bubble {
    background: #fff;
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}
.hrm-ai-bubble ul {
    margin: 6px 0 0;
    padding-left: 18px;
}
.hrm-ai-bubble p:last-child,
.hrm-ai-bubble ul:last-child {
    margin-bottom: 0;
}
.hrm-ai-mini-table {
    margin: 8px 0 0;
    font-size: 12px;
    background: #fff;
}
.hrm-ai-links {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.hrm-ai-link-btn {
    border-radius: 14px !important;
}
.hrm-ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 12px 8px;
    min-height: 0;
}
.hrm-ai-messages-page + .hrm-ai-chips,
#hrmAiChat .hrm-ai-chips {
    padding: 8px 0 0;
}
.hrm-ai-chip {
    border: 1px solid #cfe2ff;
    background: #e7f1ff;
    color: #0d6efd;
    border-radius: 16px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.hrm-ai-chip:hover {
    background: #cfe2ff;
}
.hrm-ai-typing {
    font-size: 12px;
    color: var(--text-muted);
    padding: 0 12px 6px;
    font-style: italic;
}
.hrm-ai-msg-typing .hrm-ai-bubble {
    padding: 14px 18px;
    min-width: 52px;
}
.hrm-ai-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 10px;
}
.hrm-ai-dots span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6c757d;
    animation: hrmAiDotBounce 1.2s ease-in-out infinite;
}
.hrm-ai-dots span:nth-child(2) { animation-delay: 0.15s; }
.hrm-ai-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes hrmAiDotBounce {
    0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}
.hrm-ai-bubble.hrm-ai-fade-in {
    animation: hrmAiFadeIn 0.35s ease-out;
}
@keyframes hrmAiFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.hrm-ai-widget-header-title {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}
.hrm-ai-widget-sub {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.9;
}

/* Floating AI assistant */
.hrm-ai-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9999;
    font-size: 14px;
}
.hrm-ai-widget-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1a8cff 0%, #0d6efd 100%);
    color: #fff;
    font-size: 22px;
    box-shadow: 0 4px 16px rgba(13, 110, 253, 0.45);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.hrm-ai-widget-btn:hover,
.hrm-ai-widget-btn:focus {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.55);
    color: #fff;
    outline: none;
}
.hrm-ai-widget-btn-active {
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
}
.hrm-ai-widget-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 68px;
    width: 340px;
    max-width: calc(100vw - 40px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    border: 1px solid var(--border);
    overflow: hidden;
}
.hrm-ai-widget-open {
    display: block;
    animation: hrmAiSlideUp 0.25s ease-out;
}
@keyframes hrmAiSlideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}
.hrm-ai-widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: linear-gradient(135deg, #1a8cff 0%, #0d6efd 100%);
    color: #fff;
    font-weight: 600;
}
.hrm-ai-widget-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    opacity: 0.9;
    cursor: pointer;
    padding: 0 4px;
}
.hrm-ai-widget-close:hover { opacity: 1; }
.hrm-ai-widget-panel .hrm-ai-chat-log {
    min-height: 160px;
    max-height: 260px;
    margin: 12px;
    border-radius: 8px;
}
.hrm-ai-widget-form {
    padding: 0 12px 8px;
}
.hrm-ai-widget-foot {
    margin: 0;
    padding: 6px 12px 12px;
    text-align: center;
    font-size: 12px;
}
.hrm-ai-widget-foot a { color: var(--primary, #0d6efd); }
@media (max-width: 480px) {
    .hrm-ai-widget { right: 12px; bottom: 12px; }
    .hrm-ai-widget-panel { width: calc(100vw - 24px); }
}
.hrm-face-video {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius);
    background: #111;
}

.dl-horizontal dt { font-weight: 600; color: var(--text-muted); font-size: 13px; }
.dl-horizontal dd { margin-bottom: 10px; font-size: 14px; }
