/* ==========================================================================
   SyncTune - Modern YouTube-Inspired UI
   ========================================================================== */

:root {
    /* Color Palette - Light Mode (Default) */
    --bg-primary: #f9f9f9;
    --bg-secondary: #ffffff;
    --text-primary: #0f0f0f;
    --text-secondary: #606060;
    --accent-color: #cc0000; /* Classic YouTube Red */
    --accent-hover: #ff0000;
    --border-color: #e5e5e5;
    
    /* Glassmorphism settings */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);

    /* Typography */
    --font-family: 'Roboto', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    
    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Color Palette - Dark Mode */
        --bg-primary: #0f0f0f;
        --bg-secondary: #212121;
        --text-primary: #f1f1f1;
        --text-secondary: #aaaaaa;
        --accent-color: #ff0000;
        --accent-hover: #ff4d4d;
        --border-color: #3f3f3f;
        
        /* Glassmorphism dark mode */
        --glass-bg: rgba(33, 33, 33, 0.7);
        --glass-border: rgba(255, 255, 255, 0.05);
        --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
    }
}

/* Fallback/Explicit dark mode class if UI wants to toggle manually */
body.dark-mode {
    --bg-primary: #0f0f0f;
    --bg-secondary: #212121;
    --text-primary: #f1f1f1;
    --text-secondary: #aaaaaa;
    --accent-color: #ff0000;
    --accent-hover: #ff4d4d;
    --border-color: #3f3f3f;
    --glass-bg: rgba(33, 33, 33, 0.7);
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-color);
}

/* ==========================================================================
   Typography Utilities
   ========================================================================== */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-accent { color: var(--accent-color); }
.text-sm { font-size: 0.875rem; }
.text-md { font-size: 1rem; }
.text-lg { font-size: 1.25rem; }
.text-xl { font-size: 1.5rem; font-weight: 600; }
.text-2xl { font-size: 2rem; font-weight: 700; }
.font-bold { font-weight: bold; }
.font-medium { font-weight: 500; }
.text-center { text-align: center; }

/* ==========================================================================
   Layout Utilities
   ========================================================================== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.gap-xs { gap: 0.25rem; }
.gap-sm { gap: 0.5rem; }
.gap-md { gap: 1rem; }
.gap-lg { gap: 1.5rem; }
.gap-xl { gap: 2rem; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid-cols-auto { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }

.w-full { width: 100%; }
.h-full { height: 100%; }
.h-screen { height: 100vh; }
.max-w-screen-xl { max-width: 1280px; margin-left: auto; margin-right: auto; }

.p-sm { padding: 0.5rem; }
.p-md { padding: 1rem; }
.p-lg { padding: 1.5rem; }
.py-sm { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.px-sm { padding-left: 0.5rem; padding-right: 0.5rem; }
.py-md { padding-top: 1rem; padding-bottom: 1rem; }
.px-md { padding-left: 1rem; padding-right: 1rem; }
.m-sm { margin: 0.5rem; }
.m-md { margin: 1rem; }
.mt-sm { margin-top: 0.5rem; }
.mt-md { margin-top: 1rem; }
.mb-sm { margin-bottom: 0.5rem; }
.mb-md { margin-bottom: 1rem; }

.hidden { display: none; }

/* ==========================================================================
   UI Components & Glassmorphism
   ========================================================================== */

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden; /* For inner scrolling */
}

/* Topbar / Header (Glassmorphism) */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1.5rem;
    height: 64px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
}

/* Sidebar */
.sidebar {
    width: 240px;
    background-color: var(--bg-primary);
    padding: 1rem 0;
    overflow-y: auto;
    transition: width var(--transition-smooth);
    border-right: 1px solid var(--border-color);
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-radius: 0.5rem;
    margin: 0 0.5rem 0.25rem 0.5rem;
    transition: background-color var(--transition-fast);
}

.sidebar-item:hover {
    background-color: var(--bg-secondary);
}

.sidebar-item.active {
    background-color: var(--bg-secondary);
    font-weight: 500;
}

/* Content Area */
.content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    padding-bottom: 160px;
}

/* Cards (Glassmorphism) */
.card {
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    border: 1px solid var(--border-color);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

.card-glass {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
    padding: 1.5rem;
}

/* Thumbnail / Image container */
.thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    background-color: var(--border-color);
    border-radius: 12px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(204, 0, 0, 0.3);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: transparent;
    color: var(--text-primary);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: var(--bg-secondary);
}

/* Input Fields */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(204, 0, 0, 0.2);
}

/* Search Bar (YouTube Style) */
.search-container {
    display: flex;
    align-items: center;
    max-width: 600px;
    width: 100%;
    margin: 0 2rem;
}

.search-input {
    flex: 1;
    padding: 0.5rem 1rem;
    border-radius: 20px 0 0 20px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
}
.search-input:focus {
    outline: none;
    border-color: #1c62b9; /* Classic secondary focus color */
}

.search-btn {
    padding: 0.5rem 1.25rem;
    border-radius: 0 20px 20px 0;
    border: 1px solid var(--border-color);
    border-left: none;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
}
.search-btn:hover {
    background-color: var(--border-color);
}

/* Floating Player / Miniplayer (Glassmorphism) */
.floating-player {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 450px;
    max-width: calc(100vw - 40px);
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 12px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp var(--transition-smooth) forwards;
}

/* ==========================================================================
   Animations
   ========================================================================== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.animate-fade-in {
    animation: fadeIn var(--transition-smooth) forwards;
}

.animate-slide-up {
    animation: slideUp var(--transition-smooth) forwards;
}

/* Smooth micro-animations for interactive elements */
.hover-scale {
    transition: transform var(--transition-fast);
}
.hover-scale:hover {
    transform: scale(1.05);
}

.active-press {
    transition: transform 0.1s;
}
.active-press:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

/* Tablet & Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -240px; /* Hidden by default on mobile */
        height: 100vh;
        z-index: 200;
        transition: left var(--transition-smooth);
    }

    .sidebar.open {
        left: 0;
    }

    .search-container {
        display: none; /* Hide search bar on mobile, could show an icon instead */
    }

    .search-container.mobile-active {
        display: flex;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        margin: 0;
        padding: 0 1rem;
        background-color: var(--bg-primary);
        z-index: 101;
    }

    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr);
    }
    .grid-cols-3 {
        grid-template-columns: repeat(1, 1fr);
    }

    .content-area {
        padding: 1rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .grid-cols-2, .grid-cols-auto {
        grid-template-columns: 1fr;
    }
    
    .floating-player {
        width: calc(100% - 20px);
        bottom: 10px;
        right: 10px;
    }
}

/* Utilities for responsive hiding */
@media (max-width: 768px) {
    .hide-on-mobile { display: none !important; }
}
@media (min-width: 769px) {
    .hide-on-desktop { display: none !important; }
}

/* ==========================================================================
   Custom Player Controls
   ========================================================================== */
.custom-player {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    margin-top: 1rem;
}
.player-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.player-time {
    font-size: 0.875rem;
    color: var(--text-secondary);
    min-width: 45px;
}
.progress-bar {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--border-color);
    outline: none;
    cursor: pointer;
}
.progress-bar::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
}
.progress-bar:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* ==========================================================================
   Modals & User Customization
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal-content {
    background: var(--bg-secondary);
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--border-color);
}
.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.2s;
}
.color-swatch:hover {
    transform: scale(1.1);
}
.color-swatch.selected {
    border-color: var(--text-primary);
}
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    text-transform: uppercase;
}