/* 
 * StreamSync - Premium Dark Mode Web App Styles
 */

/* ================== CSS Variables ================== */
:root {
    --bg-base: #0a0a0c;
    --bg-surface: #141419;
    --bg-elevated: #1e1e24;
    
    --brand-primary: #6366f1;
    --brand-primary-hover: #4f46e5;
    
    --brand-secondary: #3b82f6;
    --brand-secondary-hover: #2563eb;
    
    --accent-danger: #ef4444;
    --accent-danger-hover: #dc2626;
    --accent-danger-bg: rgba(239, 68, 68, 0.1);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 9999px;
    
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.2), 0 4px 6px -2px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.4);
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow: hidden; /* Prevent scrolling, app-like feel */
    height: 100vh;
    height: 100dvh;
}

/* ================== Layout Structure ================== */
.app-container {
    width: 100%;
    height: 100%;
    position: relative;
    max-width: 600px; /* Constrain on desktop to mobile size */
    margin: 0 auto;
    background-color: var(--bg-base);
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 24px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: opacity var(--transition-fast), transform var(--transition-bounce), visibility var(--transition-fast);
    z-index: 10;
}

.view.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    z-index: 20;
}

.view.hidden {
    display: none; /* Only use this if avoiding layout calculation */
}
/* We override hidden locally through JS classes later to fade out gracefully */

/* ================== Typography ================== */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

p {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ================== Buttons ================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    transition: all var(--transition-fast);
    text-decoration: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.96);
}

.btn-large {
    width: 100%;
    padding: 24px 20px;
    flex-direction: column;
    border-radius: var(--radius-lg);
    gap: 8px;
}

.btn-large .icon {
    font-size: 2.5rem;
    margin-bottom: 4px;
}

.btn-large .text {
    font-size: 1.25rem;
    color: var(--text-primary);
}

.btn-large .subtext {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    font-weight: 400;
}

.btn-primary {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-hover));
    box-shadow: var(--shadow-glow);
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-primary:active .text { color: #fff; }

.btn-secondary {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--border-strong);
}

.btn-danger {
    background-color: var(--accent-danger);
    color: #fff;
}

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

.btn-pill {
    border-radius: var(--radius-pill);
    padding: 16px 32px;
    font-size: 1.125rem;
    box-shadow: var(--shadow-md);
    gap: 12px;
}

.btn-sm {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
}

.btn-ghost {
    background: rgba(255,255,255,0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

/* ================== Specific Views ================== */

/* Home View */
.hero-header {
    margin-top: 10vh;
    margin-bottom: 48px;
    text-align: center;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Setup View */
.status-header {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 32px;
}

.qr-container {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid var(--border-subtle);
    margin-bottom: 24px;
}

.qr-code-wrapper {
    background: #fff;
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    box-shadow: var(--shadow-glow);
}

.instruction-text {
    text-align: center;
    font-size: 0.9375rem;
}

.url-share {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.3);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    margin-bottom: auto;
}

.url-text {
    font-family: monospace;
    color: var(--text-primary);
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 12px;
}

footer {
    display: flex;
    justify-content: center;
    padding-top: 24px;
    margin-top: auto;
}

/* Streaming Mode Classes */

.stream-backdrop {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    margin-bottom: 24px;
}

.live-indicator {
    position: absolute;
    top: 16px;
    left: 16px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    z-index: 10;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent-danger);
    border-radius: 50%;
    animation: blink 1.5s infinite ease-in-out;
}

@keyframes blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.camera-preview {
    width: 100%;
    height: 100%;
    background: #000;
}

.camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror self view */
}

.stream-controls {
    display: flex;
    justify-content: center;
    margin-bottom: 24px;
}

/* Animations & Loaders */
.loader-pulse {
    width: 8px;
    height: 8px;
    background-color: var(--brand-primary);
    border-radius: 50%;
    margin: 16px auto 0;
    position: relative;
    animation: loader 1s infinite alternate ease-in-out;
}

.loader-pulse::before, .loader-pulse::after {
    content: '';
    position: absolute;
    top: 0;
    width: 8px;
    height: 8px;
    background-color: var(--brand-primary);
    border-radius: 50%;
    animation: loader 1s infinite alternate ease-in-out;
}

.loader-pulse::before {
    left: -20px;
    animation-delay: -0.2s;
}

.loader-pulse::after {
    left: 20px;
    animation-delay: 0.2s;
}

@keyframes loader {
    0% { transform: scale(0.8); opacity: 0.5; }
    100% { transform: scale(1.2); opacity: 1; }
}

/* Form inputs for Monitor Setup */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: auto;
}

.input-group input {
    width: 100%;
    padding: 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 1.125rem;
    font-family: monospace;
    text-align: center;
    transition: border-color var(--transition-fast);
}

.input-group input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Full Screen Monitor Mode */
.view.monitor-full {
    padding: 0;
    background: #000;
}

#remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.overlay-controls {
    position: absolute;
    bottom: 40px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: center;
    z-index: 30;
}

.live-badge {
    position: absolute;
    top: 30px;
    left: 20px;
    background: var(--accent-danger);
    color: white;
    padding: 4px 12px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 0.875rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    z-index: 30;
}
