/* ============================================
   Stream System - Global Styles
   ============================================ */

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 12px;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--gray-800);
    line-height: 1.6;
}

/* Container */
.container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

/* Card */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 500px;
}

.card h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 8px;
}

.card .subtitle {
    color: var(--gray-500);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.form-group .required {
    color: var(--danger);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--gray-50);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: #fff;
}

.form-group small {
    display: block;
    margin-top: 4px;
    color: var(--gray-400);
    font-size: 0.8rem;
}

.form-group code {
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* OTP Input */
.otp-input {
    text-align: center;
    font-size: 2rem;
    letter-spacing: 0.5em;
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 8px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-secondary {
    background: var(--gray-600);
    color: #fff;
}

.btn-secondary:hover {
    background: var(--gray-700);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--gray-300);
    color: var(--gray-600);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* Alerts */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.95rem;
}

.alert p {
    margin: 0;
}

.alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

.alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* Footer link */
.footer-link {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-200);
}

.footer-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.footer-link a:hover {
    text-decoration: underline;
}

/* OTP Hint */
.otp-hint {
    text-align: center;
    font-size: 1.1rem;
    color: var(--gray-600);
    margin-bottom: 20px;
}

.otp-hint span {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.3rem;
}

/* ============================================
   Live Page
   ============================================ */
.live-page {
    background: var(--gray-900);
    min-height: 100vh;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.nav-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
    color: rgba(255,255,255,0.8);
    font-size: 0.9rem;
}

.nav-user strong {
    color: #fff;
}

/* Live Content */
.live-content {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 32px;
    min-height: calc(100vh - 70px);
}

/* Stream Wrapper */
.stream-wrapper {
    width: 100%;
    max-width: 1200px;
}

.stream-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.stream-header h1 {
    color: #fff;
    font-size: 1.5rem;
}

.live-badge {
    background: var(--danger);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.iframe-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 */
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

.iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Coming Soon */
.coming-soon {
    text-align: center;
    color: #fff;
    padding: 60px 20px;
}

.coming-soon-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

.coming-soon h1 {
    font-size: 3rem;
    margin-bottom: 16px;
    background: linear-gradient(135deg, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.coming-soon p {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 24px;
}

/* Countdown Box */
.countdown-box {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 32px 0;
}

.countdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.countdown-item span {
    font-size: 3rem;
    font-weight: 800;
    color: #fff;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 12px 20px;
    min-width: 90px;
    font-family: 'Courier New', monospace;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.countdown-item label {
    margin-top: 8px;
    color: rgba(255,255,255,0.6);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.start-time {
    color: rgba(255,255,255,0.5) !important;
    font-size: 0.9rem !important;
}

/* ============================================
   Live Layout — Video + Chat
   ============================================ */
.live-layout {
    display: flex;
    gap: 0;
    width: 100%;
    max-width: 1400px;
    height: calc(100vh - 70px);
}

.live-layout .stream-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.live-layout .stream-wrapper .iframe-container {
    flex: 1;
    padding-bottom: 0;
    min-height: 0;
}

/* Chat Panel */
.chat-panel {
    width: 380px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-left: 1px solid rgba(255,255,255,0.1);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--gray-900);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.chat-header h2 {
    color: #fff;
    font-size: 1rem;
    margin: 0;
}

.chat-viewers {
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    background: var(--gray-50);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: msgSlideIn 0.2s ease-out;
}

@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.chat-msg-me {
    align-self: flex-end;
}

.chat-msg-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 2px;
    padding-left: 4px;
}

.chat-msg-me .chat-msg-name {
    text-align: right;
    padding-right: 4px;
    padding-left: 0;
    color: var(--gray-500);
}

.chat-msg-text {
    background: #fff;
    padding: 8px 14px;
    border-radius: 16px 16px 16px 4px;
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--gray-800);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    word-break: break-word;
}

.chat-msg-me .chat-msg-text {
    background: var(--primary);
    color: #fff;
    border-radius: 16px 16px 4px 16px;
}

.chat-msg-time {
    font-size: 0.7rem;
    color: var(--gray-400);
    margin-top: 2px;
    padding-left: 4px;
}

.chat-msg-me .chat-msg-time {
    text-align: right;
    padding-right: 4px;
    padding-left: 0;
}

.chat-loading,
.chat-empty {
    text-align: center;
    color: var(--gray-400);
    font-size: 0.9rem;
    padding: 40px 20px;
    align-self: center;
}

/* Chat Input */
.chat-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid var(--gray-200);
}

.chat-input-row {
    display: flex;
    gap: 8px;
}

.chat-input-row input {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 24px;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-row input:focus {
    border-color: var(--primary);
}

.btn-chat-send {
    padding: 10px 20px;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-error {
    color: var(--danger);
    font-size: 0.8rem;
    margin-top: 6px;
    min-height: 18px;
}

/* Responsive */
@media (max-width: 900px) {
    .live-layout {
        flex-direction: column;
        height: auto;
    }
    .live-layout .stream-wrapper .iframe-container {
        padding-bottom: 56.25%;
    }
    .chat-panel {
        width: 100%;
        min-width: unset;
        height: 50vh;
        border-left: none;
        border-top: 1px solid rgba(255,255,255,0.1);
    }
}

/* ============================================
   Admin Page
   ============================================ */
.login-page {
    background: linear-gradient(135deg, #1e1b4b, #312e81);
}

.admin-page {
    background: var(--gray-100);
    min-height: 100vh;
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.admin-sidebar {
    width: 260px;
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    padding: 24px 20px;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.sidebar-nav a.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer .btn {
    width: 100%;
    border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.7);
}

.sidebar-footer .btn:hover {
    border-color: #fff;
    color: #fff;
}

/* Admin Main */
.admin-main {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
}

.admin-header {
    margin-bottom: 32px;
}

.admin-header h1 {
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 4px;
}

.admin-header p {
    color: var(--gray-500);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
}

.stat-icon {
    font-size: 2rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-50);
    border-radius: 12px;
}

.stat-number {
    display: block;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--gray-900);
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: var(--gray-500);
}

/* Admin Section */
.admin-section {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.admin-section h2 {
    font-size: 1.25rem;
    color: var(--gray-800);
    margin-bottom: 16px;
}

.admin-section h3 {
    font-size: 1.1rem;
    color: var(--gray-700);
    margin-bottom: 16px;
}

/* Admin Toolbar */
.admin-toolbar {
    margin-bottom: 20px;
}

.search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

.search-form input {
    padding: 10px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.95rem;
    width: 300px;
}

.search-form input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Data Table */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    font-size: 0.9rem;
}

.data-table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.05em;
}

.data-table tr:hover {
    background: var(--gray-50);
}

.data-table .text-center {
    text-align: center;
    color: var(--gray-400);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-email {
    background: #dbeafe;
    color: #1e40af;
}

.badge-phone {
    background: #dcfce7;
    color: #166534;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-top: 20px;
}

.page-info {
    color: var(--gray-500);
    font-size: 0.9rem;
}

/* Admin Form */
.admin-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.inline-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.inline-form .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* Preview Frame */
.preview-frame {
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    overflow: hidden;
}

.preview-frame iframe {
    display: block;
    width: 100%;
    height: 400px;
}

/* Log Container */
.log-container {
    background: var(--gray-900);
    border-radius: 8px;
    padding: 16px;
    max-height: 400px;
    overflow-y: auto;
}

.log-entry {
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: #a5f3fc;
    padding: 4px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    word-break: break-all;
}

/* Text utilities */
.text-center { text-align: center; }
.text-muted { color: var(--gray-400); }
.text-danger { color: var(--danger); font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
    .admin-sidebar {
        width: 200px;
    }
    .admin-main {
        margin-left: 200px;
        padding: 20px;
    }
    .countdown-box {
        gap: 12px;
    }
    .countdown-item span {
        font-size: 2rem;
        min-width: 60px;
        padding: 8px 12px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .admin-form .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .admin-sidebar {
        display: none;
    }
    .admin-main {
        margin-left: 0;
    }
    .card {
        padding: 24px;
    }
}
