:root {
    --brand: #0d6efd;
    --brand-dark: #0b5ed7;
    --sidebar-bg: #14213d;
    --sidebar-fg: #cbd5e1;
    --sidebar-fg-active: #ffffff;
    --sidebar-active: #1f3a68;
    --header-h: 56px;
    --sidebar-w: 250px;
    --content-bg: #f5f7fb;
}

html, body {
    height: 100%;
}

/* Base font size — scales the whole UI (Bootstrap uses rem units). */
html {
    font-size: 16px;
}

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--content-bg);
    color: #1f2937;
}

/* ---------- Anonymous (login) ---------- */
.app-anonymous {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #14213d 0%, #1f3a68 100%);
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
    padding: 2rem;
}

.auth-brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-brand .brand-mark { font-size: 2.5rem; }

/* ---------- App shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
    overflow-x: clip;
}

.app-sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1030;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 1rem 1.25rem;
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .brand-mark { font-size: 1.4rem; }

.sidebar-nav {
    padding: .75rem 0;
    display: flex;
    flex-direction: column;
}

.sidebar-nav .nav-link {
    color: var(--sidebar-fg);
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    font-size: 1rem;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255,255,255,.05);
    color: #fff;
}

.sidebar-nav .nav-link.active {
    background: var(--sidebar-active);
    color: var(--sidebar-fg-active);
    border-left-color: var(--brand);
}

.sidebar-nav .nav-icon { width: 1.2rem; text-align: center; }

.nav-section {
    padding: 1rem 1.25rem .35rem;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
}

.app-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow-x: clip;
}

.app-header {
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.header-search {
    flex: 1;
    max-width: 480px;
    position: relative;
}

.header-search .input-group:focus-within {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    border-radius: 0.375rem;
}

.header-search .input-group:focus-within .input-group-text,
.header-search .input-group:focus-within .form-control {
    border-color: #86b7fe;
}

.header-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.12), 0 8px 10px -6px rgba(0, 0, 0, 0.08);
    z-index: 1060;
    max-height: 420px;
    overflow-y: auto;
}

.header-search-item {
    display: block;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.header-search-item:last-child {
    border-bottom: none;
}

.header-search-item:hover,
.header-search-item.active {
    background-color: #f8fafc;
    color: #0f172a;
}

.header-search-item .patient-id-badge {
    font-size: 0.75rem;
    font-family: var(--bs-font-monospace);
}

.header-search-footer {
    display: block;
    padding: 0.5rem 0.875rem;
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 0.825rem;
    font-weight: 500;
    color: #0d6efd;
    text-decoration: none;
    text-align: center;
}

.header-search-footer:hover {
    background-color: #f1f5f9;
    color: #0a58ca;
}

.header-user { margin-left: auto; }

.app-content {
    padding: 1.25rem 1.5rem 3rem;
    flex: 1;
}

.page-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.breadcrumb { font-size: .95rem; }

/* ---------- Cards / dashboard ---------- */
.stat-card {
    display: block;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1rem 1.15rem;
    text-decoration: none;
    color: inherit;
    height: 100%;
    transition: box-shadow .15s ease, transform .15s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,.08);
    transform: translateY(-1px);
    color: inherit;
}

.stat-card .stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card .stat-label {
    color: #6b7280;
    font-size: .95rem;
}

.stat-card .stat-icon { font-size: 1.4rem; opacity: .5; }

.card { border-color: #e5e7eb; }

/* ---------- Data tables ---------- */
.table thead th {
    font-size: .875rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    font-size: .95rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #9ca3af;
}

.empty-state .empty-icon { font-size: 2.5rem; }

/* ---------- Profile tabs ---------- */
.profile-header {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 1.15rem 1.25rem;
    margin-bottom: 1rem;
}

.profile-name { font-size: 1.35rem; font-weight: 600; }

.profile-meta { color: #6b7280; font-size: .9rem; }

.nav-tabs .nav-link { color: #374151; }
.nav-tabs .nav-link.active { font-weight: 600; }

.timeline {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

.timeline li {
    border-left: 2px solid #e5e7eb;
    padding: 0 0 1rem 1rem;
    position: relative;
}

.timeline li::before {
    content: "";
    position: absolute;
    left: -6px;
    top: .25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--brand);
}

/* ---------- Responsive ---------- */
@media (max-width: 767.98px) {
    .app-sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; }
}

/* ---- Work-time widget (floating, draggable box) ---- */
.work-time-widget {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1050;
    width: 196px;
    padding: 0.45rem 0.75rem 0.6rem;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 0.6rem;
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.15);
    font-size: 0.85rem;
    touch-action: none;
    transition: box-shadow 0.15s ease, opacity 0.15s ease;
}

.work-time-widget.wt-dragging {
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.25);
    opacity: 0.94;
    cursor: grabbing !important;
    user-select: none;
}

.work-time-widget .wt-drag-bar {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding-bottom: 0.35rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    cursor: grab;
    user-select: none;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.work-time-widget.wt-dragging .wt-drag-bar {
    cursor: grabbing;
}

.work-time-widget .wt-grip {
    letter-spacing: -1px;
    font-size: 0.85rem;
    line-height: 1;
    color: #94a3b8;
}

.work-time-widget .wt-drag-title {
    flex: 1;
}

.work-time-widget .wt-reset-pos {
    background: transparent;
    border: none;
    color: #64748b;
    padding: 0 0.2rem;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 0.25rem;
}

.work-time-widget .wt-reset-pos:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.work-time-widget .wt-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.work-time-widget .wt-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.work-time-widget .wt-times {
    flex: 1 1 auto;
}

.work-time-widget .wt-worked,
.work-time-widget .wt-break {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
}

.work-time-widget .wt-label {
    color: #6c757d;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.work-time-widget .wt-value {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    font-size: 1rem;
}

.work-time-widget .wt-break .wt-value {
    color: #b8860b;
}

/* Keep the widget clear of the toast stack when both are visible. */
.toast-container {
    margin-bottom: 7.5rem;
}

@media (max-width: 575.98px) {
    .work-time-widget {
        width: 160px;
    }
}


/* Date Picker Native Sync Positioning (anchors browser calendar directly at the trigger button without horizontal overflow) */
.date-picker-native-sync {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    width: 42px !important;
    max-width: 42px !important;
    min-width: 0 !important;
    height: 100% !important;
    opacity: 0 !important;
    pointer-events: none !important;
    z-index: -1 !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
}

/* For small input groups */
.input-group-sm > .date-picker-native-sync {
    width: 34px !important;
    max-width: 34px !important;
}

/* Ensure button retains its rounded right corners when followed by native sync input in input-group */
.input-group > .btn-date-picker-trigger {
    border-top-right-radius: var(--bs-border-radius) !important;
    border-bottom-right-radius: var(--bs-border-radius) !important;
}

.input-group-sm > .btn-date-picker-trigger {
    border-top-right-radius: var(--bs-border-radius-sm) !important;
    border-bottom-right-radius: var(--bs-border-radius-sm) !important;
}
