/*
 * Internal app (coordinator UI) styles. Consumes brand tokens from rightflo.css.
 * Portal pages use portal.css instead; these styles target the sidebar/topbar layout.
 */

body { background: var(--gray-50); }

.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    grid-template-rows: 64px 1fr;
    grid-template-areas:
        "sidebar topbar"
        "sidebar main";
    min-height: 100vh;
}

.app-sidebar {
    grid-area: sidebar;
    background: var(--navy);
    color: var(--white);
    padding: 1.25rem 0;
    position: sticky; top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-sidebar .brand {
    padding: 0 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 1rem;
}

.app-sidebar .brand img {
    height: 48px;
}

.app-sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
}
.app-sidebar nav a:hover { background: rgba(255,255,255,0.04); color: var(--white); }
.app-sidebar nav a.active {
    background: rgba(37,99,235,0.15);
    color: var(--white);
    border-left: 3px solid var(--blue);
    padding-left: calc(1.25rem - 3px);
}
.app-sidebar nav a.disabled { opacity: 0.45; cursor: not-allowed; }

.app-topbar {
    grid-area: topbar;
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.app-topbar h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.4rem;
    margin: 0;
    letter-spacing: -0.02em;
}
.topbar-user {
    display: flex; align-items: center; gap: 0.75rem;
    font-size: 0.85rem; color: var(--gray-600);
}
.topbar-user .avatar {
    width: 32px; height: 32px;
    background: var(--blue); color: var(--white);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem;
}

.app-main {
    grid-area: main;
    padding: 1.75rem 2rem;
}

/* ============ Card / Panel ============ */
.panel {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(11,29,58,0.03);
}
.panel + .panel { margin-top: 1.25rem; }
.panel-head {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex; align-items: center; justify-content: space-between;
}
.panel-head h2 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.1rem; margin: 0; color: var(--navy); letter-spacing: -0.01em;
}
.panel-body { padding: 1.25rem 1.5rem; }
.panel-body.flush { padding: 0; }

/* ============ Table ============ */
.queue-table {
    width: 100%;
    border-collapse: separate; border-spacing: 0;
    font-size: 0.88rem;
}
.queue-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    color: var(--gray-600);
    font-weight: 600; font-size: 0.78rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--gray-200);
}
.queue-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--navy);
    vertical-align: middle;
}
.queue-table tr:hover td { background: var(--gray-50); }
.queue-table a.tracking { color: var(--blue); font-weight: 600; text-decoration: none; }
.queue-table a.tracking:hover { text-decoration: underline; }

/* ============ Status pills ============ */
.status-pills { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.pill {
    padding: 0.35rem 0.85rem;
    border-radius: 50px;
    border: 1px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-600);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}
.pill:hover { border-color: var(--blue); color: var(--navy); }
.pill.active { background: var(--blue); color: var(--white); border-color: var(--blue); }

/* ============ Chips ============ */
.chip {
    display: inline-block;
    padding: 0.15rem 0.65rem;
    border-radius: 50px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.chip-urg-urgent { background: #FEE2E2; color: #991B1B; }
.chip-urg-soon { background: #FEF3C7; color: #92400E; }
.chip-urg-routine { background: #E0F2FE; color: #075985; }

.chip-status { background: var(--gray-100); color: var(--gray-700); }
.chip-status-received { background: #E0F2FE; color: #075985; }
.chip-status-intriage { background: #FEF3C7; color: #92400E; }
.chip-status-moreinforequested { background: #FEF3C7; color: #92400E; }
.chip-status-accepted { background: #DCFCE7; color: #166534; }
.chip-status-contactingpatient { background: #DBEAFE; color: #1E40AF; }
.chip-status-scheduled { background: #DBEAFE; color: #1E40AF; }
.chip-status-visitcompleted { background: #E0E7FF; color: #3730A3; }
.chip-status-reportsent { background: #E0E7FF; color: #3730A3; }
.chip-status-loopclosed { background: var(--gray-200); color: var(--gray-700); }
.chip-status-rejected, .chip-status-cancelled { background: #FEE2E2; color: #991B1B; }

.chip-sla-healthy { background: #DCFCE7; color: #166534; }
.chip-sla-approaching { background: #FEF3C7; color: #92400E; }
.chip-sla-breached { background: #FEE2E2; color: #991B1B; }
.chip-sla-notapplicable { background: var(--gray-100); color: var(--gray-500); }

/* ============ Filters ============ */
.filter-bar {
    display: flex; flex-wrap: wrap; gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-100);
    align-items: center;
}
.filter-bar input,
.filter-bar select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.85rem;
    background: var(--white);
    color: var(--navy);
}
.filter-bar input[type="search"] { min-width: 220px; }

/* ============ Buttons (internal) ============ */
.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    padding: 0.55rem 1.1rem;
    border-radius: 8px;
    font-family: inherit; font-weight: 600; font-size: 0.88rem;
    border: none; cursor: pointer;
    text-decoration: none; transition: all 0.15s;
}
.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { filter: brightness(0.95); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }
.btn-outline { background: transparent; border: 1.5px solid var(--gray-300); color: var(--navy); }
.btn-outline:hover { border-color: var(--navy); }
.btn-danger { background: #DC2626; color: var(--white); }
.btn-danger:hover { filter: brightness(0.95); }
.btn-sm { padding: 0.4rem 0.9rem; font-size: 0.8rem; }

/* ============ Detail view ============ */
.detail-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.25rem;
}
.detail-head h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 1.75rem; margin: 0 0 0.25rem; color: var(--navy);
}
.detail-head .meta { color: var(--gray-500); font-size: 0.88rem; }

.detail-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
}
@media (max-width: 960px) {
    .detail-grid { grid-template-columns: 1fr; }
    .app-shell { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
    .app-sidebar { display: none; }
}

/* ============ Tabs ============ */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--gray-200); margin-bottom: 1rem; }
.tabs button {
    background: none; border: none; cursor: pointer;
    padding: 0.75rem 1rem;
    font-family: inherit; font-size: 0.9rem; font-weight: 500;
    color: var(--gray-500);
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}
.tabs button.active { color: var(--navy); border-bottom-color: var(--blue); }
.tabs button:hover:not(.active) { color: var(--navy); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Triage panel form fields */
.tp-row { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.9rem; }
.tp-row label { font-size: 0.8rem; font-weight: 600; color: var(--navy); }
.tp-row select,
.tp-row input,
.tp-row textarea {
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-family: inherit; font-size: 0.88rem;
    background: var(--white); color: var(--navy);
}

.timeline-rail {
    display: flex; align-items: center; gap: 0.25rem; flex-wrap: wrap;
    margin: 0.5rem 0 1rem;
}
.timeline-rail .step {
    padding: 0.3rem 0.65rem;
    border-radius: 50px;
    font-size: 0.7rem; font-weight: 600;
    background: var(--gray-100); color: var(--gray-500);
    position: relative;
}
.timeline-rail .step.done { background: var(--mint); color: var(--green); }
.timeline-rail .step.current { background: var(--blue); color: var(--white); }

.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.6rem 1.25rem; font-size: 0.88rem; }
.info-grid .full { grid-column: 1 / -1; }
.info-grid dt { color: var(--gray-500); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
.info-grid dd { color: var(--navy); margin: 0 0 0.5rem; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 0.75rem; font-size: 0.88rem; }
.alert-error { background: #FEE2E2; color: #991B1B; border: 1px solid #FECACA; }
.alert-success { background: #DCFCE7; color: #166534; border: 1px solid #BBF7D0; }
.muted { color: var(--gray-500); font-size: 0.85rem; }

/* ============ Notification bell + dropdown ============ */
.notif-wrap { position: relative; }
.notif-bell {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gray-600);
    padding: 0.4rem;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    position: relative;
    transition: background 0.15s, color 0.15s;
}
.notif-bell:hover { background: var(--gray-100); color: var(--navy); }
.notif-badge {
    position: absolute;
    top: -2px; right: -2px;
    min-width: 18px; height: 18px;
    padding: 0 4px;
    background: #DC2626; color: var(--white);
    border-radius: 50px;
    font-size: 0.65rem; font-weight: 700;
    line-height: 18px; text-align: center;
    border: 2px solid var(--white);
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + 6px); right: 0;
    width: 360px;
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(11,29,58,0.12);
    display: none;
    z-index: 40;
}
.notif-dropdown.open { display: block; }
.notif-dropdown-head {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    display: flex; justify-content: space-between; align-items: center;
}
.dropdown-notif {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: background 0.15s;
}
.dropdown-notif:hover { background: var(--gray-50); }
.dropdown-notif.unread { background: rgba(37,99,235,0.04); }
.dropdown-notif:last-child { border-bottom: none; }
