/* ============================================================
   Annie Insights — Site CSS
   Bootstrap 5 overrides + custom layout + sidebar styling
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --sidebar-width: 260px;
    --header-height: 56px;
    --footer-height: 40px;
    --ai-primary: #2563eb;
    --ai-primary-dark: #1d4ed8;
    --ai-bg: #f8f9fc;
    --ai-sidebar-bg: #1e293b;
    --ai-sidebar-text: #cbd5e1;
    --ai-sidebar-active: #3b82f6;
    --ai-border: #e2e8f0;
    --ai-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --ai-radius: 8px;
    --ai-transition: 0.2s ease;
}

/* --- Global --- */
html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    background: var(--ai-bg);
    color: #1e293b;
}

/* --- App Container (sidebar + main) --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--ai-sidebar-bg);
    color: var(--ai-sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    overflow-y: auto;
    transition: transform var(--ai-transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--ai-primary);
    border-radius: var(--ai-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-name {
    font-weight: 700;
    font-size: 15px;
    color: white;
    letter-spacing: 0.5px;
}

.brand-tagline {
    font-size: 11px;
    color: #94a3b8;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* --- Sidebar Search --- */
.sidebar-search {
    padding: 12px 16px;
}

.sidebar-search .input-group-text {
    border-color: rgba(255, 255, 255, 0.12);
    color: #94a3b8;
}

.sidebar-search .form-control {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
    color: white;
    font-size: 13px;
}

.sidebar-search .form-control::placeholder {
    color: #64748b;
}

.sidebar-search .form-control:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--ai-primary);
    box-shadow: none;
}

/* --- Sidebar Toggle (Active/Archive) --- */
.sidebar-toggle {
    padding: 0 16px 12px;
}

.sidebar-toggle .btn {
    font-size: 12px;
    padding: 4px 8px;
    font-weight: 500;
}

/* --- Letter Groups (A-C, D-F, etc.) --- */
.sidebar-letter-groups {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 0 16px 16px;
}

.letter-group-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: 6px;
    text-decoration: none;
    color: var(--ai-sidebar-text);
    font-size: 12px;
    font-weight: 500;
    transition: all var(--ai-transition);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.letter-group-tile:hover {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    border-color: rgba(255, 255, 255, 0.15);
}

.letter-group-tile.active {
    background: var(--ai-primary);
    color: white;
    border-color: var(--ai-primary);
}

.letter-group-tile .group-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* --- Sidebar Footer --- */
.sidebar-footer {
    margin-top: auto;
    padding: 8px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--ai-sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--ai-transition);
}

.sidebar-footer .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* --- Sidebar Logo --- */
.sidebar-logo {
    max-height: 32px;
    width: auto;
}

/* --- Login Page --- */
.h-100vh {
    height: 100vh;
}

.login-page {
    background: #fff;
}

.login-left {
    padding: 2rem;
}

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

.login-logo {
    max-height: 48px;
    width: auto;
}

.btn-login {
    background: var(--ai-primary);
    border-color: var(--ai-primary);
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-login:hover {
    background: var(--ai-primary-dark);
    border-color: var(--ai-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.login-page .carousel-item img {
    object-fit: cover;
    height: 100vh;
}

.login-page .carousel-indicators button {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* --- Dashboard --- */
.dashboard-welcome {
    background: white;
    border-radius: var(--ai-radius);
    padding: 2rem;
    box-shadow: var(--ai-card-shadow);
}

/* --- Sidebar Nav Links --- */
.sidebar-divider {
    margin: 8px 16px;
    border-color: rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--ai-sidebar-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--ai-transition);
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: white;
}

.sidebar-nav .nav-link.active {
    background: rgba(59, 130, 246, 0.15);
    color: var(--ai-sidebar-active);
    border-right: 3px solid var(--ai-sidebar-active);
}

.sidebar-nav .nav-link i {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

/* --- Main Content --- */
.app-main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Header --- */
.app-header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 500;
}

.header-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #1e293b;
}

.user-menu {
    text-decoration: none;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
}

/* --- Page Content --- */
.app-content {
    flex: 1;
    padding: 24px;
}

/* --- Footer --- */
.app-footer {
    height: var(--footer-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #94a3b8;
    border-top: 1px solid var(--ai-border);
    background: white;
}

.app-footer a {
    color: var(--ai-primary);
    text-decoration: none;
}

/* --- Cards --- */
.welcome-card {
    background: white;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-card-shadow);
    padding: 32px;
    margin-top: 16px;
}

/* --- Login Layout --- */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    color: white;
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand i {
    font-size: 48px;
    margin-bottom: 16px;
}

.login-brand h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

/* --- Report Layout --- */
.report-page {
    background: white;
    min-height: 100vh;
}

.report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 2px solid var(--ai-primary);
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.report-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.report-brand .brand-icon {
    width: 40px;
    height: 40px;
    background: var(--ai-primary);
    border-radius: var(--ai-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

.report-brand .brand-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--ai-primary-dark);
}

.report-brand .brand-text small {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #64748b;
}

.report-content {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
}

.report-footer {
    text-align: center;
    padding: 16px;
    font-size: 12px;
    color: #94a3b8;
    border-top: 1px solid var(--ai-border);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .app-sidebar {
        transform: translateX(-100%);
    }

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

    .app-main {
        margin-left: 0;
    }
}

/* --- Print Styles --- */
@media print {
    .app-sidebar,
    .app-header,
    .app-footer,
    .report-actions,
    .sidebar-toggle-btn {
        display: none !important;
    }

    .app-main {
        margin-left: 0;
    }

    .report-page {
        background: white;
    }

    .report-content {
        padding: 0;
    }
}

/* ============================================================
   Patient Management Pages
   ============================================================ */

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 4px;
    color: #1e293b;
}

.breadcrumb {
    font-size: 12px;
}

.breadcrumb-item a {
    color: var(--ai-primary);
    text-decoration: none;
}

/* --- Content Toolbar --- */
.content-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: white;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-card-shadow);
    margin-bottom: 12px;
}

/* --- Progress Tracker (inline 3-step) --- */
.progress-tracker {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: relative;
    padding: 4px 0;
    min-width: 140px;
}

.progress-tracker::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 14px;
    right: 14px;
    height: 3px;
    background: #e2e8f0;
    z-index: 0;
}

.progress-tracker-bar {
    position: absolute;
    top: 10px;
    left: 14px;
    height: 3px;
    background: var(--ai-primary);
    z-index: 1;
    transition: width 0.4s ease;
}

.progress-tracker-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    font-size: 10px;
    color: #94a3b8;
    gap: 3px;
}

.progress-tracker-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e2e8f0;
    border: 2px solid white;
    box-shadow: 0 0 0 1px #e2e8f0;
    transition: all 0.3s ease;
}

.progress-tracker-step.active .progress-tracker-dot {
    background: var(--ai-primary);
    box-shadow: 0 0 0 1px var(--ai-primary);
}

.progress-tracker-step.active {
    color: var(--ai-primary);
    font-weight: 600;
}

/* --- Avatar Circle --- */
.avatar-circle {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary) 0%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
}

/* --- Patient Info List --- */
.patient-info-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.info-row i {
    width: 18px;
    text-align: center;
    font-size: 14px;
}

/* --- Table Enhancements --- */
.table th {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    border-bottom-width: 2px;
    padding: 12px;
}

.table td {
    padding: 12px;
    font-size: 13px;
    vertical-align: middle;
}

.table-hover tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.04);
}

/* --- Badge Enhancements --- */
.bg-primary-subtle {
    background-color: rgba(37, 99, 235, 0.1) !important;
}

/* --- Button Icon Only --- */
.btn-icon-only {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

/* --- Form Enhancements (Modal) --- */
.text-uppercase {
    text-transform: uppercase;
}

/* --- Card Border-0 Shadow --- */
.card.border-0.shadow-sm {
    border-radius: var(--ai-radius);
}

.card-header {
    border-bottom: 1px solid var(--ai-border);
    padding: 14px 16px;
}

/* ============================================================
   Report Pages (annie-card system from Report-2)
   ============================================================ */

.annie-card {
    background: white;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-card-shadow);
    margin-bottom: 16px;
    overflow: hidden;
}

.annie-card .card-body {
    padding: 20px 24px;
}

/* --- Patient Header (report top bar) --- */
.patient-header {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 2px solid var(--ai-primary);
}

.patient-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field-label {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
}

.field-value {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
}

/* --- Section Header --- */
.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

.section-header i {
    color: var(--ai-primary);
    font-size: 16px;
}

/* --- Annie Table --- */
.annie-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.annie-table th {
    background: #f8fafc;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #64748b;
    padding: 10px 12px;
    border-bottom: 2px solid #e2e8f0;
    text-align: left;
}

.annie-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
    color: #334155;
}

.annie-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.03);
}

/* --- Data Field (key-value rows) --- */
.data-field {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

.data-label {
    font-weight: 600;
    color: #1e293b;
}

.data-value {
    color: #475569;
}

/* --- Grid 2 Column --- */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }
}

/* --- No Data State --- */
.no-data-state {
    text-align: center;
    padding: 40px 20px;
}

.no-data-icon {
    font-size: 48px;
    color: #cbd5e1;
    margin-bottom: 12px;
}

.no-data-title {
    font-size: 16px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 4px;
}

.no-data-text {
    font-size: 13px;
    color: #94a3b8;
}

/* ============================================================
   Case Management (Phase 4 — Stepper & Image Upload)
   ============================================================ */

/* --- Case Stepper --- */
.case-stepper {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    position: relative;
    padding: 16px 24px;
    background: white;
    border-radius: var(--ai-radius);
    box-shadow: var(--ai-card-shadow);
    margin-bottom: 16px;
}

.stepper-line-bg {
    position: absolute;
    top: 34px;
    left: 60px;
    right: 60px;
    height: 3px;
    background: #e2e8f0;
    z-index: 0;
}

.stepper-line-progress {
    position: absolute;
    top: 34px;
    left: 60px;
    height: 3px;
    background: var(--ai-primary);
    z-index: 1;
    transition: width 0.4s ease;
}

.stepper-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 2;
    cursor: pointer;
    text-align: center;
    min-width: 80px;
}

.stepper-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #e2e8f0;
    border: 3px solid white;
    box-shadow: 0 0 0 2px #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #64748b;
    transition: all 0.3s ease;
    margin-bottom: 6px;
}

.stepper-item.active .stepper-circle {
    background: var(--ai-primary);
    box-shadow: 0 0 0 2px var(--ai-primary);
    color: white;
}

.stepper-item.done .stepper-circle {
    background: #10b981;
    box-shadow: 0 0 0 2px #10b981;
    color: white;
}

.stepper-label {
    font-size: 10px;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
}

.stepper-item.active .stepper-label {
    color: var(--ai-primary);
}

.stepper-item.done .stepper-label {
    color: #10b981;
}

/* --- Image Upload Cards --- */
.card-img-upload {
    border: 2px dashed #e2e8f0;
    border-radius: var(--ai-radius);
    transition: border-color 0.2s ease;
    height: 100%;
}

.card-img-upload:hover {
    border-color: var(--ai-primary);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 160px;
    cursor: pointer;
    padding: 20px;
}

.upload-placeholder:hover {
    background: rgba(59, 130, 246, 0.04);
    border-radius: 8px;
}

.img-clickable {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.img-clickable:hover {
    transform: scale(1.02);
}

/* ============================================================
   Phase 5: Credits & Checkout
   ============================================================ */

.credit-balance-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ai-primary), #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.credit-balance-value {
    color: white;
    font-size: 28px;
    font-weight: 800;
}

.credit-pkg-card {
    cursor: pointer;
    border: 2px solid #e2e8f0;
    border-radius: var(--ai-radius);
    transition: all 0.2s ease;
}

.credit-pkg-card:hover {
    border-color: var(--ai-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.credit-pkg-card.border-primary {
    border-color: var(--ai-primary) !important;
    background: rgba(59, 130, 246, 0.04);
}

.checkout-icon {
    font-size: 64px;
}

.checkout-icon.success {
    color: #10b981;
}

.checkout-icon.cancel {
    color: #f59e0b;
}

/* ============================================================
   Phase 6: Digitize
   ============================================================ */

.digitize-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
}

#konva-container {
    cursor: crosshair;
}
