/* Starlight Ads - Purple/Lavender Theme */
:root {
    --primary: #6C5CE7;
    --primary-dark: #5A4BD1;
    --primary-darker: #4C3D99;
    --lavender: #A29BFE;
    --lavender-light: #DDD6FE;
    --lavender-bg: #F5F3FF;
    --white: #FFFFFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --accent: #F59E0B;
    --accent-light: #FCD34D;
    --success: #10B981;
    --danger: #EF4444;
    --danger-dark: #DC2626;
    --info: #3B82F6;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--lavender-bg);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); text-decoration: underline; }

/* Top Navigation */
.topnav {
    background: linear-gradient(135deg, var(--primary-darker) 0%, var(--primary) 100%);
    color: white;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topnav .logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

.topnav .logo:hover { text-decoration: none; }

.topnav .logo svg {
    width: 28px;
    height: 28px;
}

.topnav nav {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.topnav nav a {
    color: rgba(255,255,255,0.85);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.15s;
}

.topnav nav a:hover {
    background: rgba(255,255,255,0.15);
    color: white;
    text-decoration: none;
}

.topnav nav a.active {
    background: rgba(255,255,255,0.2);
    color: white;
}

.topnav .user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: rgba(255,255,255,0.85);
    font-size: 0.9rem;
}

.topnav .user-info a {
    color: rgba(255,255,255,0.85);
    font-size: 0.85rem;
}

/* Main Content */
.main-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

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

.card-header h2 {
    font-size: 1.25rem;
    color: var(--primary-darker);
    font-weight: 600;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.75rem;
    color: var(--primary-darker);
    font-weight: 700;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    line-height: 1.4;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-md); }

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

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-dark); color: white; }

.btn-secondary { background: var(--gray-200); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-300); color: var(--gray-800); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: white;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: var(--lavender-bg);
    color: var(--primary-darker);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--lavender-light);
}

table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.9rem;
    vertical-align: middle;
}

table tr:hover td {
    background: var(--lavender-bg);
}

table .actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: nowrap;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-700);
    margin-bottom: 0.35rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--white);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--lavender);
    box-shadow: 0 0 0 3px rgba(162, 155, 254, 0.25);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
}

.form-row-4 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--gray-200);
}

/* Flash Messages */
.flash {
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flash-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.flash-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FECACA;
}

.flash-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

/* Login Page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-darker) 0%, var(--primary) 40%, var(--lavender) 100%);
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    margin: 1rem;
}

.login-card h1 {
    text-align: center;
    color: var(--primary-darker);
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.login-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 0.9rem;
    margin-bottom: 2rem;
}

.login-card .btn {
    width: 100%;
    justify-content: center;
    padding: 0.75rem;
    font-size: 1rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo svg {
    width: 56px;
    height: 56px;
}

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

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon svg { width: 24px; height: 24px; }

.stat-icon.purple { background: var(--lavender-light); color: var(--primary); }
.stat-icon.amber { background: #FEF3C7; color: #D97706; }
.stat-icon.green { background: #D1FAE5; color: #059669; }
.stat-icon.blue { background: #DBEAFE; color: #2563EB; }

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-800);
    line-height: 1;
}

.stat-info p {
    font-size: 0.8rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
    margin-top: 0.25rem;
}

/* Badge */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

.badge-admin { background: var(--lavender-light); color: var(--primary-darker); }
.badge-podcaster { background: #D1FAE5; color: #065F46; }
.badge-advertiser { background: #FEF3C7; color: #92400E; }

/* Confirm Dialog */
.confirm-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

.confirm-dialog {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.confirm-dialog h3 {
    margin-bottom: 0.5rem;
    color: var(--gray-800);
}

.confirm-dialog p {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.confirm-dialog .btn-group {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* YT Simulcast Toggle */
.toggle-yes { color: var(--success); font-weight: 600; }
.toggle-no { color: var(--gray-400); }

/* Typeahead / Autocomplete */
.typeahead-wrap {
    position: relative;
}

.typeahead-wrap input[type="text"] {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--white);
}

.typeahead-wrap input[type="text"]:focus {
    outline: none;
    border-color: var(--lavender);
    box-shadow: 0 0 0 3px rgba(162, 155, 254, 0.25);
}

.typeahead-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1.5px solid var(--lavender);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 220px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: var(--shadow-md);
    display: none;
}

.typeahead-list.open { display: block; }

.typeahead-list .ta-item {
    padding: 0.55rem 0.85rem;
    cursor: pointer;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.1s;
}

.typeahead-list .ta-item:last-child { border-bottom: none; }
.typeahead-list .ta-item:hover,
.typeahead-list .ta-item.active {
    background: var(--lavender-bg);
    color: var(--primary-darker);
}

.typeahead-list .ta-item.ta-new {
    color: var(--primary);
    font-weight: 600;
    font-style: italic;
}

.typeahead-selected {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    background: var(--lavender-bg);
    border: 1.5px solid var(--lavender);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.typeahead-selected .ta-clear {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0 0.25rem;
    line-height: 1;
}

.typeahead-selected .ta-clear:hover { color: var(--danger); }

/* Modal Overlay (for new advertiser) */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    color: var(--primary-darker);
    margin-bottom: 1.25rem;
    font-size: 1.2rem;
}

/* Breadcrumbs */
.breadcrumbs {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}
.breadcrumbs a { color: var(--primary); }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { margin: 0 0.35rem; color: var(--gray-400); }

/* Sortable Table Headers */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--primary); }
th.sortable a { color: inherit; text-decoration: none; }
th.sortable a:hover { text-decoration: none; }
th .sort-arrow { margin-left: 0.25rem; font-size: 0.7rem; color: var(--gray-400); }
th.sorted-asc .sort-arrow,
th.sorted-desc .sort-arrow { color: var(--primary); }

/* Report Tables */
.report-total-row td {
    font-weight: 700;
    border-top: 2px solid var(--lavender-light);
    background: var(--lavender-bg);
}

/* Month Selector */
.month-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.month-selector select {
    padding: 0.5rem 0.85rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--white);
}
.month-selector select:focus {
    outline: none;
    border-color: var(--lavender);
    box-shadow: 0 0 0 3px rgba(162, 155, 254, 0.25);
}

/* Quill Editor Overrides */
.ql-toolbar.ql-snow { border-radius: var(--radius) var(--radius) 0 0; border-color: var(--gray-300); }
.ql-container.ql-snow { border-radius: 0 0 var(--radius) var(--radius); border-color: var(--gray-300); font-size: 0.9rem; font-family: inherit; }
.ql-editor { min-height: 100px; }
.ql-editor.ql-blank::before { font-style: normal; color: var(--gray-400); }

/* Show Grid (podcaster homepage) */
.show-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.show-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--gray-800);
    transition: box-shadow 0.15s, transform 0.15s;
}
.show-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}
.show-card-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--lavender-bg);
    color: var(--primary);
    border-radius: var(--radius);
}
.show-card-icon svg { width: 22px; height: 22px; }
.show-card h3 { font-size: 0.95rem; font-weight: 600; margin: 0; }
.show-card-icon.amber-bg { background: #FEF3C7; color: var(--accent); }
.show-card-icon.green-bg { background: #D1FAE5; color: var(--success); }

/* Active-ad dot on show cards */
.active-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    margin-left: 0.4rem;
    vertical-align: middle;
}

/* Editable impressions */
.editable-imps {
    cursor: pointer;
    padding: 0.15rem 0.3rem;
    border-radius: 4px;
    border: 1px solid transparent;
    transition: border-color 0.15s, background 0.15s;
}
.editable-imps:hover {
    border-color: var(--gray-300);
    background: var(--gray-50);
}
.imps-input {
    width: 100px;
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
    border: 1.5px solid var(--primary);
    border-radius: 4px;
    outline: none;
    background: white;
}

/* Copy / Pixel detail links */
.detail-link { font-size: 0.85rem; font-weight: 500; }
.detail-empty { color: var(--gray-300); }
.detail-content { display: none; }
.detail-body {
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    line-height: 1.6;
}

/* Vetting badges on homepage */
.vetting-badge { font-size: 0.8rem; color: var(--accent); font-weight: 600; }
.vetting-done { font-size: 0.8rem; color: var(--success); font-weight: 500; }

/* Vetting page */
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; }
.status-pill {
    display: inline-block;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-approved { background: #D1FAE5; color: #065F46; }
.status-rejected { background: #FEE2E2; color: #991B1B; }

.ext-link {
    color: var(--gray-400);
    text-decoration: none;
    font-size: 0.85rem;
    margin-left: 0.3rem;
}
.ext-link:hover { color: var(--primary); }

/* Checkbox Grid (podcast access) */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.25rem 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 0.75rem;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    background: var(--gray-50);
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 4px;
}
.checkbox-label:hover { background: var(--lavender-bg); }
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    flex-shrink: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .topnav { padding: 0 1rem; }
    .main-content { padding: 1rem; }
    .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
    .stats-grid { grid-template-columns: 1fr; }
    .topnav nav { display: none; }
}
