/**
 * ASTRA v1.0 - Dashboard Pro Dark Theme
 * Stile Adobe After Effects - Grigi scuri con accenti viola/azzurro
 */

/* ============================================
   CSS Variables - Adobe AE Color Palette
   ============================================ */
:root {
    /* Background tones */
    --bg-darkest: #1a1a1a;
    --bg-darker: #232323;
    --bg-dark: #2d2d2d;
    --bg-medium: #383838;
    --bg-light: #444444;

    /* Accent colors - Adobe style */
    --accent-primary: #00d4ff;      /* Cyan */
    --accent-secondary: #9d4edd;    /* Purple */
    --accent-tertiary: #7b2cbf;     /* Deep purple */
    --accent-gold: #ffd700;         /* Gold for ASTRA branding */

    /* Status colors */
    --status-success: #00c853;
    --status-warning: #ffab00;
    --status-error: #ff5252;
    --status-info: #00b0ff;

    /* Text colors */
    --text-primary: #e0e0e0;
    --text-secondary: #9e9e9e;
    --text-muted: #616161;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.12);
    --border-accent: rgba(0, 212, 255, 0.3);

    /* Shadows */
    --shadow-glow: 0 0 20px rgba(0, 212, 255, 0.15);
    --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.4);

    /* Chart colors */
    --chart-gpu: #00d4ff;
    --chart-cpu: #9d4edd;
    --chart-ram: #00c853;
    --chart-vram: #ffab00;
}

/* ============================================
   Base Styles
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background: #0a0a1a !important;
}

body {
    font-family: 'Space Grotesk', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0a0a1a;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Scrollbar - Adobe style */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

/* ============================================
   Layout
   ============================================ */
.dashboard-container {
    display: grid;
    grid-template-columns: 1fr 320px;
    grid-template-rows: auto 1fr;
    gap: 0;
    min-height: 100vh;
}

/* ============================================
   Header
   ============================================ */
.header {
    grid-column: 1 / -1;
    background: rgba(10, 10, 20, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon-img {
    height: 36px;
    width: auto;
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.5));
}

.logo-text-img {
    height: 28px;
    width: auto;
    filter: drop-shadow(0 0 6px rgba(0, 96, 255, 0.4));
}

.logo-icon {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 8px rgba(0, 212, 255, 0.5));
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-text span {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

.header-center {
    display: flex;
    align-items: center;
    gap: 24px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Status Badges */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.active {
    border-color: var(--status-success);
    background: rgba(0, 200, 83, 0.1);
}

.status-badge.warning {
    border-color: var(--status-warning);
    background: rgba(255, 171, 0, 0.1);
}

.status-badge.inactive {
    border-color: var(--text-muted);
    background: transparent;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-dot.green { background: var(--status-success); }
.status-dot.yellow { background: var(--status-warning); }
.status-dot.red { background: var(--status-error); }
.status-dot.blue { background: var(--status-info); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   Main Content Area
   ============================================ */
.main-content {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================================
   Cards
   ============================================ */
.card {
    background: rgba(18, 18, 42, 0.52);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(13, 13, 26, 0.48);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-title svg {
    width: 16px;
    height: 16px;
    color: var(--accent-primary);
}

.card-body {
    padding: 16px;
}

/* ============================================
   Monitoring Grid
   ============================================ */
.monitoring-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.metric-card {
    background: rgba(18, 18, 42, 0.52);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}

.metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.metric-card.gpu::before { background: var(--chart-gpu); }
.metric-card.cpu::before { background: var(--chart-cpu); }
.metric-card.ram::before { background: var(--chart-ram); }
.metric-card.vram::before { background: var(--chart-vram); }

.metric-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.metric-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-icon {
    width: 20px;
    height: 20px;
    opacity: 0.6;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 8px;
}

.metric-card.gpu .metric-value { color: var(--chart-gpu); }
.metric-card.cpu .metric-value { color: var(--chart-cpu); }
.metric-card.ram .metric-value { color: var(--chart-ram); }
.metric-card.vram .metric-value { color: var(--chart-vram); }

.metric-subtext {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.metric-bar {
    height: 4px;
    background: var(--bg-medium);
    border-radius: 2px;
    margin-top: 12px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.5s ease;
}

.metric-card.gpu .metric-bar-fill { background: var(--chart-gpu); }
.metric-card.cpu .metric-bar-fill { background: var(--chart-cpu); }
.metric-card.ram .metric-bar-fill { background: var(--chart-ram); }
.metric-card.vram .metric-bar-fill { background: var(--chart-vram); }

/* ============================================
   Charts Section - Compatto
   ============================================ */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.charts-row .card {
    /* Grafici più compatti */
}

.charts-row .card-header {
    padding: 8px 12px;
}

.charts-row .card-body {
    padding: 8px 12px;
}

.chart-container {
    height: 120px;  /* Ridotto da 200px */
    position: relative;
}

/* ============================================
   Vision Console - ESPANSA per leggibilità testi
   ============================================ */
.vision-console {
    background: var(--bg-darkest);
    border: 2px solid var(--border-accent);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 15px rgba(0, 212, 255, 0.1);
}

.vision-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(90deg, rgba(0, 212, 255, 0.15), transparent);
    border-bottom: 1px solid var(--border-accent);
}

.vision-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.vision-stats {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.vision-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.vision-stat strong {
    color: var(--accent-primary);
}

.vision-content {
    padding: 16px 20px;
    min-height: 200px;
    max-height: 350px;  /* Aumentato da 150px */
    overflow-y: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;  /* Aumentato da 0.75rem */
    line-height: 1.7;    /* Aumentato da 1.5 */
    color: var(--text-primary);  /* Più leggibile */
    white-space: pre-wrap;
    background: rgba(0, 0, 0, 0.2);
}

.vision-content.empty {
    color: var(--text-muted);
    font-style: italic;
    min-height: 80px;
}

.vision-content .code-detected {
    color: var(--accent-secondary);
}

/* ============================================
   Query Section - Layout VERTICALE per testi lunghi
   ============================================ */
.query-section {
    display: flex;
    flex-direction: column;  /* Verticale invece che affiancato */
    gap: 16px;
}

.query-input-wrapper {
    position: relative;
}

.query-input {
    width: 100%;
    height: 100px;  /* Ridotto leggermente perché ora è full-width */
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.95rem;
    resize: none;
    transition: border-color 0.2s;
}

.query-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.query-input::placeholder {
    color: var(--text-muted);
}

.query-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-tertiary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.btn-secondary {
    background: var(--bg-medium);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.btn-secondary:hover {
    background: var(--bg-light);
}

.btn svg {
    width: 16px;
    height: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent-primary);
}

/* Card Query Input - più compatta */
.query-section .card:first-child .card-body {
    padding: 12px 16px;
}

/* Response Area - ESPANSA e più importante visivamente */
.response-area {
    background: var(--bg-dark);
    border: 2px solid var(--accent-secondary);
    border-radius: 8px;
    padding: 20px 24px;
    min-height: 250px;
    max-height: 450px;  /* Aumentato da 300px */
    overflow-y: auto;
    box-shadow: 0 0 20px rgba(157, 78, 221, 0.1);
}

.response-content {
    font-size: 1.05rem;  /* Aumentato da 0.9rem */
    line-height: 1.8;    /* Aumentato da 1.6 */
    color: var(--text-primary);
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
}

.response-content.empty {
    color: var(--text-muted);
    font-style: italic;
    font-size: 0.95rem;
}

/* Card Risposta ASTRA - più prominente */
.query-section .card:last-child {
    border: 2px solid rgba(157, 78, 221, 0.4);
    box-shadow: 0 4px 25px rgba(157, 78, 221, 0.15);
}

.query-section .card:last-child .card-header {
    background: linear-gradient(90deg, rgba(157, 78, 221, 0.15), transparent);
}

.query-section .card:last-child .card-title {
    font-size: 0.95rem;
    color: var(--accent-secondary);
}

.query-section .card:last-child .card-title svg {
    color: var(--accent-secondary);
}

.response-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.confidence-meter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.confidence-bar {
    width: 100px;
    height: 6px;
    background: var(--bg-medium);
    border-radius: 3px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.confidence-fill.high { background: var(--status-success); }
.confidence-fill.medium { background: var(--status-warning); }
.confidence-fill.low { background: var(--status-error); }

/* ============================================
   Sidebar
   ============================================ */
.sidebar {
    background: rgba(10, 10, 20, 0.80);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-left: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

/* AI Provider Cards */
.provider-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 8px;
}

.provider-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.provider-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.provider-name {
    font-size: 0.85rem;
    font-weight: 500;
}

.provider-status {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-medium);
    border-radius: 22px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-primary);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* History List */
.history-list {
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    padding: 10px 12px;
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--accent-primary);
    background: rgba(0, 212, 255, 0.05);
}

.history-query {
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Budget Display */
.budget-display {
    background: var(--bg-dark);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 12px;
}

.budget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.budget-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.budget-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-gold);
}

.budget-bar {
    height: 4px;
    background: var(--bg-medium);
    border-radius: 2px;
    overflow: hidden;
}

.budget-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-gold), var(--status-warning));
    border-radius: 2px;
    transition: width 0.5s ease;
}

/* ============================================
   Loading Overlay
   ============================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--bg-medium);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--accent-primary);
    font-size: 1rem;
    font-weight: 500;
}

/* ============================================
   Alerts
   ============================================ */
.alert-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.alert {
    padding: 12px 16px;
    background: var(--bg-darker);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease;
    max-width: 320px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert.warning {
    border-color: var(--status-warning);
    background: rgba(255, 171, 0, 0.1);
}

.alert.error {
    border-color: var(--status-error);
    background: rgba(255, 82, 82, 0.1);
}

.alert.success {
    border-color: var(--status-success);
    background: rgba(0, 200, 83, 0.1);
}

.alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert.warning .alert-icon { color: var(--status-warning); }
.alert.error .alert-icon { color: var(--status-error); }
.alert.success .alert-icon { color: var(--status-success); }

.alert-message {
    font-size: 0.8rem;
    color: var(--text-primary);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1400px) {
    .monitoring-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .monitoring-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 100px;
    }
}

@media (max-width: 900px) {
    .dashboard-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .vision-content {
        max-height: 250px;
    }

    .response-area {
        max-height: 350px;
    }
}

/* ============================================
   FASE 7: Local AI Badge Styles
   ============================================ */

/* Status badge gray dot for inactive Local AI */
.status-dot.gray {
    background-color: #6b7280;
}

/* Provider Badge in Response Area */
.provider-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 12px;
}

.provider-badge-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Local AI Badge - Green */
.provider-badge.local {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #10b981;
}

.provider-badge.local .provider-badge-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* Claude Badge - Orange/Amber */
.provider-badge.claude {
    background: rgba(245, 158, 11, 0.15);
    border: 1px solid rgba(245, 158, 11, 0.4);
    color: #f59e0b;
}

.provider-badge.claude .provider-badge-dot {
    background: #f59e0b;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.6);
}

/* Gemini Badge - Blue/Purple */
.provider-badge.gemini {
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.4);
    color: #8b5cf6;
}

.provider-badge.gemini .provider-badge-dot {
    background: #8b5cf6;
    box-shadow: 0 0 8px rgba(139, 92, 246, 0.6);
}

/* Council Badge - Cyan (multiple AI) */
.provider-badge.council {
    background: rgba(0, 212, 255, 0.15);
    border: 1px solid rgba(0, 212, 255, 0.4);
    color: #00d4ff;
}

.provider-badge.council .provider-badge-dot {
    background: linear-gradient(135deg, #f59e0b, #8b5cf6);
    box-shadow: 0 0 8px rgba(0, 212, 255, 0.6);
}

/* Local AI Status Badge Active */
#local-ai-status.active {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #10b981;
}

#local-ai-status.active .status-dot {
    background: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.6);
}

/* Local LLM Card highlight when active */
#local-llm-card.active {
    background: rgba(16, 185, 129, 0.1);
    border-left-color: #10b981;
}

/* Savings animation */
@keyframes savingsGlow {
    0%, 100% { text-shadow: 0 0 5px rgba(16, 185, 129, 0.3); }
    50% { text-shadow: 0 0 15px rgba(16, 185, 129, 0.6); }
}

#local-savings.updated {
    animation: savingsGlow 1s ease-in-out;
}
