/**
 * HR Attendance System - Main Stylesheet
 * Step 1: Layout, Sidebar, Login
 */

:root {
    --sidebar-width: 260px;
    --topbar-height: 60px;
    --primary-color: #0d6efd;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #3b82f6;
}

/* ---- Locale fonts ---- */
body.locale-lo,
html[lang="lo"] body {
    font-family: "Noto Sans Lao", "Noto Sans", system-ui, -apple-system, sans-serif;
}

body.locale-lo .form-control,
body.locale-lo .form-select,
body.locale-lo .btn,
body.locale-lo .nav-link,
body.locale-lo .dropdown-item {
    font-family: inherit;
}

/* ---- App Layout ---- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    background-color: #f1f5f9;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    margin-left: var(--sidebar-width);
}

.app-content {
    flex: 1;
}

.app-topbar {
    min-height: var(--topbar-height);
    position: sticky;
    top: 0;
    z-index: 1020;
    overflow: visible;
}

.app-topbar-inner,
.app-topbar-actions {
    overflow: visible;
}

.app-topbar-actions .nav-item.dropdown {
    position: relative;
}

.app-topbar-actions .nav-item.dropdown > .dropdown-menu,
.app-topbar-actions .nav-item.dropdown .app-topbar-dropdown-menu {
    position: absolute;
    top: 100%;
    left: auto;
    right: 0;
    z-index: 1060;
    margin-top: 0.375rem;
}

.topbar-title {
    color: #1e293b;
}

.topbar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--primary-color);
    flex-shrink: 0;
}

.topbar-avatar .user-avatar,
.user-avatar.topbar-user-avatar {
    display: block;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #f1f5f9;
}

.app-topbar-icon-btn .user-avatar {
    border: 1px solid rgba(15, 23, 42, 0.08);
}

/* ---- Sidebar ---- */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1030;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    height: var(--topbar-height);
    padding: 0 1.25rem;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand i {
    font-size: 1.25rem;
    color: var(--sidebar-active);
}

.sidebar-nav {
    padding: 1rem 0.75rem;
    flex: 1;
}

.sidebar-section-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #64748b;
    padding: 1rem 0.75rem 0.5rem;
    font-weight: 600;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-text);
    border-radius: 0.5rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.15rem;
    display: flex;
    align-items: center;
    transition: background 0.2s, color 0.2s;
}

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

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav .nav-link.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1025;
}

.sidebar-overlay.show {
    display: block;
}

/* ---- Employee photos ---- */
.employee-thumb,
.employee-photo-preview {
    object-fit: cover;
    background: #e9ecef;
}

/* ---- Language Switcher ---- */
.lang-switcher .dropdown-toggle {
    min-width: 5rem;
}

.lang-switcher .dropdown-item.active {
    font-weight: 600;
}

/* ---- Login Page ---- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

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

.login-card {
    background: #fff;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.login-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
    font-size: 1.75rem;
    color: #fff;
}

.login-footer {
    border-top: 1px solid #eee;
    padding-top: 1rem;
    margin-top: 0.5rem;
}

/* ---- Stat Cards ---- */
.stat-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* ---- Tables ---- */
.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6c757d;
}

/* ---- Footer ---- */
.app-footer {
    margin-top: auto;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .app-main {
        margin-left: 0;
    }

    .app-sidebar {
        transform: translateX(-100%);
    }

    .app-sidebar.show {
        transform: translateX(0);
    }
}

@media (max-width: 576px) {
    .login-card {
        padding: 1.5rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ---- Face Recognition (Step 4) ---- */
.face-video-wrap {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 4 / 3;
    background: #0f172a;
    border-radius: 0.5rem;
    overflow: hidden;
}

.face-canvas-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.face-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

/* ---- Reports (Step 5) ---- */
.report-card {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.report-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1) !important;
}

/* ---- Mobile Check-in (Step 13) ---- */
.mobile-checkin-page {
    max-width: 480px;
    margin: 0 auto;
}

.employee-self-photo-picker {
    border: 1px dashed #cbd5e1;
    border-radius: 0.75rem;
    background: #f8fafc;
}

.employee-self-photo-picker:hover,
.employee-self-photo-picker:focus {
    border-color: var(--primary-color);
    background: rgba(13, 110, 253, 0.04);
}
    padding-top: 0.85rem;
    padding-bottom: 0.85rem;
}

.antifraud-checklist li {
    padding: 0.25rem 0;
}

.mobile-checkin-extras-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    background: #f8fafc;
    color: #334155;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: left;
}

.mobile-checkin-extras-toggle:hover,
.mobile-checkin-extras-toggle:focus {
    background: #f1f5f9;
    color: #1e293b;
}

.mobile-checkin-extras-toggle-label {
    min-width: 0;
}

.mobile-checkin-extras-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.mobile-checkin-extras-toggle[aria-expanded="true"] .mobile-checkin-extras-chevron {
    transform: rotate(180deg);
}

.mobile-checkin-extras-body {
    margin-top: 0.65rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.65rem;
    background: #fff;
}

@media (min-width: 768px) {
    .mobile-checkin-extras-body.collapse:not(.show) {
        display: block;
        height: auto !important;
        visibility: visible;
    }

    .mobile-checkin-extras-body.collapsing {
        height: auto !important;
        transition: none;
    }

    .mobile-checkin-extras .mt-3 {
        display: none;
    }
}

@media (min-width: 992px) {
    .mobile-checkin-page {
        max-width: 720px;
    }
}

.my-hr-page {
    max-width: 960px;
    margin: 0 auto;
}

.my-hr-page .nav-tabs .nav-link {
    font-size: 0.9rem;
    white-space: nowrap;
}

/* ---- My HR — mobile bottom navigation ---- */
.my-hr-bottom-spacer {
    flex-shrink: 0;
    width: 100%;
    height: var(--my-hr-bottom-scroll-padding, 7rem);
    pointer-events: none;
}

.my-hr-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1035;
    display: flex;
    align-items: stretch;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
    padding-bottom: var(--my-hr-system-nav-inset, 36px);
}

.my-hr-bottom-nav-item {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    padding: 0.45rem 0.15rem;
    min-height: calc(3.5rem + var(--my-hr-bottom-nav-extra, 12px));
    font-size: 0.625rem;
    line-height: 1.2;
    color: #64748b;
    text-decoration: none;
    text-align: center;
    transition: color 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.my-hr-bottom-nav-item i {
    font-size: 1.35rem;
    line-height: 1;
}

.my-hr-bottom-nav-item span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 0.1rem;
}

.my-hr-bottom-nav-item:hover,
.my-hr-bottom-nav-item:focus {
    color: var(--primary-color);
    background: rgba(13, 110, 253, 0.06);
}

.my-hr-bottom-nav-item.active {
    color: var(--primary-color);
    font-weight: 600;
}

.my-hr-bottom-nav-item.active i {
    transform: scale(1.05);
}

@media (max-width: 767.98px) {
    body.page-my-hr {
        --my-hr-bottom-nav-extra: 12px;
        --my-hr-system-nav-inset: max(36px, env(safe-area-inset-bottom, 0px));
        --my-hr-bottom-nav-row: calc(3.5rem + var(--my-hr-bottom-nav-extra));
        --my-hr-bottom-nav-total-height: calc(var(--my-hr-bottom-nav-row) + var(--my-hr-system-nav-inset));
        --my-hr-bottom-scroll-gap: 1.25rem;
        --my-hr-bottom-scroll-padding: calc(var(--my-hr-bottom-nav-total-height) + var(--my-hr-bottom-scroll-gap));
        --app-native-topbar-height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
        scroll-padding-bottom: var(--my-hr-bottom-scroll-padding);
    }

    body.page-my-hr .app-sidebar,
    body.page-my-hr .sidebar-overlay {
        display: none !important;
    }

    body.page-my-hr .app-topbar--native {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1034;
        min-height: var(--app-native-topbar-height);
        padding-top: env(safe-area-inset-top, 0);
        box-shadow: 0 1px 0 rgba(15, 23, 42, 0.06);
        overflow: visible;
    }

    body.page-my-hr .app-topbar-inner {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        gap: 0.5rem;
        min-height: var(--topbar-height);
        padding-inline: 0.75rem;
    }

    body.page-my-hr .app-topbar-brand {
        width: 2.25rem;
        height: 2.25rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.65rem;
        background: linear-gradient(135deg, #0d6efd, #2563eb);
        color: #fff;
        text-decoration: none;
        flex-shrink: 0;
        font-size: 1.15rem;
    }

    body.page-my-hr .app-topbar-title-native {
        text-align: center;
        justify-self: center;
        width: 100%;
        max-width: 100%;
        font-size: 1.0625rem;
        letter-spacing: -0.01em;
    }

    body.page-my-hr .app-topbar-actions {
        margin-left: 0 !important;
        justify-self: end;
    }

    body.page-my-hr .app-topbar-icon-btn,
    body.page-my-hr .app-topbar-actions > .nav-item > .nav-link {
        color: #334155;
    }

    body.page-my-hr .app-topbar-icon-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 2.25rem;
        min-height: 2.25rem;
        border-radius: 0.5rem;
    }

    body.page-my-hr .app-topbar-icon-btn:hover,
    body.page-my-hr .app-topbar-icon-btn:focus {
        background: rgba(15, 23, 42, 0.06);
        color: #334155;
    }

    body.page-my-hr .app-main {
        padding-top: var(--app-native-topbar-height);
    }

    body.page-my-hr .app-content .container-fluid {
        padding-top: 1rem;
        padding-bottom: 0.75rem;
    }

    body.page-my-hr .app-footer {
        display: none;
    }

    body.page-my-hr .my-hr-tabs-desktop {
        display: none !important;
    }
}

@media (max-width: 380px) {
    .my-hr-bottom-nav-item {
        font-size: 0.575rem;
        padding-inline: 0.05rem;
    }

    .my-hr-bottom-nav-item i {
        font-size: 1.2rem;
    }
}

/* ---- Mobile Phone Login ---- */
.login-mobile-page {
    background: linear-gradient(160deg, #ecfdf5 0%, #f0f9ff 50%, #ffffff 100%);
}

.login-mobile-wrapper {
    max-width: 420px;
}

.login-mobile-icon {
    background: linear-gradient(135deg, #198754, #20c997);
    color: #fff;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.login-mobile-features li {
    padding: 0.2rem 0;
}

.report-icon {
    width: 48px;
    height: 48px;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

/* ---- Branch map (Leaflet) ---- */
.branch-map {
    height: 380px;
    min-height: 280px;
    z-index: 1;
}

@media (max-width: 576px) {
    .branch-map {
        height: 300px;
    }
}

/* ---- Notifications (Step 9) ---- */
.notification-badge {
    position: absolute;
    top: 2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    color: #fff;
    background: #dc3545;
    border-radius: 999px;
}

.notification-dropdown {
    width: min(320px, 90vw);
    max-height: 360px;
    overflow-y: auto;
}
