/* Stream Gate v3.4.0 – Frontend Styles */

/* ── CSS Variables ──────────────────────────────────────────── */
.sg-wrapper {
    --sg-accent:      #1a3a6b;
    --sg-accent-dark: #142d55;
    --sg-accent-glow: rgba(26, 58, 107, 0.18);
    --sg-red:         #e02424;
    --sg-text:        #111827;
    --sg-muted:       #6b7280;
    --sg-border:      #e5e7eb;
    --sg-white:       #ffffff;
    --sg-radius:      12px;
    --sg-shadow:      0 1px 3px rgba(0,0,0,0.07), 0 4px 16px rgba(0,0,0,0.06);
    --sg-shadow-lg:   0 4px 6px rgba(0,0,0,0.05), 0 10px 40px rgba(0,0,0,0.10);

    max-width: 720px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    color: var(--sg-text);
    line-height: 1.5;
}

/* ── LIVE badge ─────────────────────────────────────────────── */
.sg-live-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--sg-red);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    padding: 4px 10px 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    user-select: none;
}

/* rgba() literals used — CSS custom properties are not accessible
   inside @keyframes on Safari < 15.4 */
.sg-live-dot {
    width: 7px;
    height: 7px;
    background: #fff;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
    animation: sg-pulse 1.6s ease-in-out infinite;
}

@keyframes sg-pulse {
    0%   { box-shadow: 0 0 0 0   rgba(255, 255, 255, 0.6); }
    60%  { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0);   }
    100% { box-shadow: 0 0 0 0   rgba(255, 255, 255, 0);   }
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .sg-live-dot      { animation: none; box-shadow: none; }
    .sg-btn           { transition: none; }
    .sg-btn-spinner   { animation: none; }
    .sg-logout-btn    { transition: none; }
    .sg-input-wrap input { transition: none; }
}

/* ── OFFLINE state ──────────────────────────────────────────── */
.sg-offline-wrap {
    text-align: center;
    padding: 4rem 2rem;
    border: 1px solid var(--sg-border);
    border-radius: var(--sg-radius);
    background: var(--sg-white);
}

.sg-offline-wrap .sg-offline-icon svg {
    width: 48px;
    height: 48px;
    stroke: var(--sg-muted);
    display: block;
    margin: 0 auto 1rem;
}

.sg-offline-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--sg-text);
    margin: 0 0 0.5rem;
}

.sg-offline-msg {
    color: var(--sg-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* ── PLAYER section ─────────────────────────────────────────── */
.sg-player-section {
    display: flex;
    flex-direction: column;
}

/* FIX (CSS-1): Single merged definition — badge+title left, logout right.
   Previously split across two blocks (lines 112 and 374) causing cascade
   fragility; merged here into one authoritative rule. */
.sg-player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--sg-border);
    margin-bottom: 14px; /* FIX (CSS-3): gap between header and player */
}

.sg-player-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

/* FIX (CSS-2): Single merged definition — previously split across two blocks
   (lines 120 and 385); second block added overflow properties orphaned from
   the first. Merged into one rule. */
.sg-player-title {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--sg-text);
    margin: 0;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* border-radius applied to both container and .video-js so theme-injected
   wrappers don't expose square corners */
.sg-player-wrap {
    border-radius: var(--sg-radius);
    overflow: hidden;
    background: #000;
    box-shadow: var(--sg-shadow-lg);
}

.sg-player-wrap .video-js {
    width: 100% !important;
    aspect-ratio: 16 / 9;
    height: auto !important;
    border-radius: var(--sg-radius);
}

/* ── GATE (form) section ────────────────────────────────────── */
.sg-gate-wrap {
    display: flex;
    flex-direction: column;
}

.sg-gate-header {
    text-align: center;
    padding: 2.5rem 1rem 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.sg-gate-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--sg-text);
    margin: 0;
    letter-spacing: -0.02em;
}

.sg-gate-subtitle {
    color: var(--sg-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* ── Card ───────────────────────────────────────────────────── */
.sg-card {
    background: var(--sg-white);
    border: 1px solid var(--sg-border);
    border-top: 3px solid var(--sg-accent);
    border-radius: var(--sg-radius);
    padding: 2rem 2.25rem 2.25rem;
    box-shadow: var(--sg-shadow);
}

/* ── Form ───────────────────────────────────────────────────── */
.sg-form {
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

.sg-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.sg-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--sg-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.sg-req { color: var(--sg-red); }

.sg-input-wrap {
    position: relative;
}

.sg-input-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #9ca3af;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.sg-input-icon svg {
    width: 16px;
    height: 16px;
}

.sg-input-wrap input {
    width: 100%;
    padding: 0.65rem 0.85rem 0.65rem 2.4rem;
    border: 1.5px solid var(--sg-border);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--sg-text);
    background: var(--sg-white);
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
    -webkit-appearance: none;
    appearance: none;
}

.sg-input-wrap input::placeholder {
    color: #d1d5db;
}

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

.sg-input-wrap input.sg-input-error {
    border-color: var(--sg-red);
    box-shadow: 0 0 0 3px rgba(224, 36, 36, 0.08);
}

.sg-field-error {
    font-size: 0.78rem;
    color: var(--sg-red);
    min-height: 1em;
    padding-left: 2px;
}

.sg-ajax-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 0.7rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

/* ── Submit button ──────────────────────────────────────────── */
.sg-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 0.5rem;
    padding: 0.8rem 1.75rem;
    background: var(--sg-accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
    width: 100%;
    letter-spacing: 0.01em;
    font-family: inherit;
}

.sg-btn:hover:not(:disabled) {
    background: var(--sg-accent-dark);
    box-shadow: 0 4px 12px var(--sg-accent-glow);
}

.sg-btn:active:not(:disabled) {
    transform: scale(0.99);
}

.sg-btn:disabled {
    opacity: 0.75;
    cursor: not-allowed;
}

.sg-btn-arrow {
    transition: transform 0.15s;
}

.sg-btn:hover:not(:disabled) .sg-btn-arrow {
    transform: translateX(3px);
}

.sg-btn-spinner {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: sg-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.sg-btn.sg-loading .sg-btn-text    { opacity: 0.7; }
.sg-btn.sg-loading .sg-btn-arrow   { display: none; }
.sg-btn.sg-loading .sg-btn-spinner { display: inline-block; }

@keyframes sg-spin {
    to { transform: rotate(360deg); }
}

/* ── Logout button ──────────────────────────────────────────── */
.sg-logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: transparent;
    border: 1.5px solid var(--sg-border);
    border-radius: 6px;
    color: var(--sg-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
    line-height: 1;
}

.sg-logout-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.sg-logout-btn:hover:not(:disabled) {
    border-color: var(--sg-red);
    color: var(--sg-red);
    background: #fef2f2;
}

.sg-logout-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Thank-you message ──────────────────────────────────────── */
.sg-thankyou {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #15803d;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin: 1rem 0 0;
}

/* ── Notice ─────────────────────────────────────────────────── */
.sg-notice {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* ── Responsive ─────────────────────────────────────────────── */
/* FIX (CSS-4): Single merged @media 560px block — previously split across
   two blocks (lines 358 and 427); merged into one authoritative block. */
@media (max-width: 560px) {
    .sg-card        { padding: 1.5rem 1.25rem; }
    .sg-gate-header { padding: 1.75rem 1rem 1.5rem; }
    .sg-gate-title  { font-size: 1.4rem; }
    .sg-player-title { font-size: 1rem; }
    /* Collapse logout label to icon-only on small screens */
    .sg-logout-btn .sg-logout-label { display: none; }
    .sg-logout-btn { padding: 5px 8px; }
}
