/* ============================================================
   @alexlamasg — Streaming Platform Styles
   ============================================================ */

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

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #111119;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16161f;
    --text-primary: #e8e8ed;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --red-live: #ef4444;
    --green-online: #22c55e;
    --border: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(99, 102, 241, 0.2);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 48px rgba(0, 0, 0, 0.5);
    --transition: 0.2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ---- Background Pattern ---- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.03) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ============================================================
   Header
   ============================================================ */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header__logo {
    font-size: 24px;
    line-height: 1;
}

.header__title {
    font-size: 1.15rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.header__status {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ---- Live Badge ---- */
.live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    opacity: 0.5;
    transition: var(--transition);
}

.live-badge--active {
    opacity: 1;
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.1);
}

.live-badge__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--red-live);
}

.live-badge--active .live-badge__dot {
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

.live-badge__text {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--red-live);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---- Viewer Count ---- */
.viewer-count {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.15);
}

.viewer-count__icon {
    width: 16px;
    height: 16px;
    color: var(--green-online);
}

.viewer-count__number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--green-online);
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   Main Layout
   ============================================================ */
.main {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    height: calc(100vh - 53px);
    max-width: 1920px;
    margin: 0 auto;
}

/* ============================================================
   Player Section
   ============================================================ */
.player-section {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.player-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

.player-container {
    width: 100%;
    height: 100%;
    position: relative;
}

/* OvenPlayer full sizing */
.player-container .op-wrapper {
    width: 100% !important;
    height: 100% !important;
}

/* ---- Player Placeholder ---- */
.player-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(180deg, #0a0a14, #111124);
    z-index: 5;
}

.player-placeholder__icon {
    font-size: 56px;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.player-placeholder__text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

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

/* ---- Stream Info Bar ---- */
.stream-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.stream-info__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.stream-info__desc {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.stream-info__right {
    display: flex;
    gap: 12px;
    align-items: center;
}

.stream-info__tech,
.stream-info__latency {
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--accent-glow);
    color: var(--accent-hover);
    border: 1px solid var(--border-accent);
}

/* ---- Embed Button ---- */
.embed-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border: 1px solid var(--border-accent);
    border-radius: 6px;
    background: var(--accent-glow);
    color: var(--accent-hover);
    font-size: 0.72rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.embed-btn:hover {
    background: rgba(99, 102, 241, 0.25);
    border-color: var(--accent);
}

/* ============================================================
   Embed Modal
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.modal-overlay--visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    width: 90%;
    max-width: 560px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

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

.modal__title {
    font-size: 0.95rem;
    font-weight: 600;
}

.modal__close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color var(--transition);
}

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

.modal__body {
    padding: 20px;
}

.modal__desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.modal__code-wrapper {
    position: relative;
    margin-bottom: 14px;
}

.modal__code {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--accent-hover);
    font-family: 'Courier New', monospace;
    font-size: 0.78rem;
    resize: none;
    outline: none;
}

.modal__copy {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 5px 12px;
    border: 1px solid var(--border-accent);
    border-radius: 6px;
    background: var(--accent);
    color: white;
    font-size: 0.72rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition);
}

.modal__copy:hover {
    background: var(--accent-hover);
}

.modal__options {
    display: flex;
    gap: 16px;
    margin-bottom: 14px;
}

.modal__label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

.modal__input {
    width: 100px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.82rem;
    outline: none;
}

.modal__input:focus {
    border-color: var(--accent);
}

/* ============================================================
   Chat Section
   ============================================================ */
.chat-section {
    border-left: 1px solid var(--border);
    background: var(--bg-secondary);
}

.chat {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat__title {
    font-size: 0.9rem;
    font-weight: 600;
}

.chat__users {
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
}

/* ---- Chat Messages ---- */
.chat__messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.chat__messages::-webkit-scrollbar {
    width: 5px;
}

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

.chat__messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.chat__messages::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ---- Welcome Message ---- */
.chat__welcome {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.chat__welcome p:first-child {
    font-size: 1rem;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.chat__welcome-sub {
    font-size: 0.75rem;
}

/* ---- Chat Message ---- */
.chat__msg {
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    line-height: 1.5;
    transition: background 0.15s;
}

.chat__msg:hover {
    background: rgba(255, 255, 255, 0.03);
}

.chat__msg--new {
    animation: msgSlideIn 0.25s ease-out;
}

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

.chat__msg-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-hover);
    margin-right: 6px;
}

.chat__msg-name--me {
    color: #f59e0b;
}

.chat__msg-text {
    font-size: 0.84rem;
    color: var(--text-primary);
    word-break: break-word;
}

.chat__msg-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: 8px;
    opacity: 0;
    transition: opacity 0.15s;
}

.chat__msg:hover .chat__msg-time {
    opacity: 1;
}

/* System Messages */
.chat__msg--system {
    text-align: center;
    padding: 4px;
}

.chat__msg-system-text {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-style: italic;
}

/* ---- Chat Input ---- */
.chat__input-wrapper {
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.chat__identity {
    padding: 8px 18px 0;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.chat__identity-label {
    color: var(--text-muted);
}

.chat__identity strong {
    color: var(--accent-hover);
    font-weight: 600;
}

.chat__form {
    display: flex;
    padding: 10px 14px;
    gap: 8px;
}

.chat__input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

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

.chat__input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.chat__send {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}

.chat__send svg {
    width: 18px;
    height: 18px;
}

.chat__send:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
}

.chat__send:active {
    transform: scale(0.95);
}

/* ============================================================
   Toast Overrides
   ============================================================ */
.geo-toast {
    font-family: var(--font) !important;
}

.toastify {
    font-family: var(--font) !important;
}

/* ============================================================
   Responsive — Tablet
   ============================================================ */
@media (max-width: 1024px) {
    .main {
        grid-template-columns: 1fr 320px;
    }
}

/* ============================================================
   Responsive — Mobile
   ============================================================ */
@media (max-width: 768px) {
    .header {
        padding: 10px 16px;
    }

    .header__title {
        font-size: 1rem;
    }

    .main {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        height: auto;
        min-height: calc(100vh - 48px);
    }

    .player-section {
        height: auto;
    }

    .player-wrapper {
        aspect-ratio: 16 / 9;
        height: auto;
    }

    .player-container {
        aspect-ratio: 16 / 9;
    }

    .stream-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 16px;
    }

    .stream-info__right {
        gap: 8px;
    }

    .chat-section {
        border-left: none;
        border-top: 1px solid var(--border);
        height: 50vh;
        min-height: 300px;
    }

    .live-badge {
        padding: 4px 10px;
    }

    .live-badge__text {
        font-size: 0.65rem;
    }

    .viewer-count {
        padding: 4px 10px;
    }

    .viewer-count__number {
        font-size: 0.78rem;
    }
}

/* ============================================================
   Responsive — Small Mobile
   ============================================================ */
@media (max-width: 480px) {
    .header__logo {
        font-size: 20px;
    }

    .header__title {
        font-size: 0.9rem;
    }

    .chat-section {
        min-height: 250px;
    }

    .chat__form {
        padding: 8px 10px;
    }

    .chat__input {
        padding: 8px 12px;
        font-size: 0.82rem;
    }

    .chat__send {
        width: 38px;
        height: 38px;
    }
}

/* ============================================================
   Accessibility
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
