/* ==========================================================================
   Employee attendance admin: SaaS-style dashboard theme on top of Bootstrap 5.3
   ========================================================================== */

:root {
    --app-primary: #4f46e5;
    --app-primary-dark: #4338ca;
    --app-primary-soft: #eef2ff;
    --app-bg: #f4f6fb;
    --app-surface: #ffffff;
    --app-border: #e6e9f0;
    --app-text: #1f2937;
    --app-muted: #6b7280;
    --app-sidebar: #0f172a;
    --app-sidebar-text: #94a3b8;
    --app-radius: 14px;
    --app-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --app-shadow-lg: 0 12px 32px rgba(16, 24, 40, .12);

    --bs-primary: #4f46e5;
    --bs-primary-rgb: 79, 70, 229;
    --bs-link-color: #4f46e5;
    --bs-link-color-rgb: 79, 70, 229;
    --bs-link-hover-color: #4338ca;
    --bs-body-bg: var(--app-bg);
    --bs-body-color: var(--app-text);
    --bs-border-color: var(--app-border);
    --bs-focus-ring-color: rgba(79, 70, 229, .25);
}

html { -webkit-text-size-adjust: 100%; }

body {
    background: var(--app-bg);
    color: var(--app-text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: .94rem;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { letter-spacing: -.01em; }
.text-muted, .text-secondary { color: var(--app-muted) !important; }
.min-w-0 { min-width: 0; }
/* overflow-wrap (unlike Bootstrap .text-break / word-break) does not shrink the minimum width of table columns */
.wrap { overflow-wrap: break-word; }

/* ---- buttons ---------------------------------------------------------------------------------------------- */
.btn { border-radius: 10px; font-weight: 500; }
.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-dark);
    --bs-btn-hover-border-color: var(--app-primary-dark);
    --bs-btn-active-bg: var(--app-primary-dark);
    --bs-btn-active-border-color: var(--app-primary-dark);
    --bs-btn-disabled-bg: var(--app-primary);
    --bs-btn-disabled-border-color: var(--app-primary);
    --bs-btn-focus-shadow-rgb: 79, 70, 229;
}
.btn-outline-primary {
    --bs-btn-color: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary);
    --bs-btn-hover-border-color: var(--app-primary);
    --bs-btn-active-bg: var(--app-primary);
    --bs-btn-active-border-color: var(--app-primary);
}
.btn-icon { width: 2rem; height: 2rem; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-light-border { background: #fff; border: 1px solid var(--app-border); color: var(--app-text); }
.btn-light-border:hover { background: #f8fafc; border-color: #d5dae4; }

.form-control, .form-select { border-radius: 10px; border-color: #d9dee8; }
.form-control:focus, .form-select:focus { border-color: var(--app-primary); box-shadow: 0 0 0 .2rem rgba(79, 70, 229, .15); }
.form-label { font-weight: 500; margin-bottom: .35rem; }
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }
.form-text { color: var(--app-muted); }

/* ---- shell ------------------------------------------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.app-content { padding: 1.5rem; width: 100%; max-width: 1480px; margin: 0 auto; flex: 1 0 auto; }
.app-footer { padding: 1rem 1.5rem; color: var(--app-muted); font-size: .8rem; }

.sidebar { display: contents; }
.sidebar-panel {
    --bs-offcanvas-bg: var(--app-sidebar);
    --bs-offcanvas-color: #cbd5e1;
    --bs-offcanvas-width: 280px;
}
@media (min-width: 992px) {
    .sidebar {
        display: block;
        flex: 0 0 264px;
        width: 264px;
        background: var(--app-sidebar);
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
    }
}
.sidebar .offcanvas-body { padding: 0 1rem 1rem; }
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.25rem .5rem 1.1rem; color: #fff; text-decoration: none; }
.sidebar-brand .brand-mark {
    width: 38px; height: 38px; border-radius: 11px; flex: 0 0 38px;
    background: linear-gradient(135deg, #6366f1, #4338ca);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem;
    box-shadow: 0 6px 16px rgba(79, 70, 229, .45);
}
.sidebar-brand .brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.sidebar-brand .brand-sub { font-size: .72rem; color: var(--app-sidebar-text); }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 1rem .75rem .4rem; }
.nav-app .nav-link {
    display: flex; align-items: center; gap: .75rem; padding: .62rem .85rem; margin-bottom: 2px;
    border-radius: 10px; color: var(--app-sidebar-text); font-weight: 500;
}
.nav-app .nav-link .bi { font-size: 1.1rem; opacity: .9; }
.nav-app .nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-app .nav-link.active { background: var(--app-primary); color: #fff; box-shadow: 0 6px 16px rgba(79, 70, 229, .35); }
.sidebar-foot { margin-top: auto; padding: 1rem .5rem 0; color: #64748b; font-size: .75rem; }

.topbar {
    position: sticky; top: 0; z-index: 1020; height: 64px; padding: 0 1.25rem;
    display: flex; align-items: center; gap: .75rem;
    background: rgba(255, 255, 255, .9); backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--app-border);
}
.topbar .company-switch { max-width: 100%; }
.topbar .company-switch .label { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 575.98px) {
    .topbar { padding: 0 .75rem; gap: .5rem; }
    .topbar .company-switch .label { max-width: 7.5rem; }
    .app-content { padding: 1rem .75rem; }
}
.dropdown-menu { border-radius: 12px; border-color: var(--app-border); box-shadow: var(--app-shadow-lg); padding: .4rem; }
.dropdown-item { border-radius: 8px; padding: .5rem .75rem; }
.dropdown-item.active, .dropdown-item:active { background: var(--app-primary); }

/* ---- cards & page header ---------------------------------------------------------------------------------- */
.card { background: var(--app-surface); border: 1px solid var(--app-border); border-radius: var(--app-radius); box-shadow: var(--app-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--app-border); font-weight: 600; padding: .9rem 1.25rem; }
.card-body { padding: 1.25rem; }
.page-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-title { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-subtitle { color: var(--app-muted); margin: .15rem 0 0; }
.breadcrumb { font-size: .82rem; margin-bottom: .35rem; --bs-breadcrumb-divider-color: #9ca3af; }
.breadcrumb a { text-decoration: none; }

.stat-tile { display: flex; flex-direction: row; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.stat-icon {
    width: 48px; height: 48px; flex: 0 0 48px; border-radius: 14px; font-size: 1.4rem;
    display: inline-flex; align-items: center; justify-content: center; background: var(--app-primary-soft); color: var(--app-primary);
}
.stat-icon.green { background: #ecfdf3; color: #039855; }
.stat-icon.amber { background: #fffaeb; color: #b54708; }
.stat-icon.sky { background: #eff8ff; color: #175cd3; }
.stat-icon.rose { background: #fef3f2; color: #d92d20; }
.stat-value { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--app-muted); font-size: .82rem; }

/* ---- tables ----------------------------------------------------------------------------------------------- */
.table-modern { margin-bottom: 0; --bs-table-bg: transparent; }
.table-modern thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--app-muted); font-weight: 600;
    background: #f9fafc; border-bottom: 1px solid var(--app-border); white-space: nowrap; padding: .75rem 1rem;
}
.table-modern tbody td { padding: .8rem 1rem; vertical-align: middle; border-color: var(--app-border); }
.table-modern tbody tr:hover { background: #fafbff; }
.sort-link { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: .3rem; }
.sort-link:hover, .sort-link.is-sorted { color: var(--app-primary); }
.table-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .85rem 1rem; border-top: 1px solid var(--app-border); }
.page-link { color: var(--app-primary); border-radius: 8px; margin: 0 2px; border-color: var(--app-border); }
.page-item.active .page-link { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }

.filters { padding: 1rem 1.25rem; }
.filters .form-control, .filters .form-select { min-width: 0; }

/* ---- avatars & badges ------------------------------------------------------------------------------------- */
.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; overflow: hidden;
    width: 40px; height: 40px; border-radius: 50%; background: var(--app-primary-soft); color: var(--app-primary);
    font-weight: 600; font-size: .85rem; border: 1px solid #e0e7ff;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-sm { width: 32px; height: 32px; font-size: .75rem; }
.avatar-lg { width: 72px; height: 72px; font-size: 1.4rem; }
.avatar-square { border-radius: 12px; }
.avatar-xl { width: 168px; height: 168px; font-size: 3rem; border-radius: 20px; }
.badge-soft { font-weight: 600; border-radius: 999px; padding: .4em .75em; font-size: .72rem; }
.badge-soft-success { background: #ecfdf3; color: #027a48; }
.badge-soft-warning { background: #fffaeb; color: #b54708; }
.badge-soft-danger { background: #fef3f2; color: #b42318; }
.badge-soft-secondary { background: #f2f4f7; color: #475467; }
.badge-soft-primary { background: var(--app-primary-soft); color: var(--app-primary-dark); }
.badge-soft-sky { background: #eff8ff; color: #175cd3; }

.entity-cell { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.table-modern td .entity-cell { min-width: 12rem; }
.entity-cell .entity-title { font-weight: 600; color: var(--app-text); text-decoration: none; }
.entity-cell .entity-title:hover { color: var(--app-primary); }
.entity-cell .entity-sub { font-size: .78rem; color: var(--app-muted); }

/* ---- empty state, key/value lists ------------------------------------------------------------------------- */
.empty-state { text-align: center; padding: 3rem 1.5rem; color: var(--app-muted); }
.empty-state .bi { font-size: 2.5rem; color: #c7cdd9; display: block; margin-bottom: .5rem; }
.empty-state .title { font-weight: 600; color: var(--app-text); margin-bottom: .25rem; }
.kv { display: grid; grid-template-columns: minmax(7rem, 11rem) 1fr; gap: .6rem 1rem; margin: 0; }
.kv dt { color: var(--app-muted); font-weight: 500; }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 575.98px) { .kv { grid-template-columns: 1fr; gap: .1rem; } .kv dd { margin-bottom: .6rem; } }
.placeholder-card { border: 1px dashed #cbd2e0; background: #fbfcfe; box-shadow: none; }

/* ---- alerts & forms --------------------------------------------------------------------------------------- */
.app-flash { border: 0; border-radius: 12px; display: flex; align-items: center; gap: .6rem; box-shadow: var(--app-shadow); }
.app-flash.alert-success { background: #ecfdf3; color: #067647; }
.app-flash.alert-danger { background: #fef3f2; color: #b42318; }
.app-flash.alert-warning { background: #fffaeb; color: #b54708; }
.form-section-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--app-muted); font-weight: 600; margin: 0 0 .9rem; }
.photo-upload { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.is-loading { pointer-events: none; opacity: .85; }
.audit-details { max-width: 28rem; }
.audit-details pre { margin: .35rem 0 0; padding: .6rem .75rem; background: #f8fafc; border: 1px solid var(--app-border); border-radius: 8px; font-size: .75rem; white-space: pre-wrap; word-break: break-word; max-height: 12rem; overflow: auto; }
code.code-chip { background: #f2f4f7; color: #344054; padding: .15rem .45rem; border-radius: 6px; font-size: .78rem; }

/* ---- public (login / setup / errors) ---------------------------------------------------------------------- */
.public-shell { min-height: 100vh; display: flex; }
.public-aside {
    flex: 1 1 46%; display: none; position: relative; overflow: hidden; color: #fff; padding: 3rem;
    background: radial-gradient(1200px 600px at 10% 0%, #6366f1 0%, transparent 60%), linear-gradient(160deg, #1e1b4b, #312e81 55%, #4338ca);
}
.public-aside .brand-mark { width: 46px; height: 46px; border-radius: 14px; background: rgba(255, 255, 255, .16); display: inline-flex; align-items: center; justify-content: center; font-size: 1.5rem; }
.public-aside h1 { font-weight: 700; font-size: 2.1rem; line-height: 1.2; margin-top: 3rem; }
.public-aside p { color: #c7d2fe; max-width: 28rem; }
.public-aside ul { list-style: none; padding: 0; margin: 2rem 0 0; color: #e0e7ff; }
.public-aside li { display: flex; gap: .75rem; margin-bottom: .9rem; align-items: flex-start; }
.public-main { flex: 1 1 54%; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.public-card { width: 100%; max-width: 440px; }
.public-card.wide { max-width: 560px; }
@media (min-width: 992px) { .public-aside { display: block; } }
.error-code { font-size: 4.5rem; font-weight: 800; color: #c7cdd9; line-height: 1; }
