/* Main Styles */
:root {
    /* Color Palette */
    --color-background: #0a0a0f;
    --color-surface: #1a1a24;
    --color-primary: #007acc;
    --color-secondary: #6b4fbb;
    --color-accent: #ff9800;
    --color-text: #ffffff;
    --color-text-secondary: #a0a0a0;
    --color-border: #2a2a34;
    --color-success: #4caf50;
    --color-warning: #ff9800;
    --color-error: #f44336;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 350ms ease;
}

body {
    background-color: var(--color-background);
    color: var(--color-text);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

.app-container {
    display: grid;
    grid-template-rows: auto auto auto 1fr; /* status row, header, ticker, content */
    min-height: 100vh;
    max-width: 1440px;
    margin: 0 auto;
    padding: var(--spacing-md);
}

/* Header Styles */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) 0; /* tighter */
    margin-bottom: var(--spacing-md); /* reduce vertical gap */
}

.header-right { display: flex; align-items: center; gap: 12px; }
.status-indicators { display: flex; gap: 6px; align-items: center; }
.status-chip { padding: 2px 8px; border-radius: 10px; font-size: 12px; background: #39424e; color: #cfd8dc; }
.status-chip.ok { background: #2e7d32; color: #e8f5e9; }
.status-chip.warn { background: #ef6c00; color: #fff8e1; }
.status-chip.err { background: #b71c1c; color: #ffebee; }
.logout-btn { padding: 6px 10px; border: 1px solid #607d8b; background: transparent; color: #cfd8dc; border-radius: 6px; cursor: pointer; }
.logout-btn:hover { background: rgba(96,125,139,0.2); }

/* System ticker (full-width under header) */
.system-ticker {
    width: 100%;
    overflow: hidden;
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    margin-bottom: var(--spacing-sm);
    height: 30px;               /* fixed height */
    display: flex;
    align-items: center;         /* vertically center text */
}
.system-ticker-track {
    display: block;
    text-align: center;          /* center children */
    overflow: hidden;
    height: 100%;
}
.system-ticker-text {
    display: inline-block;          /* shrink to text */
    white-space: nowrap;
    margin: 0 auto;                 /* center within track */
    padding: 0;                     /* rely on fixed bar height */
    color: var(--color-text-secondary);
    line-height: 30px;              /* match bar height */
    font-size: 0.95rem;
}
/* Per-item dynamic animation */
/* Remove scrolling; use centered, stationary text */
.system-ticker-item { display: none; }
@keyframes ticker-scroll {
    0% { transform: translateX(100%); }
    100% { transform: translateX(-100%); }
}

/* Button Styles */
.btn { 
    border: 1px solid #607d8b; 
    background: transparent; 
    color: #cfd8dc; 
    border-radius: 6px; 
    cursor: pointer; 
    font-family: inherit;
    transition: background-color var(--transition-fast);
}
.btn:hover { background: rgba(96,125,139,0.2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn.xs { padding: 2px 6px; font-size: 11px; }
.btn.sm { padding: 6px 10px; font-size: 12px; }
.btn.md { padding: 8px 12px; font-size: 14px; }
.btn.lg { padding: 12px 16px; font-size: 16px; }
.commander-info { display: flex; flex-direction: column; gap: 2px; }

.main-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-primary);
    margin: 0; /* remove default h1 margins causing extra header height */
}

.commander-info {
    display: flex;
    gap: var(--spacing-md);
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* Four equal-width columns */
    gap: var(--spacing-lg);
    align-items: start; /* prevent columns from stretching full height; grow with content */
}

/* Section Styles */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 500;
}

/* Scoped to the projects panel to avoid header bleed */
.depot-list-section .section-subheader {
    display: flex;
    align-items: center;
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    margin-bottom: var(--spacing-sm);
    /* Indent to align roughly with the checkbox column */
    padding-left: 28px;
}
.depot-list-section .section-subheader .col-subscribed { opacity: 0.85; }

/* Shopping list subheader: slightly smaller and snug to the title */
.shopping-list-section .section-header { margin-bottom: 2px; }
.shopping-list-section .section-subheader {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    line-height: 1.1;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

/* Cohorts subheader: same styling as shopping list */
.cohorts-section .section-header { margin-bottom: 2px; }
.cohorts-section .section-subheader {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    line-height: 1.1;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

/* Carriers subheader: match cohorts styling */
.carriers-section .section-header { margin-bottom: 2px; }
.carriers-section .section-subheader {
    margin-top: 0;
    margin-bottom: var(--spacing-sm);
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    line-height: 1.1;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border);
}

/* List Controls */
.list-controls {
    display: flex;
    gap: var(--spacing-sm);
}

.sort-select {
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    padding: var(--spacing-xs) var(--spacing-sm);
    cursor: pointer;
}

.sort-select:hover {
    border-color: var(--color-primary);
}

/* Column 1: Cohorts and Carriers panels with spacing */
.column-1 {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Column 3: Ship Cargo and Cohort Cargo panels with spacing */
.column-3 {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

/* Panel styling for all columns */
.column-1 .cohorts-section,
.column-1 .carriers-section,
.column-3 .ship-cargo-section,
.column-3 .cohort-cargo-section {
    background-color: var(--color-surface);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md);
    height: fit-content;
}

/* Remove old left-column references */
.left-column .ship-cargo-section,
.left-column .cohort-cargo-section,
.left-column .carrier-stock-section {
    background-color: var(--color-surface);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md);
}

.left-column { display: flex; flex-direction: column; gap: var(--spacing-lg); }

/* Shopping list layout */
.shopping-list { display: flex; flex-direction: column; gap: var(--spacing-sm); }
.shopping-list-item {
    display: grid;
    grid-template-columns: 1fr minmax(70px, 120px);
    align-items: center;
}
.shopping-list-item .commodity-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shopping-list-item .needed-amount { text-align: right; font-variant-numeric: tabular-nums; }

/* Cohorts panel styling */
.cohorts-section {
    background-color: var(--color-surface);
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-md);
    height: fit-content;
}
.cohorts-list { display: flex; flex-direction: column; gap: 8px; }
.cohort-row { display: flex; align-items: center; gap: 8px; }

/* Cohort Cargo card styling */
.cohort-cargo-section .cohort-block {
    background: rgba(58, 68, 81, 0.35);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}
.cohort-cargo-section .cohort-block:last-child {
    margin-bottom: 0;
}
.cohort-cargo-section .cohort-title {
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}
.cohort-cargo-section .cohort-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: var(--spacing-sm);
    }

    .main-header {
        flex-direction: column;
        gap: var(--spacing-sm);
        text-align: center;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}