@import url('https://fonts.googleapis.com/css2?family=Calistoga&family=Source+Sans+3:wght@400;500;600;700&display=swap');

:root {
    --primary: #ffffff;
    --primary-dark: #e5e5e5;
    --secondary: #9ca3af;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #333333;
    --bg-secondary: #3d3d3d;
    --bg-card: #404040;
    --text: #ffffff;
    --text-muted: #c9cdd4;
    --border: #4a4a4a;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -2px rgba(0,0,0,0.3);
    --radius: 8px;
    --font-heading: 'Calistoga', cursive;
    --font-body: 'Source Sans 3', -apple-system, BlinkMacSystemFont, sans-serif;
    --link: #60a5fa;
    --link-hover: #93c5fd;
    --btn-primary: #ffffff;
    --btn-primary-hover: #e5e5e5;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* Header */
header {
    background: var(--bg);
    color: var(--text);
    padding: 20px 0;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: 0;
}

header p {
    opacity: 0.8;
    font-size: 0.85rem;
    margin-top: 2px;
}

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    margin-bottom: 24px;
}

.breadcrumb a {
    color: var(--link);
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    color: var(--text-muted);
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 400;
}

/* Grid */
.grid {
    display: grid;
    gap: 24px;
}

.grid-2 {
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

/* Masthead cards */
.masthead-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
    overflow: hidden;
}

.masthead-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.masthead-card-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border);
    min-height: 0;
    overflow: hidden;
}

.masthead-card-logo {
    width: 48px;
    height: 48px;
    max-width: 48px;
    max-height: 48px;
    border-radius: 6px;
    object-fit: contain;
    flex-shrink: 0;
}

.masthead-card-title {
    flex: 1;
}

.masthead-card h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 2px;
    color: var(--text);
}

.masthead-card .region {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

.masthead-card-body {
    padding: 16px 20px 20px;
}

.masthead-card .council-count {
    font-size: 0.75rem;
    color: var(--text);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Council list */
.council-list {
    list-style: none;
}

.council-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.council-item:last-child {
    border-bottom: none;
}

.council-item a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
}

.council-item a:hover {
    color: var(--link);
}

.council-item .state {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
}

/* Status badges */
.status {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 9999px;
    text-transform: capitalize;
}

.status-pending { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.status-downloading { background: rgba(96, 165, 250, 0.2); color: #60a5fa; }
.status-downloaded { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-transcribing { background: rgba(96, 165, 250, 0.2); color: #60a5fa; }
.status-transcribed { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-summarizing { background: rgba(96, 165, 250, 0.2); color: #60a5fa; }
.status-complete { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-error { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.status-active { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.status-inactive { background: rgba(156, 163, 175, 0.2); color: #9ca3af; }
.status-filtered { background: rgba(156, 163, 175, 0.2); color: #9ca3af; }

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--link);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Checkbox */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    border: none;
}

.btn-primary {
    background: var(--btn-primary);
    color: #333333;
}

.btn-primary:hover {
    background: var(--btn-primary-hover);
    color: #333333;
}

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

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

.btn-warning {
    background: #f59e0b;
    color: #ffffff;
}

.btn-warning:hover {
    background: #d97706;
    color: #ffffff;
}

.btn-success {
    background: #10b981;
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
    color: #ffffff;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:disabled {
    cursor: not-allowed;
}

/* Video table */
.video-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.video-table th {
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border);
}


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

.video-table tr:hover {
    background: var(--bg-secondary);
}

.video-title {
    font-weight: 500;
    color: var(--text);
}

.video-date {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.video-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Transcript/Summary display */
.content-box {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 20px;
    margin-top: 16px;
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
    max-height: 400px;
    overflow-y: auto;
}

/* Flags */
.flag-list {
    list-style: none;
}

.flag-item {
    background: rgba(245, 158, 11, 0.15);
    border-left: 3px solid var(--warning);
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.flag-keyword {
    font-weight: 600;
    color: #fbbf24;
}

.flag-context {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text);
}

.tab.active {
    color: var(--link);
    border-bottom-color: var(--link);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
    color: var(--text);
}

/* Two column layout */
.two-col {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .two-col {
        grid-template-columns: 1fr;
    }

    .grid-2, .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Summary content styling */
.summary-content p {
    margin-bottom: 12px;
}

.summary-content p:last-child {
    margin-bottom: 0;
}

.summary-content strong {
    color: #60a5fa;
    font-weight: 600;
}

.summary-content li {
    margin-left: 20px;
    margin-bottom: 6px;
    list-style: disc;
}

.summary-content em {
    font-style: italic;
}

/* =========================================================================
   Mobile (small phone widths). Pure-additive — desktop is untouched.
   Targets ≤ 640px which covers iPhone 12 Pro (390px) and most phones.
   ========================================================================= */
@media (max-width: 640px) {
    /* Prevent horizontal overflow when long words/URLs appear */
    body { overflow-x: hidden; }

    /* Tighten container padding and remove unused width minimums */
    .container { padding: 0 12px !important; }

    /* Header — stack brand on top, action buttons below */
    header { padding: 12px 0; margin-bottom: 20px; }
    .site-nav { flex-wrap: wrap; row-gap: 10px; justify-content: center !important; }
    .site-nav__spacer { display: none !important; }
    .site-nav__brand { order: 1; flex: 0 0 100%; }
    .site-nav__brand h1 { font-size: 1.35rem !important; }
    .site-nav__actions {
        order: 2;
        flex: 0 0 100%;
        min-width: 0 !important;
        justify-content: center !important;
        gap: 6px !important;
    }
    /* Compact buttons: keep icons, hide text labels.
       All header buttons forced to one consistent height — the icon
       buttons and the user badge otherwise differ because their content
       (SVG/emoji vs text) has different intrinsic heights. */
    .nav-btn, .nav-user {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        min-height: 40px;
        padding: 6px 10px !important;
    }
    .nav-btn { font-size: 0.85rem !important; }
    .nav-btn .nav-label { display: none; }
    .nav-user span { font-size: 0.8rem !important; }

    /* Cards — tighter padding so content has more room */
    .card { padding: 16px; margin-bottom: 16px; }
    .card-header { flex-wrap: wrap; gap: 8px; margin-bottom: 12px; padding-bottom: 12px; }
    .card-header h2 { font-size: 1.1rem; }

    /* Breadcrumb wraps instead of overflowing */
    .breadcrumb { flex-wrap: wrap; margin-bottom: 16px; }

    /* Grid items must be allowed to shrink below their content size,
       otherwise a wide <table> inside the grid expands the whole track
       and pushes everything off-screen. */
    .two-col > *, .grid-2 > *, .grid-3 > * { min-width: 0; }

    /* Generic wide tables (Users list, filtered-videos modal) — let them
       scroll horizontally inside their card rather than squishing the
       columns into unreadable slivers. */
    .video-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .video-table th, .video-table td { padding: 8px 8px; }

    /* The council page's main video table is special: it has expandable
       full-width summary/transcript rows that MUST wrap to the viewport,
       so a horizontal-scroll table won't do. Instead, drop the three
       low-value columns (Date — usually also in the title; Duration;
       Size) and lay the remaining three — Title / Status / Actions — out
       in a fixed 100%-wide table that always fits the screen. */
    .video-table--main {
        display: table;          /* override the generic block rule */
        table-layout: fixed;
        width: 100%;
    }
    /* Drop the desktop 6-column colgroup entirely; with table-layout:fixed
       the column widths then come from the first-row header cells. */
    .video-table--main colgroup { display: none; }
    .video-table--main th:nth-child(2),
    .video-table--main td:nth-child(2),
    .video-table--main th:nth-child(3),
    .video-table--main td:nth-child(3),
    .video-table--main th:nth-child(4),
    .video-table--main td:nth-child(4) {
        display: none;
    }
    .video-table--main th:nth-child(1) { width: 50%; }
    .video-table--main th:nth-child(5) { width: 22%; }
    .video-table--main th:nth-child(6) { width: 28%; }
    .video-table--main th,
    .video-table--main td {
        white-space: normal;
        overflow-wrap: break-word;   /* only break genuinely-long strings */
    }
    /* Expandable summary/transcript content always wraps */
    .video-table .summary-content,
    .video-table .summary-content * { white-space: normal; overflow-wrap: break-word; }

    /* Tabs scroll horizontally so they don't overflow */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
    }
    .tab { white-space: nowrap; }

    /* Forms — slightly tighter inputs */
    .form-group input,
    .form-group select,
    .form-group textarea { font-size: 1rem; /* prevents iOS zoom */ }

    /* Buttons stretch to fit narrower screens nicely */
    .btn { padding: 10px 14px; font-size: 0.9rem; }

    /* Override fixed max-width inline styles on common cards (Settings) */
    .card[style*="max-width"] { max-width: 100% !important; }
}
