/* ==========================================
   StreamTracker — Premium Dark Theme
   ========================================== */

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #111128;
    --bg-card: rgba(22, 22, 50, 0.6);
    --bg-card-hover: rgba(30, 30, 65, 0.8);
    --bg-glass: rgba(255, 255, 255, 0.04);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --border-focus: rgba(99, 102, 241, 0.5);

    --text-primary: #e8e8f0;
    --text-secondary: #9898b8;
    --text-muted: #6868a0;
    --text-accent: #a78bfa;

    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1, #a855f7);
    --accent-glow: rgba(99, 102, 241, 0.25);

    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.2);
    --warning: #f59e0b;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 400ms cubic-bezier(0.25, 0.46, 0.45, 0.94);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* Animated Background */
.bg-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.bg-particles::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse 600px 400px at 20% 30%, rgba(99, 102, 241, 0.08) 0%, transparent 70%),
        radial-gradient(ellipse 500px 350px at 80% 60%, rgba(168, 85, 247, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 400px 300px at 50% 80%, rgba(139, 92, 246, 0.05) 0%, transparent 70%);
    animation: bgFloat 20s ease-in-out infinite alternate;
}

@keyframes bgFloat {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-30px, -20px) rotate(2deg); }
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(139, 92, 246, 0.4);
    border-radius: 50%;
    animation: particleFloat linear infinite;
}

@keyframes particleFloat {
    0% { transform: translateY(100vh) scale(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-10vh) scale(1); opacity: 0; }
}

/* Typography */
h1, h2, h3, h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 26, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 1.5rem;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
    gap: 1rem;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.3)); }
    50% { filter: drop-shadow(0 0 12px rgba(99, 102, 241, 0.6)); }
}

.app-title {
    font-size: 1.25rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.app-subtitle {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.user-plan-badge {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.3);
    padding: 0.2rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.user-plan-badge.premium {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border-color: rgba(34, 197, 94, 0.3);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-glow), var(--shadow-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

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

.btn-ghost:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-outline {
    background: transparent;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
}

.btn-outline:hover {
    background: rgba(99, 102, 241, 0.1);
}

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 2px 8px var(--danger-glow);
}

.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--danger-glow);
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
}

.btn-icon {
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

/* Stats Section */
.stats-section {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition-normal);
}

.stat-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.stat-icon-emails { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.stat-icon-platforms { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.stat-icon-assignments { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.stat-icon-free { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

.stat-info {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
}

.stat-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Search Section */
.search-section {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto 1.5rem;
    padding: 0 1.5rem;
}

.search-bar {
    position: relative;
    margin-bottom: 1rem;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.search-input {
    width: 100%;
    padding: 0.85rem 2.5rem 0.85rem 3rem;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: all var(--transition-normal);
    backdrop-filter: blur(12px);
}

.search-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-input:focus ~ .search-icon {
    color: var(--accent-primary);
}

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

.search-clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-glass);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: all var(--transition-fast);
}

.search-clear:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

/* Filter Bar Controls & Chips */
.filter-bar-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    flex: 1;
}

.filter-toggle-mode {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: rgba(20, 20, 45, 0.4);
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
}

.filter-toggle-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.toggle-group {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 2px;
}

.toggle-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-normal);
}

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

.toggle-btn.toggle-active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}


.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    white-space: nowrap;
}

.chip:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
}

.chip-active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.chip-active:hover {
    opacity: 0.9;
    color: white;
}

.chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
}

/* Email Grid (Compact List) */
.email-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Email Card (Compact Row) */
.email-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    position: relative;
    transition: all var(--transition-normal);
    animation: cardIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    opacity: 0;
    transform: translateY(8px);
}

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

.email-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm), var(--shadow-glow);
}

.email-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1.5;
    min-width: 0;
}

.email-address {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.email-notes-inline {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

.email-card-actions {
    display: flex;
    gap: 0.15rem;
    flex-shrink: 0;
    opacity: 0.8;
    transition: opacity var(--transition-fast);
}

.email-card:hover .email-card-actions {
    opacity: 1;
}

.email-card-platforms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-end;
    flex: 2;
}

.platform-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    transition: all var(--transition-fast);
}

.platform-badge:hover {
    transform: scale(1.05);
}

/* Platform Colors */
.platform-netflix { background: rgba(229, 9, 20, 0.15); color: #f87171; border: 1px solid rgba(229, 9, 20, 0.2); }
.platform-disney { background: rgba(17, 60, 207, 0.15); color: #60a5fa; border: 1px solid rgba(17, 60, 207, 0.2); }
.platform-hbo { background: rgba(89, 37, 220, 0.15); color: #a78bfa; border: 1px solid rgba(89, 37, 220, 0.2); }
.platform-amazon { background: rgba(0, 168, 225, 0.15); color: #22d3ee; border: 1px solid rgba(0, 168, 225, 0.2); }
.platform-spotify { background: rgba(30, 215, 96, 0.15); color: #4ade80; border: 1px solid rgba(30, 215, 96, 0.2); }
.platform-apple { background: rgba(162, 170, 173, 0.15); color: #d1d5db; border: 1px solid rgba(162, 170, 173, 0.2); }
.platform-paramount { background: rgba(0, 100, 255, 0.15); color: #60a5fa; border: 1px solid rgba(0, 100, 255, 0.2); }
.platform-other { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.2); }

.no-platforms {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    padding: 0.25rem 0;
}

/* Search Toolbar & View Switcher */
.search-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.view-switcher {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 3px;
    backdrop-filter: blur(8px);
}

.view-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.view-btn-active {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

/* Matrix Table View */
.matrix-wrapper {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-bottom: 2rem;
    animation: fadeIn 0.4s ease;
}

.matrix-scroll {
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.matrix-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.matrix-table th, .matrix-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    white-space: nowrap;
}

.matrix-table th {
    background: rgba(17, 17, 35, 0.9);
    color: var(--text-accent);
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    position: sticky;
    top: 0;
}

.matrix-table th:first-child, .matrix-table td:first-child {
    position: sticky;
    left: 0;
    background: var(--bg-secondary);
    z-index: 10;
    border-right: 1px solid var(--border-subtle);
    width: 280px;
    min-width: 280px;
    max-width: 280px;
}

.matrix-table td {
    color: var(--text-secondary);
}

.matrix-table tr:hover td {
    background: rgba(255, 255, 255, 0.01) !important;
    color: var(--text-primary);
}

.matrix-table tr:hover td:first-child {
    background: var(--bg-secondary) !important;
}

/* Matrix Cell Interactive Statuses */
.matrix-cell-interactive {
    text-align: center !important;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.matrix-cell-interactive:hover {
    background: rgba(99, 102, 241, 0.08) !important;
}

.matrix-dot {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
    border: 2px solid var(--border-light);
    background: transparent;
    margin: 0 auto;
}

.matrix-dot:hover {
    transform: scale(1.15);
}

.matrix-dot-active {
    border-color: transparent !important;
    transform: scale(1.1);
    box-shadow: 0 0 8px currentColor;
}

.matrix-dot-active svg {
    opacity: 1 !important;
}

.matrix-dot svg {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.matrix-email {
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-all;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.matrix-notes {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: block;
    font-weight: 400;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.matrix-actions-cell {
    display: flex;
    gap: 0.15rem;
}

/* Modal Tabs Layout */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-subtle);
    background: rgba(0, 0, 0, 0.15);
    padding: 0 1rem;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.modal-tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
}

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

.modal-tab-btn.tab-active {
    color: var(--accent-primary);
}

.modal-tab-btn.tab-active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-gradient);
}

.tab-content {
    animation: fadeIn 0.3s ease;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.empty-icon {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    opacity: 0.5;
}

.empty-state h2 {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    max-width: 400px;
    margin: 0 auto 2rem;
    font-size: 0.9rem;
}

.empty-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* No Results */
.no-results {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.no-results svg {
    margin-bottom: 1rem;
    opacity: 0.4;
}

.no-results p {
    font-size: 0.9rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: overlayIn 0.2s ease;
}

@keyframes overlayIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.modal-lg {
    max-width: 640px;
}

.modal-sm {
    max-width: 380px;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
}

.modal-close:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-subtle);
}

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

.form-group:last-child {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-input {
    width: 100%;
    padding: 0.65rem 0.85rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    transition: all var(--transition-normal);
}

.form-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

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

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%239898b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.25rem;
}

/* Platforms Grid (in modal) */
.platforms-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.platform-toggle {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-normal);
    user-select: none;
}

.platform-toggle:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-light);
}

.platform-toggle.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: var(--accent-primary);
}

.platform-toggle-check {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 2px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.platform-toggle.active .platform-toggle-check {
    background: var(--accent-gradient);
    border-color: var(--accent-primary);
}

.platform-toggle-check svg {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.platform-toggle.active .platform-toggle-check svg {
    opacity: 1;
}

.platform-toggle-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.platform-toggle-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.platform-toggle.active .platform-toggle-name {
    color: var(--text-primary);
}

/* Import Modal */
.import-instructions {
    margin-bottom: 1.25rem;
}

.instruction-step {
    display: flex;
    gap: 0.85rem;
    padding: 0.75rem 0;
}

.instruction-step + .instruction-step {
    border-top: 1px solid var(--border-subtle);
}

.step-number {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.instruction-step h3 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.instruction-step p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.csv-example {
    margin-top: 0.5rem;
    padding: 0.6rem 0.85rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.csv-example code {
    font-size: 0.72rem;
    color: var(--text-accent);
    font-family: 'Fira Code', 'Consolas', monospace;
    line-height: 1.7;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
    transition: all var(--transition-normal);
    cursor: pointer;
}

.drop-zone svg {
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.drop-zone p {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.drop-zone span {
    font-size: 0.78rem;
    display: block;
    margin-bottom: 0.75rem;
}

.drop-zone.drag-over {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.05);
    color: var(--text-primary);
}

.drop-zone.drag-over svg {
    opacity: 1;
    color: var(--accent-primary);
}

/* Import Preview */
.import-preview h3 {
    font-size: 0.95rem;
    margin-bottom: 0.75rem;
}

.preview-info {
    padding: 0.6rem 0.85rem;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.82rem;
    color: #4ade80;
}

.preview-table-wrap {
    overflow-x: auto;
    margin-bottom: 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.preview-table th {
    background: rgba(99, 102, 241, 0.1);
    color: var(--text-accent);
    padding: 0.5rem 0.65rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.preview-table td {
    padding: 0.4rem 0.65rem;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    white-space: nowrap;
}

.preview-table tr:hover td {
    background: var(--bg-glass);
}

.column-mapping {
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

.column-mapping h4 {
    font-size: 0.88rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.mapping-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.6rem;
}

.mapping-row label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 140px;
}

.mapping-row .form-input {
    flex: 1;
}

.mapping-platforms {
    margin-top: 1rem;
}

.mapping-platforms h5 {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.mapping-platform-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.4rem;
    padding: 0.3rem 0;
}

.mapping-platform-row .platform-badge {
    min-width: 90px;
    justify-content: center;
}

.mapping-platform-row .form-input {
    flex: 1;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: 0.85rem;
    min-width: 280px;
    animation: toastIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent-primary); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-exit {
    animation: toastOut 0.25s ease forwards;
}

@keyframes toastOut {
    to { opacity: 0; transform: translateX(20px); }
}

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

.text-muted {
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* Responsive */
@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .email-grid {
        grid-template-columns: 1fr;
    }

    .header-content {
        flex-wrap: wrap;
        height: auto;
        padding: 0.75rem 0;
        gap: 0.75rem;
    }

    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .btn span {
        display: none;
    }

    .btn svg {
        margin: 0;
    }

    .platforms-grid {
        grid-template-columns: 1fr;
    }

    .mapping-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .mapping-row label {
        min-width: auto;
    }
    .filter-toggle-mode {
        width: 100%;
        justify-content: space-between;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.6rem;
    }

    .stat-card {
        padding: 0.85rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .modal {
        margin: 0.5rem;
        max-height: 95vh;
    }

    .filter-chips {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 0.25rem;
        scrollbar-width: none;
    }

    .filter-chips::-webkit-scrollbar {
        display: none;
    }
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* Auth & Database Setup Screens */
.full-screen-container {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.5rem;
    overflow-y: auto;
}

.full-screen-container::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse 600px 400px at 30% 30%, rgba(99, 102, 241, 0.06) 0%, transparent 70%),
        radial-gradient(ellipse 500px 350px at 70% 70%, rgba(168, 85, 247, 0.05) 0%, transparent 70%);
    animation: bgFloat 25s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 0;
}

.auth-card {
    position: relative;
    z-index: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 2.25rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: modalIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.auth-logo {
    text-align: center;
    margin-bottom: 1.75rem;
}

.auth-logo svg {
    margin-bottom: 0.75rem;
}

.auth-logo h2 {
    font-size: 1.35rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-logo p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.auth-switch {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--accent-primary);
    font-weight: 700;
    cursor: pointer;
    font-family: var(--font-sans);
    padding: 0 0.25rem;
    text-decoration: underline;
    transition: color var(--transition-fast);
}

.btn-link:hover {
    color: var(--accent-secondary);
}

.btn-link-danger {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sans);
    text-decoration: underline;
    transition: color var(--transition-fast);
}

.btn-link-danger:hover {
    color: var(--danger);
}

.auth-db-reset {
    text-align: center;
    margin-top: 1.75rem;
    border-top: 1px solid var(--border-subtle);
    padding-top: 1rem;
}

.setup-help {
    margin-top: 1.5rem;
    border-top: 1px solid var(--border-subtle);
    padding-top: 1.25rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.6;
    text-align: left;
}

.setup-help p {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.setup-help ol {
    padding-left: 1.15rem;
}

.setup-help li {
    margin-bottom: 0.35rem;
}

.setup-help a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
}

.setup-help a:hover {
    text-decoration: underline;
}

/* User Email Header Label */
.user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-right: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    display: inline-block;
    vertical-align: middle;
}

.btn-icon svg {
    margin: 0 !important;
}

@media (max-width: 480px) {
    .auth-card {
        padding: 1.5rem;
    }
}

/* ==========================================
   StreamTracker — Sidebar & Content Layout
   ========================================== */

.app-layout {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem 3rem;
    gap: 2rem;
    align-items: flex-start;
}

.app-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: sticky;
    top: 90px;
}

.app-content {
    flex: 1;
    min-width: 0;
}

/* Sidebar Cards */
.sidebar-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.sidebar-heading {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 0.5rem;
}

/* Sidebar specific Chip styling (vertical) */
.app-sidebar .filter-chips {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.app-sidebar .chip {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-normal);
    width: 100%;
    text-align: left;
    white-space: nowrap;
}

.app-sidebar .chip:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-light);
    color: var(--text-primary);
    transform: translateX(4px);
}

.app-sidebar .chip.chip-active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.app-sidebar .chip.chip-active:hover {
    opacity: 0.9;
    color: white;
    transform: translateX(4px);
}

/* Sidebar specific status toggle styling */
.app-sidebar .filter-toggle-mode {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    background: var(--bg-card);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-sm);
    gap: 0.75rem;
}

.app-sidebar .filter-toggle-mode.hidden {
    display: none !important;
}

.app-sidebar .filter-toggle-mode .toggle-group {
    display: flex;
    width: 100%;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    padding: 2px;
}

.app-sidebar .filter-toggle-mode .toggle-btn {
    flex: 1;
    text-align: center;
    border-radius: var(--radius-full);
}

/* Override standard main-content and search-section margins when inside .app-content */
.app-content .search-section {
    max-width: none;
    margin: 0 0 1.5rem 0;
    padding: 0;
}

.app-content .main-content {
    max-width: none;
    margin: 0;
    padding: 0 0 3rem 0;
}

/* Custom colors for Correo Libre toggle in modal */
.platform-toggle-free.active {
    background: rgba(107, 114, 128, 0.15) !important;
    border-color: #6b7280 !important;
}
.platform-toggle-free.active .platform-toggle-check {
    background: #6b7280 !important;
    border-color: #6b7280 !important;
}

/* Responsive sidebar styling for mobile */
@media (max-width: 900px) {
    .app-layout {
        flex-direction: column;
        gap: 1.5rem;
        padding: 0 1rem 3rem;
    }

    .app-sidebar {
        width: 100%;
        position: static;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 1rem;
    }

    .app-sidebar .sidebar-card {
        flex: 1;
        min-width: 280px;
    }

    .app-sidebar .filter-chips {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .app-sidebar .chip {
        width: auto;
        flex-shrink: 0;
    }
}

/* Custom Platform Chip Delete Button */
.chip {
    position: relative;
}

.chip-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.15rem;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    transition: all var(--transition-fast);
    margin-left: auto; /* moves the delete button to the right of the vertical chip list */
}

.app-sidebar .chip-delete-btn {
    margin-left: auto;
}

.chip-delete-btn svg {
    display: block;
    margin: 0 !important;
}

.chip-delete-btn:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    transform: scale(1.1);
}

.chip-active .chip-delete-btn {
    color: rgba(255, 255, 255, 0.6);
}

.chip-active .chip-delete-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

