/* ========================================
   뮤직 클라우드 - 메인 스타일시트
   ======================================== */

:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --bg-hover: #252525;
    --bg-active: #2a2a2a;
    
    --accent: #00d4aa;
    --accent-hover: #00e6b8;
    --accent-glow: rgba(0, 212, 170, 0.3);
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    
    --border-color: #2a2a2a;
    --progress-bg: #3a3a3a;
    
    --error: #ff4757;
    --warning: #ffa502;
    --success: #00d4aa;
    
    --sidebar-width: 240px;
    --player-height: 90px;
    --header-height: 64px;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    --transition: all 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    border: none;
    background: none;
    cursor: pointer;
    color: inherit;
}

input {
    font-family: inherit;
    border: none;
    background: none;
    color: inherit;
    outline: none;
}

/* ========================================
   Layout
   ======================================== */

#app {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    grid-template-rows: 1fr var(--player-height);
    height: 100vh;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    border-right: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-bottom: 24px;
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 700;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: var(--transition);
    font-size: 0.95rem;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
}

.nav-item svg {
    flex-shrink: 0;
}

.nav-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.nav-section h3 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0 16px;
    margin-bottom: 12px;
}

.playlist-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: 200px;
    overflow-y: auto;
}

.playlist-nav-item {
    padding: 8px 16px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.playlist-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: linear-gradient(to bottom, rgba(20, 20, 20, 0.9), transparent);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-nav {
    display: flex;
    gap: 8px;
}

.nav-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.nav-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.header-search {
    flex: 1;
    max-width: 400px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    padding: 10px 16px;
    border-radius: 24px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.header-search:focus-within {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.header-search input {
    flex: 1;
    font-size: 0.95rem;
}

.header-search input::placeholder {
    color: var(--text-muted);
}

.header-search svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.header-user {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Buttons */
.btn {
    padding: 10px 24px;
    border-radius: 24px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: scale(1.02);
}

.btn-outline {
    border: 1px solid var(--text-muted);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

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

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

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* User Menu */
.user-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 24px;
    background: var(--bg-card);
    transition: var(--transition);
}

.user-btn:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--bg-primary);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    min-width: 160px;
    overflow: hidden;
    display: none;
    z-index: 100;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 12px 16px;
    color: var(--text-secondary);
    transition: var(--transition);
}

.dropdown-menu a:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

#user-menu {
    position: relative;
}

/* Content */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 24px;
}

.content::-webkit-scrollbar {
    width: 8px;
}

.content::-webkit-scrollbar-track {
    background: transparent;
}

.content::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

.content::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}

/* Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
}

.section-header a {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.section-header a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Album Grid */
.album-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.album-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 16px;
    transition: var(--transition);
    cursor: pointer;
}

.album-card:hover {
    background: var(--bg-hover);
    transform: translateY(-4px);
}

.album-cover {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 16px;
}

.album-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.album-play-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(8px);
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.album-card:hover .album-play-btn {
    opacity: 1;
    transform: translateY(0);
}

.album-play-btn:hover {
    transform: scale(1.1);
}

.album-title {
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.album-artist {
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Track List */
.track-list {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.track-header {
    display: grid;
    grid-template-columns: 40px 1fr 1fr 100px 50px;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.track-item {
    display: grid;
    grid-template-columns: 40px 1fr 1fr 100px 50px;
    gap: 16px;
    padding: 12px 16px;
    align-items: center;
    transition: var(--transition);
    cursor: pointer;
}

.track-item:hover {
    background: var(--bg-hover);
}

.track-item.playing {
    background: rgba(0, 212, 170, 0.1);
}

.track-item.playing .track-number {
    color: var(--accent);
}

.track-number {
    color: var(--text-muted);
    text-align: center;
}

.track-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.track-thumb {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}

.track-details {
    min-width: 0;
}

.track-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-artist {
    color: var(--text-secondary);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-album {
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.track-duration {
    color: var(--text-secondary);
    font-size: 0.9rem;
    text-align: right;
}

.track-actions {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: var(--transition);
}

.track-item:hover .track-actions {
    opacity: 1;
}

.track-action-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.track-action-btn:hover {
    background: var(--bg-active);
    color: var(--text-primary);
}

/* ========================================
   Player
   ======================================== */

.player {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

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

.player-cover {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.player-info {
    min-width: 0;
}

.player-title {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-artist {
    color: var(--text-secondary);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-like {
    color: var(--text-muted);
    padding: 8px;
    transition: var(--transition);
}

.player-like:hover {
    color: var(--text-primary);
}

.player-like.active {
    color: var(--accent);
}

.player-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.player-buttons {
    display: flex;
    align-items: center;
    gap: 16px;
}

.control-btn {
    color: var(--text-secondary);
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
}

.control-btn:hover {
    color: var(--text-primary);
}

.control-btn.active {
    color: var(--accent);
}

.play-btn {
    width: 40px;
    height: 40px;
    background: var(--text-primary);
    color: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.play-btn:hover {
    transform: scale(1.06);
    background: var(--text-primary);
}

.player-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 600px;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--progress-bg);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.progress-bar:hover {
    height: 6px;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    position: relative;
}

.progress-handle {
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    background: var(--text-primary);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.progress-bar:hover .progress-handle {
    opacity: 1;
}

.time-current, .time-total {
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 40px;
}

.time-current {
    text-align: right;
}

.player-extra {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.volume-control {
    display: flex;
    align-items: center;
    gap: 8px;
}

.volume-slider {
    width: 100px;
    height: 4px;
    background: var(--progress-bg);
    border-radius: 2px;
    cursor: pointer;
    position: relative;
}

.volume-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 70%;
}

/* ========================================
   Modal
   ======================================== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    font-size: 1.5rem;
    color: var(--text-muted);
    padding: 4px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    transition: var(--transition);
}

.form-input:focus {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1rem;
    color: var(--text-primary);
    cursor: pointer;
}

.form-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.form-checkbox input {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
}

.form-error {
    color: var(--error);
    font-size: 0.85rem;
    margin-top: 6px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ========================================
   Toast Notifications
   ======================================== */

.toast-container {
    position: fixed;
    bottom: 110px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1001;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

/* ========================================
   Empty State
   ======================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.empty-state p {
    margin-bottom: 20px;
}

/* ========================================
   Loading
   ======================================== */

.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========================================
   Upload Zone
   ======================================== */

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    background: rgba(0, 212, 170, 0.05);
}

.upload-zone svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.upload-zone h3 {
    margin-bottom: 8px;
}

.upload-zone p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

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

@media (max-width: 1024px) {
    #app {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        display: none;
    }
    
    .track-header,
    .track-item {
        grid-template-columns: 40px 1fr 80px;
    }
    
    .track-album {
        display: none;
    }
}

@media (max-width: 768px) {
    .header-search {
        display: none;
    }
    
    .player {
        grid-template-columns: 1fr auto;
        padding: 8px 12px;
    }
    
    .player-extra {
        display: none;
    }
    
    .player-progress {
        display: none;
    }
    
    .album-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 16px;
    }
}

/* Auth visibility helpers */
.auth-required {
    display: none;
}

body.logged-in .auth-required {
    display: flex;
}

body.logged-in .guest-only {
    display: none;
}

body.logged-in .user-only {
    display: block !important;
}
