/* Copyright (c) 2025. Jericho Crosby (Chalwk) */

:root {
    --bg-1: #f8fafc;
    --panel: #ffffff;
    --muted: #64748b;
    --accent: #4f46e5;
    --accent-600: #4338ca;
    --surface-2: #f1f5f9;
    --text: #0f172a;
    --radius: 12px;
    --gap: 16px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --btn-padding: 12px 18px;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 16px;
    line-height: 1.5;
}

/* Reset */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--bg-1);
    color: var(--text);
    padding-bottom: 48px;
}

/* container */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }

/* accessibility */
.sr-only {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Skip link */
.skip {
    position: absolute; left: -999px; top: auto; width: 1px; height: 1px;
}
.skip:focus {
    left: 16px; top: 16px; width: auto; height: auto; padding: 8px 10px;
    background: #fff; border-radius: 6px; box-shadow: var(--shadow);
    z-index: 100;
}

/* Header */
.site-header {
    padding: 16px 0;
    background: #fff;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.brand { display:flex; align-items:center; gap:12px; }
.logo { border-radius:8px; flex-shrink:0; }
.title-wrap h1 { margin:0; font-size:1.25rem; letter-spacing: -0.2px; font-weight: 700; }
.tagline { margin:4px 0 0; color:var(--muted); font-size:0.9rem; }

/* header actions */
.header-actions { display:flex; gap:8px; align-items:center; }
.btn {
    appearance:none;
    border: 1px solid #e2e8f0;
    background:#fff;
    padding: var(--btn-padding);
    border-radius:8px;
    cursor:pointer;
    font-weight:600;
    font-size:0.95rem;
    min-height:44px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}
.btn.ghost { background: transparent; border-color:transparent; color:var(--accent); padding:8px; }
.btn.ghost:hover {
    background: rgba(79, 70, 229, 0.05);
}
.btn.primary {
    background: var(--accent);
    color:#fff;
    border-color:transparent;
    box-shadow: 0 1px 2px 0 rgba(79, 70, 229, 0.3);
}
.btn.primary:hover {
    background: var(--accent-600);
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
}
.btn.btn-secondary {
    background: #f1f5f9;
    color: #334155;
    border: 1px solid #e2e8f0;
}
.btn.btn-secondary:hover {
    background: #e2e8f0;
}
.btn.small { padding:8px 12px; min-height:36px; font-size:0.85rem; }

/* Layout grid - mobile-first */
.app-grid {
    display:grid;
    grid-template-columns: 1fr;
    gap: 20px;
    margin-top: 24px;
}

/* Larger screens: two-column */
@media (min-width: 900px) {
    .app-grid {
        grid-template-columns: 1fr 420px;
        align-items:start;
    }
    /* Make history full width below panels */
    .panel-bottom { grid-column: 1 / -1; }
}

/* Panels */
.panel {
    background: var(--panel);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    border: 1px solid #f1f5f9;
    transition: box-shadow 0.2s ease;
}
.panel:hover {
    box-shadow: var(--shadow-lg);
}

/* Panel header */
.panel-head { margin-bottom: 16px; }
.panel-head h2 { margin: 0 0 8px; font-size: 1.25rem; font-weight: 700; }
.panel-head .small { margin:0; color:var(--muted); font-size:0.9rem; }

/* Controls */
.controls-row { display:flex; gap:12px; align-items:center; margin-bottom:16px; flex-wrap:wrap; }
.search-wrap { flex:1; min-width:0; display:block; }
#search {
    width:100%;
    padding:12px 16px;
    border-radius:8px;
    border:1px solid #e2e8f0;
    outline:none;
    font-size:0.95rem;
    background: #fff;
    transition: all 0.2s ease;
}
#search:focus {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    border-color:var(--accent);
}

/* Symptom list */
.symptom-list {
    display:grid;
    grid-template-columns: repeat(1, minmax(0,1fr));
    gap:12px;
    max-height: 420px;
    overflow-y:auto;
    padding: 8px;
    margin-bottom: 16px;
}
@media (min-width:700px) {
    .symptom-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
.symptom {
    display:flex;
    gap:12px;
    align-items:flex-start;
    padding:16px;
    border-radius:10px;
    border:1px solid #f1f5f9;
    background: #fff;
    transition: all 0.2s ease;
    cursor: pointer;
}
.symptom:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: rgba(79, 70, 229, 0.2);
}
.symptom.selected {
    border-color: var(--accent);
    background: rgba(79, 70, 229, 0.03);
}
.symptom-left { display:flex; align-items:center; gap:12px; }
.symptom label { font-size:0.95rem; cursor:pointer; font-weight: 500; }
.symptom small { display:block; color:var(--muted); margin-top:6px; font-size:0.85rem; }
.intensity {
    margin-left:auto;
    min-width:110px;
    padding:8px 12px;
    border-radius:8px;
    border:1px solid #e2e8f0;
    background: #fff;
    transition: all 0.2s ease;
}
.intensity:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Actions */
.actions-row { display:flex; gap:12px; margin-top:16px; flex-wrap:wrap; }
.export-actions { display:flex; gap:12px; flex-wrap:wrap; }

/* Suggestions / results */
.result-summary {
    margin-bottom:16px;
    color:var(--muted);
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border-left: 4px solid var(--accent);
}
.suggestions { display:flex; flex-direction:column; gap:16px; margin-bottom:16px; }
.suggestion {
    border-radius:10px;
    padding:20px;
    border:1px solid rgba(79, 70, 229, 0.1);
    background: #fff;
    transition: all 0.2s ease;
}
.suggestion:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.suggestion h3 { margin:0 0 12px; display:flex; gap:8px; align-items:center; }
.percent-badge {
    margin-left:auto;
    padding:6px 12px;
    border-radius:999px;
    background: rgba(79, 70, 229, 0.1);
    color:var(--accent);
    font-weight:700;
    font-size: 0.85rem;
}
.taglist { display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
.tag {
    font-size:0.85rem;
    padding:6px 10px;
    background:#eef2ff;
    border-radius:6px;
    color:var(--accent);
    font-weight: 500;
    transition: all 0.2s ease;
}
.tag:hover {
    background: #e0e7ff;
    transform: translateY(-1px);
}

/* Strategies list */
.strategies { list-style:none; padding:0; margin:12px 0 0; display:block; }
.strategy {
    display:flex;
    align-items:flex-start;
    gap:12px;
    margin-bottom:12px;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.2s ease;
}
.strategy:hover {
    background: #f8fafc;
}
.strategy button.copy {
    padding:8px 12px;
    border-radius:6px;
    font-weight:600;
    min-width:70px;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

/* Pattern insights */
.pattern-insights {
    margin-top:16px;
    padding:16px;
    background:var(--surface-2);
    border-radius:10px;
    border: 1px solid #e2e8f0;
}
.pattern-item {
    padding:16px;
    background:#fff;
    border-radius:8px;
    border-left:4px solid var(--accent);
    margin-bottom:12px;
    transition: all 0.2s ease;
}
.pattern-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

/* History */
.history-list {
    display:flex;
    flex-direction:column;
    gap:12px;
    margin-top:16px;
    max-height:360px;
    overflow:auto;
    padding:8px;
}
.hist-item {
    display:flex;
    gap:16px;
    align-items:center;
    justify-content:space-between;
    padding:16px;
    border-radius:10px;
    border:1px solid #f1f5f9;
    background:#fff;
    transition: all 0.2s ease;
}
.hist-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.hist-left { font-size:0.95rem; }
.hist-tags { display:flex; gap:8px; flex-wrap:wrap; margin-top:8px; }
.hist-metadata { font-size:0.9rem; color:var(--muted); text-align:right; min-width:180px; }

/* Charts */
.charts { display:flex; flex-direction:column; gap:20px; margin-top:20px; }
@media (min-width:900px) { .charts { flex-direction:row; } }
.chart-wrap {
    flex:1;
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    box-shadow: var(--shadow);
    border: 1px solid #f1f5f9;
}
canvas { width:100%; height:auto; border-radius:8px; background:#fff; }

/* Dialogs */
dialog {
    border:none;
    border-radius:12px;
    padding:0;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 90vw;
    width: 500px;
}
.dialog-form { padding:24px; display:flex; flex-direction:column; gap:16px; }
.dialog-actions { display:flex; gap:12px; justify-content:flex-end; }

/* Footer */
.site-footer {
    padding:20px 0;
    margin-top:40px;
    color:var(--muted);
    background: #fff;
    border-top: 1px solid #f1f5f9;
}
.footer-inner { display:flex; justify-content:space-between; align-items:center; gap:12px; }

/* Utilities */
.muted { color:var(--muted); }
.small { font-size:0.9rem; color:var(--muted); }
.row-between { display:flex; justify-content:space-between; align-items:center; gap:12px; }

/* Animations */
@keyframes fadeIn { from { opacity:0; transform: translateY(8px);} to { opacity:1; transform:none; } }
.fade-in { animation: fadeIn 0.3s ease both; }

/* touch targets */
@media (hover: none) {
    .btn { min-height:48px; padding:14px 16px; }
    .symptom { padding: 18px; }
}

/* small screens tweak */
@media (max-width:480px) {
    .container { padding: 12px; }
    .header-inner { flex-direction: column; align-items: flex-start; gap: 12px; }
    .header-actions { align-self: flex-end; }
    .panel { padding: 16px; }
    .symptom { padding: 14px; }
    .hist-item { flex-direction: column; align-items: flex-start; }
    .hist-metadata { text-align: left; width: 100%; }
    .export-actions { flex-direction: column; width: 100%; }
    .export-actions .btn { width: 100%; }
    .charts { gap: 16px; }
    .chart-wrap { padding: 12px; }
}

/* Loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Focus styles for accessibility */
button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}