/* ============================================
   KARAOKE MOBILE — iOS Inspired Design
   Matching TV App Design Language
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Base Colors — matching TV app */
    --bg-primary: #0A0E14;
    --bg-secondary: #12171F;
    --bg-tertiary: #1A2028;

    /* Glass Materials */
    --glass-light: rgba(255, 255, 255, 0.06);
    --glass-medium: rgba(255, 255, 255, 0.10);
    --glass-heavy: rgba(255, 255, 255, 0.14);
    --glass-border: rgba(255, 255, 255, 0.12);

    /* Accent Colors */
    --accent-primary: #E94B8A;
    --accent-secondary: #A855F7;
    --accent-gradient: linear-gradient(135deg, #E94B8A 0%, #A855F7 100%);

    /* Text Hierarchy */
    --text-primary: rgba(255, 255, 255, 0.95);
    --text-secondary: rgba(255, 255, 255, 0.70);
    --text-tertiary: rgba(255, 255, 255, 0.45);

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --glow-accent: 0 0 24px rgba(233, 75, 138, 0.2);

    /* Typography */
    --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: var(--font-primary);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* ========== Container ========== */

.mobile-container {
    max-width: 480px;
    margin: 0 auto;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
}

/* ========== Screens ========== */

.screen {
    display: none;
    min-height: 100vh;
    flex-direction: column;
}

.screen.active {
    display: flex;
}

/* ========== Connection Screen ========== */

.connect-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    text-align: center;
}

.connect-icon {
    position: relative;
    font-size: 72px;
    margin-bottom: var(--space-6);
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-ring {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    opacity: 0;
    animation: pulseRing 2s ease-out infinite;
}

@keyframes pulseRing {
    0% {
        transform: scale(0.5);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.connect-title {
    font-size: 28px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--space-3);
}

.connect-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: var(--space-5);
}

.connect-loader {
    width: 200px;
    height: 3px;
    background: var(--glass-light);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.loader-bar {
    width: 40%;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    animation: loaderSlide 1.5s ease-in-out infinite;
}

@keyframes loaderSlide {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(350%);
    }
}

/* ========== Error Screen ========== */

.error-visual {
    font-size: 64px;
    margin-bottom: var(--space-5);
}

.btn-retry {
    margin-top: var(--space-4);
    padding: var(--space-3) var(--space-6);
    background: var(--accent-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-family: var(--font-primary);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

.btn-retry:active {
    transform: scale(0.95);
}

/* ========== Header ========== */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-4);
    padding-top: max(var(--space-4), env(safe-area-inset-top));
    background: rgba(10, 14, 20, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.session-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(76, 175, 80, 0.15);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: #66BB6A;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #4CAF50;
    border-radius: 50%;
    animation: statusPulse 2s ease infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ========== Username Bar ========== */

.username-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--glass-light);
    border-bottom: 1px solid var(--glass-border);
}

.username-icon {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.username-bar input {
    flex: 1;
    padding: var(--space-2) var(--space-3);
    background: var(--glass-medium);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 14px;
    outline: none;
    transition: all var(--transition-fast);
}

.username-bar input:focus {
    border-color: var(--accent-primary);
    background: var(--glass-heavy);
}

.username-bar input:disabled {
    opacity: 0.7;
    background: transparent;
    border-color: transparent;
}

.username-save-btn {
    padding: var(--space-2) var(--space-4);
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.username-save-btn:active {
    transform: scale(0.95);
}

/* ========== Info Tab ========== */

.info-content {
    flex: 1;
    padding: var(--space-5) var(--space-4);
    overflow-y: auto;
}

.info-section {
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
}

.info-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-4);
}

.info-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-secondary);
    font-size: 14px;
}

.info-item:last-child {
    border-bottom: none;
}

.info-item svg {
    color: var(--accent-primary);
    flex-shrink: 0;
}


/* ========== Search ========== */

.search-wrapper {
    padding: var(--space-4);
    padding-bottom: 0;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-tertiary);
    pointer-events: none;
}

.search-box input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.search-box input:focus {
    border-color: var(--accent-primary);
    background: var(--glass-medium);
}

/* ========== Filter Chips ========== */

.filter-chips {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.chip {
    padding: 8px 16px;
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip.active {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    font-weight: 600;
}

.chip:active {
    transform: scale(0.95);
}

/* ========== Video List ========== */

.video-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3) var(--space-4);
    padding-bottom: 100px;
    -webkit-overflow-scrolling: touch;
}

.video-card {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.video-card:active {
    transform: scale(0.98);
    background: var(--glass-medium);
}

.video-thumb {
    width: 64px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.video-info {
    flex: 1;
    min-width: 0;
}

.video-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.video-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

.video-artist,
.video-requester {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.video-artist svg,
.video-requester svg {
    flex-shrink: 0;
    opacity: 0.7;
}

.video-requester {
    color: var(--accent-primary);
    font-weight: 500;
}

.btn-add {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-size: 20px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.btn-add:active {
    transform: scale(0.9);
}

.btn-add.added {
    background: rgba(76, 175, 80, 0.2);
    color: #66BB6A;
    font-size: 16px;
}

/* ========== Queue Tab ========== */

.queue-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    padding-bottom: var(--space-2);
}

.queue-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.queue-count-pill {
    padding: 4px 12px;
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ========== Playback Controls ========== */

.playback-controls {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
}

.control-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3);
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.control-btn:active {
    transform: scale(0.97);
    background: var(--glass-medium);
}

.control-btn.accent {
    background: var(--accent-gradient);
    border-color: transparent;
    color: white;
    font-weight: 600;
}

.control-btn.accent:active {
    opacity: 0.9;
}

/* ========== Queue List ========== */

.queue-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-2) var(--space-4);
    padding-bottom: 100px;
    -webkit-overflow-scrolling: touch;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    transition: box-shadow var(--transition-fast), transform var(--transition-fast);
    position: relative;
    user-select: none;
    -webkit-user-select: none;
}

/* Drag Handle */
.drag-handle {
    width: 24px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--text-tertiary);
    cursor: grab;
    flex-shrink: 0;
    touch-action: none;
    border-radius: 4px;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.drag-handle:active {
    cursor: grabbing;
    color: var(--accent-primary);
    background: rgba(233, 75, 138, 0.1);
}

.queue-number {
    width: 28px;
    height: 28px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.queue-actions {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--glass-light);
    border-radius: var(--radius-full);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-icon:active {
    transform: scale(0.9);
}

.btn-icon.danger {
    background: rgba(244, 67, 54, 0.15);
    color: #EF5350;
}

.btn-icon.danger:active {
    background: rgba(244, 67, 54, 0.3);
}

/* Drag States */
.queue-item.dragging {
    position: fixed;
    z-index: 1000;
    box-shadow: var(--shadow-lg), var(--glow-accent);
    opacity: 0.95;
    pointer-events: none;
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.queue-item-placeholder {
    border: 2px dashed var(--accent-primary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    background: rgba(233, 75, 138, 0.05);
}

/* Queue Empty */
.queue-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
    text-align: center;
}

.empty-visual {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--glass-light);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-4);
}

.empty-icon {
    font-size: 36px;
}

.empty-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-hint {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* ========== Bottom Navigation ========== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    display: flex;
    background: rgba(10, 14, 20, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border);
    padding: var(--space-2) 0;
    padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: var(--space-2) 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-family: var(--font-primary);
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}

.nav-item.active {
    color: var(--accent-primary);
}

.nav-icon-svg {
    transition: all var(--transition-fast);
}

.nav-item.active .nav-icon-svg {
    stroke: var(--accent-primary);
    filter: drop-shadow(0 0 6px rgba(233, 75, 138, 0.3));
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

.nav-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 20px);
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========== Toast ========== */

.toast {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    padding: var(--space-3) var(--space-5);
    background: var(--bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-full);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: top var(--transition-base);
    z-index: 1000;
    white-space: nowrap;
}

.toast.show {
    top: max(20px, env(safe-area-inset-top));
}

/* ========== Loading Spinner ========== */

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--glass-light);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-top: var(--space-4);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== Tab Content ========== */

.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ========== Scrollbar Styling ========== */

::-webkit-scrollbar {
    width: 3px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--glass-medium);
    border-radius: var(--radius-full);
}

/* ========== Animations ========== */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.video-card,
.queue-item {
    animation: fadeInUp 0.3s ease backwards;
}

.video-card:nth-child(1) {
    animation-delay: 0s;
}

.video-card:nth-child(2) {
    animation-delay: 0.05s;
}

.video-card:nth-child(3) {
    animation-delay: 0.1s;
}

.video-card:nth-child(4) {
    animation-delay: 0.15s;
}

.video-card:nth-child(5) {
    animation-delay: 0.2s;
}