/*
    app.css - Main stylesheet for PicassoRayne Stream Tracker
    Copyright © 2025 Picasso Rayne Studios LLC. All rights reserved.
*/

:root {
    /* StreamTracker brand — deep navy with a blue -> purple -> cyan gradient. */
    --primary-color: #4f7cff;
    --primary-dark: #2f5ce0;
    --accent-color: #22d3ee;
    --secondary-color: #8b5cf6;
    --gradient-brand: linear-gradient(135deg, #4f7cff 0%, #8b5cf6 55%, #22d3ee 100%);
    --bg-dark: #0a0e1a;
    --bg-darker: #070b16;
    --bg-card: #111a2e;
    --text-primary: #eaf0ff;
    --text-secondary: #97a3c2;
    --border-color: #1e2a45;
    --success-color: #00d28a;
    --warning-color: #ffab00;
    --danger-color: #ff5a6a;
    --live-color: #ff3b52;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
}

/* App Container */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    background-color: var(--bg-dark);
}

/* Mobile elements - hidden by default on desktop */
.mobile-header,
.sidebar-overlay,
.bottom-nav {
    display: none;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-darker);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.brand {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
    text-align: center;
}

.brand h2 {
    color: var(--primary-color);
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--primary-color);
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.username {
    font-weight: 600;
    color: var(--text-primary);
}

.connection-status {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.connection-status.connected {
    color: var(--success-color);
}

.signout-form {
    margin: 0;
    padding: 0;
}

.signout-form button {
    background: none;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.nav-menu {
    list-style: none;
    padding: 0;
    flex: 1;
}

.nav-menu li {
    margin: 0.25rem 0;
}

.nav-menu a, .nav-menu .signout-link {
    display: block;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.nav-menu a:hover, .nav-menu .signout-link:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-left-color: var(--primary-color);
}

.nav-menu a.active {
    background-color: var(--bg-card);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
}

.nav-menu .divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 1rem 1.5rem;
}

.login-prompt {
    padding: 2rem 1.5rem;
    text-align: center;
}

/* Sign-out icon button in user-info row */
.btn-signout {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.35rem 0.5rem;
    border-radius: 6px;
    font-size: 1rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.btn-signout:hover {
    background: rgba(220, 53, 69, 0.15);
    border-color: var(--danger-color);
    color: var(--danger-color);
}

/* Full-width sign-out button at sidebar bottom */
.btn-signout-full {
    display: block;
    width: 100%;
    padding: 0.6rem 1rem;
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #dc3545;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    transition: all 0.2s ease;
}

.btn-signout-full:hover {
    background: rgba(220, 53, 69, 0.25);
    border-color: #dc3545;
}

.nav-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: auto;
}

.nav-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-footer a:hover {
    color: var(--primary-color);
}

.btn-twitch {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    margin-top: 1rem;
    transition: background-color 0.2s;
}

.btn-twitch:hover {
    background-color: var(--primary-dark);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Grid */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }

    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        padding-top: 60px;
        padding-bottom: 70px;
    }

    /* Mobile header */
    .mobile-header {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-darker);
        border-bottom: 1px solid var(--border-color);
        align-items: center;
        padding: 0 1rem;
        z-index: 999;
    }

    .hamburger-btn {
        background: none;
        border: none;
        padding: 0.5rem;
        cursor: pointer;
        display: flex;
        flex-direction: column;
        gap: 5px;
    }

    .hamburger-line {
        width: 24px;
        height: 2px;
        background: var(--text-primary);
        border-radius: 2px;
        transition: transform 0.3s;
    }

    .mobile-brand {
        flex: 1;
        text-align: center;
    }

    .mobile-brand h2 {
        font-size: 1.1rem;
        margin: 0;
    }

    .mobile-avatar {
        width: 36px;
        height: 36px;
        border-radius: 50%;
    }

    /* Sidebar overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Bottom navigation */
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-darker);
        border-top: 1px solid var(--border-color);
        z-index: 998;
    }

    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        color: var(--text-secondary);
        font-size: 0.7rem;
        transition: color 0.2s;
    }

    .bottom-nav-item:hover,
    .bottom-nav-item.active {
        color: var(--primary-color);
    }

    .bottom-nav-icon {
        font-size: 1.25rem;
        margin-bottom: 2px;
    }

    .bottom-nav-label {
        font-size: 0.65rem;
    }
}

/* Hide mobile elements on desktop */
@media (min-width: 769px) {
    .mobile-header,
    .sidebar-overlay,
    .bottom-nav {
        display: none !important;
    }

    .sidebar {
        position: fixed;
        left: 0;
        width: 260px;
    }

    .main-content {
        margin-left: 260px;
    }
}

/* Stats Cards */
.stat-card {
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1.2;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.stat-change {
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.stat-change.positive { color: var(--success-color); }
.stat-change.negative { color: var(--danger-color); }

.stat-value.positive { color: var(--success-color); }
.stat-value.negative { color: var(--danger-color); }

/* Channel List */
.channel-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--bg-darker);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

/* Row selection */
.row-selected {
    background-color: rgba(145, 70, 255, 0.15) !important;
}

.channel-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.channel-info {
    flex: 1;
}

.channel-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.channel-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.live-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background-color: var(--live-color);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.live-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    background-color: white;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    font-size: 0.9rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--bg-card);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Row busy state */
.row-busy {
    opacity: 0.6;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-darker);
    color: var(--text-primary);
    font-size: 1rem;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle input {
    display: none;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 26px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(22px);
    background-color: white;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
}

.table tr:hover {
    background-color: var(--bg-darker);
}

/* Overlay Templates */
.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.template-card {
    background-color: var(--bg-card);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.template-card.selected {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(145, 70, 255, 0.3);
}

.template-preview {
    aspect-ratio: 16/9;
    background-color: var(--bg-darker);
    display: flex;
    align-items: center;
    justify-content: center;
}

.template-info {
    padding: 1rem;
}

.template-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.template-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    color: var(--text-secondary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: rgba(0, 200, 83, 0.1);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.alert-warning {
    background-color: rgba(255, 171, 0, 0.1);
    border: 1px solid var(--warning-color);
    color: var(--warning-color);
}

.alert-danger {
    background-color: rgba(255, 68, 68, 0.1);
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

/* Copy URL Box */
.url-box {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.url-input {
    flex: 1;
    padding: 0.75rem 1rem;
    background-color: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.9rem;
}

/* ============================================================
   Brand design system refresh (StreamTracker) — navy + blue/purple/cyan gradient.
   Applied on top of the existing rules so the whole site picks up the new identity.
   ============================================================ */
body {
    background:
        radial-gradient(900px 500px at 100% -5%, rgba(34, 211, 238, .07), transparent),
        radial-gradient(1000px 600px at -10% 0%, rgba(139, 92, 246, .08), transparent),
        var(--bg-dark);
    background-attachment: fixed;
}

/* Primary actions use the brand gradient. */
.btn-primary,
button.btn-primary,
.btn.btn-primary {
    background: var(--gradient-brand);
    border: none;
    color: #fff;
    box-shadow: 0 6px 20px rgba(79, 124, 255, .28);
    transition: filter .15s ease, transform .15s ease, box-shadow .15s ease;
}
.btn-primary:hover,
button.btn-primary:hover,
.btn.btn-primary:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(79, 124, 255, .38);
}

/* Brand wordmark gets the gradient. */
.sidebar .brand h2,
.mobile-brand h2,
.brand h2 {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* Cards/panels: subtle navy lift + hairline border. */
.card,
.panel,
.stat-card {
    background: linear-gradient(180deg, var(--bg-card), #0d1424);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 18px 40px rgba(0, 0, 0, .35);
}

/* Active nav item gets a brand accent. */
.nav-menu a.active,
.nav-menu .active a {
    background: linear-gradient(90deg, rgba(79, 124, 255, .18), transparent);
    border-left: 3px solid var(--accent-color);
}

/* Language switcher styling. */
.language-switcher {
    background: var(--bg-darker);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: .4rem .6rem;
    font-size: .85rem;
    width: 100%;
}
.language-switcher:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ============================================================
   Match the app's shell look (clean brand-mark, nav, eyebrow, stat-cards).
   ============================================================ */
.sidebar { background: #0b1222; border-right: 1px solid var(--border-color); }
.sidebar .brand { display: flex; align-items: center; gap: .8rem; text-decoration: none; padding: .25rem .25rem 1rem; }
.brand-mark {
    display: grid; place-items: center; width: 44px; height: 44px; flex: none;
    border-radius: 14px; background: var(--gradient-brand); color: #fff;
    font-weight: 800; font-size: 1rem; letter-spacing: .02em;
    box-shadow: 0 8px 24px rgba(79, 124, 255, .35);
}
.brand-mark-sm { width: 32px; height: 32px; border-radius: 10px; font-size: .8rem; }
.brand-text strong { display: block; color: #fff; font-size: 1.15rem; font-weight: 800; line-height: 1.1; }
.brand-text small { display: block; color: var(--text-secondary); font-size: .72rem; margin-top: .15rem; }
.mobile-brand { display: flex; align-items: center; gap: .6rem; }
.mobile-brand h2 { font-size: 1.1rem; color: #fff; }

.nav-menu { list-style: none; padding: 0; margin: .75rem 0; display: grid; gap: .2rem; }
.nav-menu li { list-style: none; }
.nav-menu li.divider { height: 1px; background: var(--border-color); margin: .5rem .4rem; }
.nav-menu a {
    display: flex; align-items: center; gap: .5rem;
    color: var(--text-secondary); padding: .6rem .85rem; border-radius: 12px;
    text-decoration: none; font-weight: 500; font-size: .95rem;
    transition: background .12s ease, color .12s ease;
}
.nav-menu a:hover { color: #fff; background: rgba(255, 255, 255, .04); }
.nav-menu a.active {
    color: #fff;
    background: linear-gradient(90deg, rgba(79, 124, 255, .20), rgba(79, 124, 255, .02));
    box-shadow: inset 3px 0 0 var(--accent-color);
}
.nav-pro {
    margin-left: auto; font-size: .6rem; font-weight: 800; letter-spacing: .06em;
    color: var(--accent-color); border: 1px solid rgba(34, 211, 238, .4);
    border-radius: 6px; padding: .05rem .32rem;
}

/* Eyebrow + page heading like the app. */
.eyebrow { color: var(--primary-color); text-transform: uppercase; letter-spacing: .12em; font-size: .78rem; font-weight: 800; margin-bottom: .35rem; }
.page-header h1 { font-size: 2.25rem; font-weight: 800; color: #fff; margin: 0 0 .4rem; }

/* App-style stat cards. */
.stat-card { background: linear-gradient(180deg, var(--bg-card), #0d1424); border: 1px solid var(--border-color); border-radius: 18px; padding: 1.25rem 1.4rem; box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
.stat-card .stat-value { font-size: 2.1rem; font-weight: 800; color: #fff; }
.stat-card .stat-label { color: var(--text-secondary); }

/* App-style topbar (signed-in identity + plan). */
.main-content { display: flex; flex-direction: column; min-height: 100vh; padding: 0; }
.app-topbar {
    display: flex; align-items: center; gap: .6rem; min-height: 60px;
    padding: 0 2rem; border-bottom: 1px solid var(--border-color);
    background: rgba(10, 14, 26, .82); backdrop-filter: blur(14px);
    position: sticky; top: 0; z-index: 10;
}
.app-topbar strong { color: #fff; font-weight: 700; }
.app-topbar span { color: var(--text-secondary); }
.main-inner { padding: 2rem; flex: 1; }
