:root {
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #0f172a;
    /* Same as dark for seamless or slightly different */
    --accent-primary: #3b82f6;
    /* Blue */
    --accent-secondary: #6366f1;
    /* Indigo */
    --accent-glow: rgba(59, 130, 246, 0.5);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #0ea5e9;

    --font-main: 'Outfit', sans-serif;
    --font-mono: 'Space Mono', monospace;

    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 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);

    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font-main);
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    color: var(--text-primary);
}

.logo-icon {
    font-size: 2rem;
    color: var(--accent-primary);
    text-shadow: 0 0 15px var(--accent-glow);
}

.logo-container h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.highlight {
    color: var(--accent-primary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-weight: 500;
}

.nav-item:hover,
.nav-item.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.1) 0%, transparent 100%);
    color: var(--accent-primary);
    border-left: 3px solid var(--accent-primary);
}

.nav-item .material-symbols-rounded {
    font-size: 1.25rem;
}

.status-panel {
    background: var(--bg-card);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.status-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
}

.status-item:last-child {
    margin-bottom: 0;
}

.status-item .label {
    color: var(--text-muted);
}

.status-item .value {
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-weight: 700;
}

/* Main Content */
.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.05), transparent 40%);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 1rem;
}

.btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    /* Fallback */
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.8));
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-icon.info {
    background: rgba(14, 165, 233, 0.15);
    color: var(--info);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.stat-info p {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* AI Risk Management Widget Styles */
.risk-analysis-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--glass-border);
}

.risk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.risk-item {
    background: rgba(15, 23, 42, 0.3);
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--glass-border);
}

.risk-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.risk-level-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.risk-level-fill {
    height: 100%;
    transition: width 1s ease-in-out;
}

.risk-low {
    background-color: var(--success);
}

.risk-medium {
    background-color: var(--warning);
}

.risk-high {
    background-color: var(--danger);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--success);
    font-weight: 600;
}

.live-indicator .dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    animation: blink 1.5s infinite;
}

@keyframes blink {
    0% { opacity: 0.4; }
    50% { opacity: 1; }
    100% { opacity: 0.4; }
}

/* Report Styles */
.divider {
    border: none;
    border-top: 1px solid var(--glass-border);
    margin: 1.5rem 0;
}

.operator-notes {
    margin-bottom: 1.5rem;
}

.operator-notes label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.operator-notes textarea {
    width: 100%;
    height: 100px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    padding: 0.75rem;
    resize: none;
    outline: none;
}

.report-actions {
    display: flex;
    justify-content: flex-end;
}

/* Flights List */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.search-bar {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-muted);
    width: 300px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    outline: none;
}

/* Flights List - Table View */
.table-container {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    overflow-x: auto;
}

.flights-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    /* Ensure scrolling on small screens */
}

.flights-table th {
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem;
    text-align: left;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.85rem;
    border-bottom: 1px solid var(--glass-border);
}

.flights-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    vertical-align: middle;
}

.flights-table tr:last-child td {
    border-bottom: none;
}

.flights-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.flight-code {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--accent-primary);
}

.flight-weather {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.weather-warning {
    color: var(--warning);
    font-weight: 600;
}

.weather-icon {
    font-size: 1.2rem;
}

.weather-icon.alert {
    color: var(--warning);
    animation: pulse 2s infinite;
}

.btn-icon {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: var(--accent-primary);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--accent-primary);
    color: white;
}

/* AI Overlay */
.hidden {
    display: none !important;
}

.ai-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ai-panel {
    width: 600px;
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.ai-header {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.2), transparent);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.ai-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.2rem;
}

.close-btn:hover {
    color: var(--text-primary);
}

.ai-content {
    padding: 1.5rem;
}

.ai-section {
    margin-bottom: 1.5rem;
}

.ai-section h4 {
    margin-bottom: 0.75rem;
    color: var(--accent-primary);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.ai-response {
    background: rgba(15, 23, 42, 0.5);
    padding: 1rem;
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
    font-size: 0.95rem;
    line-height: 1.6;
    min-height: 80px;
}

.ai-response .loading-text {
    display: block;
    text-align: center;
    padding: 1rem;
}

.ai-response h4 {
    margin-bottom: 1rem;
    color: var(--accent-primary);
    font-size: 1.1rem;
}

.ai-response strong {
    color: var(--accent-primary);
    font-weight: 600;
}

.loading-text {
    font-style: italic;
    color: var(--text-muted);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* Spin animation for refresh button */
@keyframes spin {
    100% {
        transform: rotate(360deg);
    }
}

.spin-anim {
    animation: spin 0.5s linear;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.weather-alert-row {
    background-color: rgba(245, 158, 11, 0.05);
    border-left: 3px solid var(--warning);
}

.status-badge {
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-programmato {
    background-color: rgba(100, 116, 139, 0.2);
    color: var(--text-secondary);
}

.status-imbarco {
    background-color: rgba(59, 130, 246, 0.2);
    color: var(--accent-primary);
}

.status-ritardo {
    background-color: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.status-cancellato {
    background-color: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}