/* IGP Dashboard Styles */

:root {
    --color-bg: #f8f9fa;
    --color-white: #ffffff;
    --color-text: #212529;
    --color-muted: #6c757d;
    --color-border: #dee2e6;
    --color-primary: #0d6efd;
    --color-primary-dark: #0a58ca;
    --color-red: #dc3545;
    --color-red-bg: #f8d7da;
    --color-yellow: #ffc107;
    --color-yellow-bg: #fff3cd;
    --color-green: #198754;
    --color-green-bg: #d1e7dd;
    --color-blue: #0dcaf0;
    --color-blue-bg: #cff4fc;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
}

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

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

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

/* Navbar */
.navbar {
    background: var(--color-text);
    color: var(--color-white);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}
.nav-brand a { color: var(--color-white); font-weight: 700; font-size: 1.1rem; }
.nav-brand a:hover { text-decoration: none; }
.nav-links { list-style: none; display: flex; gap: 1rem; }
.nav-links a { color: #adb5bd; padding: 0.25rem 0.5rem; border-radius: 4px; }
.nav-links a:hover { color: var(--color-white); text-decoration: none; }
.nav-links a.active { color: var(--color-white); background: rgba(255,255,255,0.15); }

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Flash messages */
.flash-messages { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.flash-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.5;
    padding: 0 0.25rem;
    line-height: 1;
    color: inherit;
}
.flash-close:hover { opacity: 1; }
.flash-success { background: var(--color-green-bg); border-color: var(--color-green); color: #0f5132; }
.flash-error { background: var(--color-red-bg); border-color: var(--color-red); color: #842029; }
.flash-warning { background: var(--color-yellow-bg); border-color: var(--color-yellow); color: #664d03; }
.flash-info { background: var(--color-blue-bg); border-color: var(--color-blue); color: #055160; }

/* Typography */
h1 { margin-bottom: 0.25rem; font-size: 1.75rem; }
h2 { margin-bottom: 0.75rem; font-size: 1.25rem; }
.subtitle { color: var(--color-muted); margin-bottom: 1.5rem; }
.text-muted { color: var(--color-muted); }
.text-red { color: var(--color-red); font-weight: 600; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
}
.stat-card.stat-alert { border-color: var(--color-red); background: var(--color-red-bg); }
.stat-card.stat-warn { border-color: var(--color-yellow); background: var(--color-yellow-bg); }
.stat-value { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--color-muted); font-size: 0.85rem; margin-top: 0.25rem; }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 1rem;
}
.table th, .table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}
.table th {
    background: #f1f3f5;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-muted);
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f8f9fa; }
.row-highlight { background: var(--color-yellow-bg) !important; }

/* Status badges */
.status-red { color: var(--color-red); font-weight: 600; }
.status-yellow { color: #b45309; font-weight: 600; }
.status-green { color: var(--color-green); font-weight: 600; }
.status-default { color: var(--color-muted); }

.badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-weight: 600;
}
.badge-red { background: var(--color-red-bg); color: var(--color-red); }
.badge-yellow { background: var(--color-yellow-bg); color: #b45309; }

/* Sections */
.section { margin-bottom: 2rem; }

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.filter-label { font-weight: 600; font-size: 0.85rem; color: var(--color-muted); }
.filter-sep { color: var(--color-border); margin: 0 0.5rem; }
.filter-link {
    font-size: 0.85rem;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    color: var(--color-muted);
}
.filter-link:hover { background: #e9ecef; text-decoration: none; color: var(--color-text); }
.filter-link.active { background: var(--color-primary); color: var(--color-white); }

/* Detail grid */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 0.5rem 1.5rem;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}
.detail-full { grid-column: 1 / -1; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}
.btn:hover { background: var(--color-primary-dark); text-decoration: none; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-green { background: var(--color-green); }
.btn-green:hover { background: #146c43; }

.inline-form { display: inline; }
.actions-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}
.form-group select,
.form-group textarea,
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group input[type="date"],
.form-group input[type="time"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.95rem;
}
.form-group textarea { font-family: var(--font-mono); font-size: 0.85rem; }
.form-group select:focus,
.form-group textarea:focus,
.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}
.form-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 700px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}
.btn-secondary {
    background: var(--color-muted);
    color: var(--color-white);
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}
.btn-secondary:hover { background: #5a6268; text-decoration: none; color: var(--color-white); }
.btn-red { background: var(--color-red); }
.btn-red:hover { background: #bb2d3b; }
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.page-header h1 { margin-bottom: 0; }

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--color-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--color-border);
    margin-top: 2rem;
}

/* Meeting Prep */
.prep-block {
    background: #f1f3f5;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}
.prep-block pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    margin: 0;
    line-height: 1.6;
}
.prep-rendered {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.5rem 2rem;
    line-height: 1.7;
}
.prep-rendered h1 { font-size: 1.5rem; margin: 0 0 1rem 0; border-bottom: 2px solid var(--color-primary); padding-bottom: 0.5rem; }
.prep-rendered h2 { font-size: 1.15rem; margin: 1.5rem 0 0.5rem 0; color: var(--color-primary); }
.prep-rendered h3 { font-size: 1rem; margin: 1rem 0 0.4rem 0; }
.prep-rendered ul, .prep-rendered ol { margin: 0.5rem 0 0.5rem 1.5rem; }
.prep-rendered li { margin-bottom: 0.3rem; }
.prep-rendered table { width: 100%; border-collapse: collapse; margin: 0.75rem 0; }
.prep-rendered th, .prep-rendered td { padding: 0.4rem 0.6rem; border: 1px solid var(--color-border); text-align: left; font-size: 0.9rem; }
.prep-rendered th { background: #f1f3f5; font-weight: 600; }
.prep-rendered code { background: #f1f3f5; padding: 0.15rem 0.4rem; border-radius: 3px; font-size: 0.85rem; }
.prep-rendered pre { background: #f1f3f5; padding: 1rem; border-radius: 6px; overflow-x: auto; margin: 0.75rem 0; }
.prep-rendered pre code { background: none; padding: 0; }
.prep-rendered p { margin: 0.5rem 0; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0.75rem; }
.timeline-entry {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: grid;
    grid-template-columns: 100px auto 1fr;
    grid-template-rows: auto auto;
    gap: 0.1rem 0.75rem;
    align-items: start;
}
.timeline-date {
    font-size: 0.85rem;
    color: var(--color-muted);
    grid-row: 1 / 3;
    padding-top: 0.15rem;
}
.timeline-type {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.5rem;
    border-radius: 10px;
    display: inline-block;
    width: fit-content;
}
.timeline-type-task { background: var(--color-blue-bg); color: #055160; }
.timeline-type-email { background: #e8daef; color: #6c3483; }
.timeline-type-meeting { background: var(--color-green-bg); color: #0f5132; }
.timeline-type-document { background: #fdebd0; color: #a04000; }
.timeline-type-activity { background: #d1f2eb; color: #0e6655; }
.timeline-title { font-weight: 600; grid-column: 3; }
.timeline-detail { font-size: 0.85rem; color: var(--color-muted); grid-column: 2 / 4; }

/* RAG Search */
.rag-controls {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}
.rag-search-form { margin-bottom: 0.75rem; }
.rag-search-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.rag-input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
}
.rag-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(13,110,253,0.15);
}
.rag-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.rag-option-label { font-size: 0.85rem; font-weight: 600; color: var(--color-muted); }
.rag-select {
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.85rem;
}
.rag-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}
.rag-results { display: flex; flex-direction: column; gap: 0.75rem; }
.rag-result {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
}
.rag-result-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}
.rag-result-rank { font-weight: 700; font-size: 1.1rem; color: var(--color-primary); }
.rag-result-score { font-size: 0.8rem; color: var(--color-muted); font-family: var(--font-mono); }
.rag-result-type { font-size: 0.7rem; }
.badge-guideline { background: var(--color-blue-bg); color: #055160; }
.badge-school { background: #fdebd0; color: #a04000; }
.badge-program { background: var(--color-green-bg); color: #0f5132; }
.rag-result-source { font-size: 0.85rem; color: var(--color-muted); margin-bottom: 0.5rem; }
.rag-result-text { font-size: 0.9rem; line-height: 1.6; white-space: pre-wrap; }
.rag-answer {
    border-left: 4px solid var(--color-primary);
    margin-bottom: 1.5rem;
}
.rag-sources-toggle {
    cursor: pointer;
    padding: 0.5rem 0;
    user-select: none;
}
.rag-sources-toggle:hover { opacity: 0.8; }
details summary::-webkit-details-marker { display: none; }
details summary::before { content: "▶ "; font-size: 0.8rem; }
details[open] summary::before { content: "▼ "; }

/* Triage Results */
.triage-results { display: flex; flex-direction: column; gap: 0.75rem; }
.triage-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
.triage-card-header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    background: #f1f3f5;
    border-bottom: 1px solid var(--color-border);
}
.triage-card-body { padding: 0.75rem 1rem; }
.triage-subject { font-weight: 600; margin-bottom: 0.3rem; }
.triage-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
}
.triage-summary { font-size: 0.9rem; margin-bottom: 0.4rem; }
.triage-action { font-size: 0.9rem; color: var(--color-muted); margin-bottom: 0.5rem; }
.triage-draft { margin-top: 0.5rem; }
.triage-draft summary {
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-primary);
    padding: 0.3rem 0;
    user-select: none;
}
.triage-draft summary:hover { opacity: 0.8; }
.triage-draft-content {
    background: #f8f9fa;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-top: 0.4rem;
    font-size: 0.9rem;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Priority badges */
.priority-high { background: var(--color-red-bg); color: var(--color-red); }
.priority-medium { background: var(--color-yellow-bg); color: #b45309; }
.priority-low { background: var(--color-green-bg); color: var(--color-green); }
.badge-category { background: #e8daef; color: #6c3483; }
.badge-action { background: var(--color-blue-bg); color: #055160; }
.badge-draft-saved { background: var(--color-green-bg); color: var(--color-green); }
.badge-draft-failed { background: var(--color-red-bg); color: var(--color-red); }

/* Reminder Preview */
.reminder-list { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.reminder-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
.reminder-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    background: #f1f3f5;
    border-bottom: 1px solid var(--color-border);
}
.reminder-card-body { padding: 0.75rem 1rem; }

/* Loading States */
@keyframes igp-spin {
    to { transform: rotate(360deg); }
}
.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: var(--color-white);
    border-radius: 50%;
    animation: igp-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 0.4rem;
}
.btn-loading {
    opacity: 0.7;
    pointer-events: none;
}
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.loading-overlay-content {
    background: var(--color-white);
    border-radius: 12px;
    padding: 2rem 2.5rem;
    text-align: center;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}
.loading-overlay-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: igp-spin 0.7s linear infinite;
    margin: 0 auto 1rem;
}
.loading-overlay-text {
    font-size: 1rem;
    color: var(--color-text);
    font-weight: 500;
}

/* Table scroll wrapper (for mobile) */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}
.table-responsive .table { margin-bottom: 0; }

/* Responsive */
/* Help page grid */
.help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}
.help-card {
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1.25rem;
}
.help-card h3 {
    margin: 0 0 0.75rem;
    font-size: 1.1rem;
    color: var(--color-primary);
}
.help-card ol, .help-card ul {
    margin: 0;
    padding-left: 1.25rem;
}
.help-card li {
    margin-bottom: 0.35rem;
    line-height: 1.5;
}
.help-card table {
    width: 100%;
    font-size: 0.9rem;
}
.help-card table td {
    padding: 0.25rem 0.5rem;
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
}
.help-card code {
    background: var(--color-bg);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.85em;
}

@media (max-width: 768px) {
    .navbar { flex-direction: column; gap: 0.5rem; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .detail-grid { grid-template-columns: 1fr; }
    .table { font-size: 0.85rem; }
    .table th, .table td { padding: 0.4rem 0.5rem; }
    .filters { flex-direction: column; align-items: flex-start; }
    .form-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

/* Collapsible sections */
.section-toggle {
    cursor: pointer;
    user-select: none;
}
.section-toggle:hover {
    opacity: 0.8;
}
.toggle-icon {
    font-size: 0.75em;
    color: var(--color-muted);
    margin-left: 0.25rem;
}
