/* ===================================================================
   Log Analyzer AI -- Dark DevOps / Terminal Theme
   Green-on-dark, monospace, SRE aesthetic
   =================================================================== */

/* --- CSS Custom Properties --- */
:root {
    --bg-primary: #0a0e14;
    --bg-secondary: #101820;
    --bg-tertiary: #151d27;
    --bg-card: #1a2332;
    --bg-card-hover: #1e2a3a;
    --bg-input: #0d1117;
    --bg-code: #0b1018;

    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #565e68;
    --text-accent: #39d353;

    --green-primary: #39d353;
    --green-dim: #238636;
    --green-glow: rgba(57, 211, 83, 0.15);
    --green-bright: #56d364;

    --red-primary: #f85149;
    --red-dim: #da3633;
    --red-glow: rgba(248, 81, 73, 0.15);

    --orange-primary: #d29922;
    --orange-dim: #9e6a03;
    --orange-glow: rgba(210, 153, 34, 0.15);

    --blue-primary: #58a6ff;
    --blue-dim: #1f6feb;
    --blue-glow: rgba(88, 166, 255, 0.15);

    --purple-primary: #bc8cff;
    --purple-dim: #8957e5;

    --border-primary: #21262d;
    --border-accent: #30363d;

    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px var(--green-glow);

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    --transition: all 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-mono);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

a { color: var(--green-primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--green-bright); }

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Navigation --- */
.nav-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand { display: flex; align-items: center; gap: 10px; }

.nav-icon {
    font-size: 1.4rem;
    color: var(--green-primary);
    font-weight: 700;
    text-shadow: 0 0 10px var(--green-glow);
}

.nav-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.nav-links { display: flex; gap: 4px; }

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: var(--transition);
    font-family: var(--font-mono);
}

.nav-link:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.nav-link.active { color: var(--green-primary); background: var(--green-glow); }

.nav-status { display: flex; align-items: center; gap: 8px; }

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green-primary);
    box-shadow: 0 0 6px var(--green-primary);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.status-text { font-size: 0.8rem; color: var(--text-secondary); }

/* --- Main Content --- */
.main-content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    transition: var(--transition);
}

.card:hover { border-color: var(--border-accent); box-shadow: var(--shadow-md); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    font-family: var(--font-sans);
}

.card-subtitle { font-size: 0.85rem; color: var(--text-secondary); }

/* --- Grid Layout --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 1024px) {
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
}

/* --- Stat Cards --- */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover { border-color: var(--green-dim); box-shadow: var(--shadow-glow); }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--green-primary); }
.stat-card .stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }

.stat-card.critical .stat-value { color: var(--red-primary); }
.stat-card.warning .stat-value { color: var(--orange-primary); }
.stat-card.info .stat-value { color: var(--blue-primary); }

/* --- Buttons --- */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-accent);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:hover { background: var(--bg-card-hover); border-color: var(--text-muted); }

.btn-primary {
    background: var(--green-dim);
    border-color: var(--green-primary);
    color: #fff;
}

.btn-primary:hover { background: var(--green-primary); color: var(--bg-primary); }

.btn-danger { background: var(--red-dim); border-color: var(--red-primary); color: #fff; }
.btn-danger:hover { background: var(--red-primary); }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }

/* --- Upload Area --- */
.upload-area {
    border: 2px dashed var(--border-accent);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: var(--bg-tertiary);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--green-primary);
    background: var(--green-glow);
    box-shadow: var(--shadow-glow);
}

.upload-icon { font-size: 3rem; color: var(--green-dim); margin-bottom: 16px; }
.upload-text { font-size: 1rem; color: var(--text-secondary); }
.upload-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 8px; }

/* --- Textarea --- */
.log-textarea {
    width: 100%;
    min-height: 200px;
    background: var(--bg-code);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    padding: 16px;
    resize: vertical;
    line-height: 1.5;
}

.log-textarea:focus { outline: none; border-color: var(--green-dim); box-shadow: var(--shadow-glow); }
.log-textarea::placeholder { color: var(--text-muted); }

/* --- Input --- */
.input-field {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.input-field:focus { outline: none; border-color: var(--green-dim); }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }

/* --- Severity Badges --- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.badge-critical { background: var(--red-glow); color: var(--red-primary); border: 1px solid var(--red-dim); }
.badge-high { background: var(--orange-glow); color: var(--orange-primary); border: 1px solid var(--orange-dim); }
.badge-medium { background: var(--blue-glow); color: var(--blue-primary); border: 1px solid var(--blue-dim); }
.badge-low { background: var(--green-glow); color: var(--green-primary); border: 1px solid var(--green-dim); }
.badge-spike { background: rgba(188, 140, 255, 0.15); color: var(--purple-primary); border: 1px solid var(--purple-dim); }

/* --- Tables --- */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.data-table th { text-align: left; padding: 10px 12px; color: var(--text-secondary); border-bottom: 2px solid var(--border-accent); text-transform: uppercase; font-size: 0.75rem; letter-spacing: 1px; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-primary); vertical-align: top; }
.data-table tr:hover td { background: var(--bg-tertiary); }
.data-table .mono { font-family: var(--font-mono); font-size: 0.8rem; }
.data-table .truncate { max-width: 400px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Log viewer --- */
.log-viewer {
    background: var(--bg-code);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
    font-size: 0.8rem;
    line-height: 1.7;
}

.log-line { display: flex; gap: 12px; padding: 2px 0; }
.log-line:hover { background: var(--bg-tertiary); }
.log-line-num { color: var(--text-muted); min-width: 40px; text-align: right; user-select: none; }
.log-line-level { min-width: 60px; font-weight: 600; }
.log-line-level.error { color: var(--red-primary); }
.log-line-level.warn { color: var(--orange-primary); }
.log-line-level.info { color: var(--green-primary); }
.log-line-level.debug { color: var(--text-muted); }
.log-line-msg { color: var(--text-primary); word-break: break-all; }

/* --- AI Summary Box --- */
.ai-summary-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--green-dim);
    border-left: 4px solid var(--green-primary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin: 16px 0;
}

.ai-summary-box .ai-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--green-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    font-weight: 600;
}

.ai-summary-box .ai-content { color: var(--text-primary); font-size: 0.9rem; line-height: 1.8; white-space: pre-wrap; }

/* --- Timeline Chart --- */
.timeline-chart {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 10px 0;
}

.timeline-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-width: 6px;
    border-radius: 2px 2px 0 0;
    position: relative;
    cursor: pointer;
}

.timeline-bar:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    white-space: nowrap;
    border: 1px solid var(--border-accent);
    z-index: 10;
}

.bar-error { background: var(--red-primary); }
.bar-warn { background: var(--orange-primary); }
.bar-info { background: var(--green-dim); }
.bar-debug { background: var(--text-muted); opacity: 0.5; }

/* --- Loading Spinner --- */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-accent);
    border-top: 3px solid var(--green-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    gap: 16px;
    color: var(--text-secondary);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state .empty-text { font-size: 1rem; }

/* --- Report List --- */
.report-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: var(--transition);
}

.report-item:hover { border-color: var(--green-dim); background: var(--bg-card-hover); }

.report-item .report-info { display: flex; flex-direction: column; gap: 4px; }
.report-item .report-title { font-weight: 600; color: var(--text-primary); }
.report-item .report-meta { font-size: 0.8rem; color: var(--text-secondary); }
.report-item .report-stats { display: flex; gap: 12px; align-items: center; }

/* --- Tabs --- */
.tab-bar { display: flex; gap: 2px; border-bottom: 2px solid var(--border-primary); margin-bottom: 20px; }
.tab-btn { padding: 10px 20px; background: none; border: none; color: var(--text-secondary); font-family: var(--font-mono); font-size: 0.85rem; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition); }
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--green-primary); border-bottom-color: var(--green-primary); }

/* --- Severity Bar Chart --- */
.severity-bar { display: flex; height: 24px; border-radius: var(--radius-sm); overflow: hidden; margin: 8px 0; }
.severity-segment { height: 100%; transition: var(--transition); }
.severity-segment:hover { opacity: 0.8; }

/* --- Footer --- */
.footer {
    padding: 16px 24px;
    text-align: center;
    border-top: 1px solid var(--border-primary);
    color: var(--text-muted);
    font-size: 0.8rem;
    background: var(--bg-secondary);
}

.footer-content { display: flex; align-items: center; justify-content: center; gap: 8px; }
.footer-sep { color: var(--border-accent); }

/* --- Section Headers --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title { font-size: 1.3rem; font-weight: 700; font-family: var(--font-sans); }
.section-subtitle { font-size: 0.9rem; color: var(--text-secondary); }

/* --- Separator --- */
.divider { height: 1px; background: var(--border-primary); margin: 24px 0; }

/* --- Notification / Toast --- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green-dim); }
.toast.error { border-color: var(--red-dim); }
