/* ============================================================
   Autonomize AI — Claims Inquiry Automation Design System
   ============================================================ */

button {
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
    background: none;
    border: none;
    outline: none;
    padding: 0;
    margin: 0;
    color: inherit;
    cursor: pointer;
}

[x-cloak] { display: none !important; }

/* ---------- Animations ---------- */
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes spin-smooth {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
@keyframes pulse-glow {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.5; }
}
@keyframes slide-in-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes progress-fill {
    from { width: 0; }
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 2px solid rgba(124,58,237,0.2); border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin-smooth 0.8s linear infinite;
    will-change: transform;
    transform: translateZ(0);
    flex-shrink: 0;
}
.spinner-sm {
    width: 13px; height: 13px; border-width: 2px;
    border-color: rgba(255,255,255,0.25); border-top-color: #fff;
}
.animate-spin {
    animation: spin-smooth 0.8s linear infinite;
    will-change: transform;
    transform: translateZ(0);
}
.animate-pulse { animation: pulse-glow 1.5s ease-in-out infinite; }
.slide-in { animation: slide-in-up 0.25s ease-out; }

/* ---------- Theme Variables ---------- */
:root {
    --primary:        #7C3AED;
    --primary-dark:   #6D28D9;
    --primary-light:  #EDE9FE;
    --primary-xlight: #F5F3FF;
    --primary-deep:   #4C1D95;

    --header-bg:      #1E1035;
    --header-height:  64px;
    --sidebar-width:  220px;

    --success:        #10B981;
    --success-text:   #065F46;
    --success-bg:     #D1FAE5;
    --success-border: #6EE7B7;

    --danger:         #EF4444;
    --danger-text:    #991B1B;
    --danger-bg:      #FEE2E2;
    --danger-border:  #FCA5A5;

    --warning:        #F59E0B;
    --warning-text:   #92400E;
    --warning-bg:     #FEF3C7;
    --warning-border: #FDE68A;

    --info:           #3B82F6;
    --info-text:      #1E40AF;
    --info-bg:        #DBEAFE;
    --info-border:    #93C5FD;

    --text:           #111827;
    --text-secondary: #6B7280;
    --text-muted:     #9CA3AF;

    --bg-page:  #F4F6F9;
    --bg-card:  #FFFFFF;
    --bg-hover: #FAFAFA;

    --border:      #E5E7EB;
    --border-dark: #D1D5DB;

    --shadow-sm: 0 1px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

    --radius-sm:  6px;
    --radius:     10px;
    --radius-lg:  14px;
    --radius-pill: 20px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    background: var(--bg-page);
    color: var(--text);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
.app-header {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-height);
    background: var(--header-bg);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.header-left  { display: flex; align-items: center; gap: 12px; }
.header-right { display: flex; align-items: center; gap: 14px; font-size: 12px; color: rgba(255,255,255,0.6); }

.header-logo {
    display: flex; align-items: center; gap: 10px;
    font-size: 13px; font-weight: 600; color: #fff;
}
.header-divider { width: 1px; height: 22px; background: rgba(255,255,255,0.2); }
.header-app-name { font-size: 12px; opacity: 0.75; font-weight: 400; }

.org-badge {
    background: rgba(124,58,237,0.35);
    border: 1px solid rgba(124,58,237,0.5);
    color: #c4b5fd;
    font-size: 11px; font-weight: 600;
    padding: 3px 10px; border-radius: var(--radius-pill);
    letter-spacing: 0.3px;
}

.header-user  { font-size: 12px; color: rgba(255,255,255,0.85); font-weight: 500; }
.header-logout {
    color: rgba(255,255,255,0.5); font-size: 12px; text-decoration: none;
    padding: 4px 10px; border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-sm); transition: all 0.15s;
}
.header-logout:hover { color: #fff; border-color: rgba(255,255,255,0.4); text-decoration: none; }

.app-sidebar {
    position: fixed; left: 0; top: var(--header-height); bottom: 0;
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--border);
    padding: 16px 12px;
    z-index: 90;
    display: flex; flex-direction: column; gap: 2px;
    overflow-y: auto;
}

.sidebar-section-label {
    font-size: 9px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.08em; color: var(--text-muted);
    padding: 10px 12px 4px;
}

.sidebar-nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: var(--radius);
    font-size: 13px; font-weight: 500; color: var(--text-secondary);
    text-decoration: none; transition: all 0.15s;
    border: none; background: none; cursor: pointer;
    width: 100%; text-align: left;
    position: relative;
}
.sidebar-nav-item:hover { background: var(--bg-page); color: var(--text); text-decoration: none; }
.sidebar-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.sidebar-nav-item svg, .sidebar-nav-item i { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-badge {
    margin-left: auto;
    background: var(--primary);
    color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 5px;
}

.sidebar-footer {
    margin-top: auto; padding: 14px 12px 4px;
    border-top: 1px solid var(--border);
    font-size: 10px; color: var(--text-muted);
    line-height: 1.6;
}
.sidebar-footer strong { display: block; margin-bottom: 2px; font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; }

.app-main {
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    min-height: 100vh;
}
.main-content {
    padding: 24px 28px;
    max-width: 1400px;
}

/* ---------- Page Header ---------- */
.page-header { margin-bottom: 22px; }
.page-title  { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.page-subtitle { font-size: 13px; color: var(--text-secondary); }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 14px 18px 12px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title {
    font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--text-muted);
}
.card-body { padding: 18px; }

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px;
    margin-bottom: 18px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    text-align: center;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

/* ---------- Upload Zone ---------- */
.upload-zone {
    border: 2px dashed var(--border-dark);
    border-radius: var(--radius);
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-page);
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: var(--primary-xlight);
}
.upload-zone .upload-icon {
    width: 40px; height: 40px;
    margin: 0 auto 10px;
    color: var(--primary);
}
.upload-zone .upload-cta {
    font-size: 13px; font-weight: 500;
    color: var(--primary);
}
.upload-zone .upload-hint {
    font-size: 11px; color: var(--text-muted); margin-top: 4px;
}
.upload-zone .upload-filename {
    font-size: 12px; color: var(--text); font-weight: 500;
    margin-top: 8px; display: none;
}

/* ---------- Form Elements ---------- */
.form-group { margin-bottom: 14px; }
.form-label {
    display: block;
    font-size: 12px; font-weight: 600; color: var(--text);
    margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm);
    font-size: 13px; font-family: inherit; color: var(--text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    outline: none;
}
.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 18px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; font-family: inherit;
    cursor: pointer; transition: all 0.15s; border: none;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary {
    background: var(--primary); color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-outline {
    background: transparent; color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: var(--primary-xlight); }
.btn-ghost {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-page); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger-outline:hover { background: var(--danger-bg); }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-full { width: 100%; justify-content: center; }

/* ---------- Pipeline Steps ---------- */
.pipeline-track {
    display: flex; align-items: center; gap: 0;
    padding: 16px 0 12px;
}
.pipeline-step {
    display: flex; flex-direction: column; align-items: center;
    flex: 1; position: relative;
}
.pipeline-step:not(:last-child)::after {
    content: '';
    position: absolute; top: 14px; left: 50%; right: -50%;
    height: 2px; background: var(--border);
    z-index: 0;
}
.pipeline-step.done:not(:last-child)::after { background: var(--primary); }
.pipeline-step.active:not(:last-child)::after { background: linear-gradient(to right, var(--primary), var(--border)); }

.step-circle {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid var(--border);
    background: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    z-index: 1; transition: all 0.3s;
    position: relative;
}
.pipeline-step.done  .step-circle { border-color: var(--primary); background: var(--primary); color: #fff; }
.pipeline-step.active .step-circle { border-color: var(--primary); background: var(--primary-light); color: var(--primary); animation: pulse-glow 1.5s infinite; }
.pipeline-step.error  .step-circle { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

.step-label {
    font-size: 10px; font-weight: 500; color: var(--text-muted);
    margin-top: 6px; text-align: center; white-space: nowrap;
}
.pipeline-step.done  .step-label { color: var(--primary); font-weight: 600; }
.pipeline-step.active .step-label { color: var(--text); font-weight: 600; }

/* ---------- Log Output ---------- */
.log-output {
    background: #1a1035;
    color: #a78bfa;
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: 'SF Mono', SFMono-Regular, ui-monospace, monospace;
    font-size: 12px; line-height: 1.7;
    min-height: 90px; max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap; word-break: break-word;
}
.log-output .log-step-name { color: #c4b5fd; font-weight: 700; }
.log-output .log-ok   { color: #6ee7b7; }
.log-output .log-err  { color: #fca5a5; }
.log-output .log-skip { color: #fbbf24; }
.log-output .log-wait { color: var(--text-muted); }

/* ---------- Classification Results ---------- */
.classification-panel {
    display: flex; flex-direction: column; gap: 12px;
}
.classification-empty {
    text-align: center; padding: 32px 20px;
    color: var(--text-muted); font-size: 13px;
}
.classification-empty .empty-icon {
    width: 40px; height: 40px; margin: 0 auto 10px;
    color: var(--border-dark);
}
.class-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 12px; border-radius: var(--radius-pill);
    font-size: 12px; font-weight: 600;
    background: var(--primary-light); color: var(--primary);
    border: 1px solid rgba(124,58,237,0.2);
}
.confidence-bar-track {
    height: 6px; background: var(--border); border-radius: 3px; overflow: hidden;
}
.confidence-bar-fill {
    height: 100%; background: var(--primary); border-radius: 3px;
    animation: progress-fill 0.6s ease-out;
}

/* ---------- Table ---------- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted);
    padding: 10px 14px; background: var(--bg-page);
    border-bottom: 1px solid var(--border);
    text-align: left; white-space: nowrap;
}
.data-table td {
    padding: 12px 14px; font-size: 13px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg-hover); }

/* ---------- Status Badges ---------- */
.status-badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: var(--radius-pill);
    font-size: 11px; font-weight: 600; white-space: nowrap;
}
.status-badge.processing { background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-border); }
.status-badge.completed  { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.status-badge.auto_closed { background: #F3F4F6; color: #374151; border: 1px solid #D1D5DB; }
.status-badge.pending_review { background: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }
.status-badge.draft_ready { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(124,58,237,0.25); }
.status-badge.failed { background: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }

.status-dot {
    width: 6px; height: 6px; border-radius: 50%;
    display: inline-block; flex-shrink: 0;
}
.status-badge.processing  .status-dot { background: var(--info); }
.status-badge.completed   .status-dot { background: var(--success); }
.status-badge.auto_closed .status-dot { background: #6B7280; }
.status-badge.pending_review .status-dot { background: var(--warning); }
.status-badge.draft_ready  .status-dot { background: var(--primary); }
.status-badge.failed  .status-dot { background: var(--danger); }

/* ---------- Flash / Alerts ---------- */
.flash-error {
    background: var(--danger-bg); color: var(--danger-text);
    border: 1px solid var(--danger-border); border-radius: var(--radius);
    padding: 10px 14px; margin-bottom: 16px; font-size: 13px;
}
.alert {
    border-radius: var(--radius); padding: 12px 16px;
    font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
    margin-bottom: 14px;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.alert-error   { background: var(--danger-bg);  color: var(--danger-text);  border: 1px solid var(--danger-border); }
.alert-info    { background: var(--info-bg);     color: var(--info-text);    border: 1px solid var(--info-border); }
.alert-warning { background: var(--warning-bg);  color: var(--warning-text); border: 1px solid var(--warning-border); }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45);
    z-index: 200; display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.modal-box {
    background: #fff; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 600px; width: 100%;
    max-height: 90vh; overflow-y: auto;
    animation: slide-in-up 0.2s ease-out;
}
.modal-header {
    padding: 18px 22px 14px;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close {
    width: 28px; height: 28px; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted); cursor: pointer;
    transition: background 0.15s;
}
.modal-close:hover { background: var(--bg-page); color: var(--text); }
.modal-body { padding: 20px 22px; }
.modal-footer {
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    display: flex; gap: 10px; justify-content: flex-end;
}

/* ---------- Letter Preview ---------- */
.letter-preview {
    background: #fafafa; border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 24px;
    font-size: 13px; line-height: 1.8; white-space: pre-wrap;
    font-family: 'Georgia', serif; color: var(--text);
    min-height: 120px;
}

/* ---------- Login Page ---------- */
.login-page {
    background: #ffffff;
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.login-card {
    background: #fff; border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.4);
    width: 100%; max-width: 400px;
    padding: 24px;
    overflow: hidden;
}
.login-form { display: flex; flex-direction: column; gap: 14px; margin-top: 16px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-label { font-size: 12px; font-weight: 600; color: var(--text); }
.login-input {
    padding: 10px 13px; border: 1px solid var(--border-dark);
    border-radius: var(--radius-sm); font-size: 13px; font-family: inherit;
    outline: none; transition: border-color 0.15s, box-shadow 0.15s;
}
.login-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }
.login-submit-btn {
    background: var(--primary); color: #fff; border: none;
    padding: 11px; border-radius: var(--radius-sm);
    font-size: 14px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: background 0.15s;
    margin-top: 4px;
}
.login-submit-btn:hover { background: var(--primary-dark); }
.login-error {
    background: var(--danger-bg); color: var(--danger-text);
    border: 1px solid var(--danger-border); border-radius: var(--radius-sm);
    padding: 10px 13px; font-size: 13px; margin-bottom: 4px;
}
.login-azure-btn {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 11px; border: 1.5px solid var(--border-dark);
    border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
    color: var(--text); background: #fff; cursor: pointer;
    text-decoration: none; transition: all 0.15s;
}
.login-azure-btn:hover { border-color: var(--primary); background: var(--primary-xlight); text-decoration: none; }
.login-divider { display: flex; align-items: center; gap: 10px; margin: 14px 0 8px; }
.login-divider::before, .login-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login-divider-text { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

/* ---------- Analytics Charts ---------- */
.chart-container { position: relative; height: 220px; }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center; padding: 48px 24px; color: var(--text-muted);
}
.empty-state svg { margin: 0 auto 14px; opacity: 0.35; }
.empty-state p { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state small { font-size: 12px; }

/* ---------- Tile ---------- */
.tile {
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 10px 13px; background: var(--bg-page);
}
.tile-label { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 4px; }
.tile-value { font-size: 13px; font-weight: 600; color: var(--text); }
.tile-value-mono { font-size: 13px; font-weight: 600; font-family: 'SF Mono', SFMono-Regular, ui-monospace, monospace; }

/* ---------- Section Divider ---------- */
.section-divider { height: 1px; background: var(--border); margin: 20px 0; }
