/* ==================== VARIABLES ==================== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --danger-color: #dc2626;
    --danger-hover: #b91c1c;
    --success-color: #16a34a;
    --background: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --sidebar-width: 280px;
    --header-height: 70px;
}

/* ==================== RESET & BASE ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ==================== HEADER ==================== */
.header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: var(--header-height);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 100%;
    max-width: 100%;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* ==================== MAIN CONTAINER ==================== */
.main-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    margin-top: var(--header-height);
    height: calc(100vh - var(--header-height));
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 1.5rem 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.05em;
}

.folder-tree {
    padding: 1rem 0;
}

.folder-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
}

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

.folder-item.active {
    background: #eff6ff;
    border-left: 3px solid var(--primary-color);
    color: var(--primary-color);
    font-weight: 500;
}

.folder-icon {
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ==================== CONTENT AREA ==================== */
.content {
    overflow-y: auto;
    padding: 2rem;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.breadcrumb-item {
    cursor: pointer;
    transition: color 0.2s;
}

.breadcrumb-item:hover {
    color: var(--primary-color);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

/* ==================== VIDEO GRID ==================== */
.view {
    width: 100%;
}

.view.hidden {
    display: none;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.video-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

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

.video-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.video-info {
    padding: 1rem;
}

.video-name {
    font-weight: 500;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 1.1rem;
}

/* ==================== VIDEO PLAYER ==================== */
.player-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.player-header h2 {
    flex: 1;
    font-size: 1.5rem;
}

.player-actions {
    display: flex;
    gap: 0.5rem;
}

.player-container {
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

#video-player {
    width: 100%;
    display: block;
    max-height: 70vh;
}

.player-controls {
    background: var(--surface);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.control-group label {
    font-weight: 500;
    color: var(--text-secondary);
}

.speed-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.9rem;
    min-width: 100px;
}

.speed-display {
    font-weight: 600;
    color: var(--primary-color);
    min-width: 50px;
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

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

.btn-secondary:hover {
    background: #475569;
}

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

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

.btn-icon {
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: all 0.2s;
}

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

/* ==================== MODALS ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-small {
    max-width: 400px;
}

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

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

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* ==================== UPLOAD AREA ==================== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s;
    margin-bottom: 1.5rem;
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: #eff6ff;
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.upload-prompt p {
    margin: 0.5rem 0;
}

.upload-hint {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.upload-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 1rem;
}

.upload-destination {
    margin-bottom: 1rem;
}

.upload-destination label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.folder-select {
    width: 100%;
    padding: 0.625rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
}

.upload-progress-item {
    background: var(--background);
    border-radius: 4px;
    padding: 1rem;
    margin-top: 1rem;
}

.upload-progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.upload-progress-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.upload-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.3s;
}

/* ==================== INPUT ==================== */
.input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ==================== CONTEXT MENU ==================== */
.context-menu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1001;
    min-width: 150px;
}

.context-menu.hidden {
    display: none;
}

.context-menu-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.context-menu-item:hover {
    background: var(--background);
}

.context-menu-item:first-child {
    border-radius: 6px 6px 0 0;
}

.context-menu-item:last-child {
    border-radius: 0 0 6px 6px;
}

/* ==================== TOAST NOTIFICATIONS ==================== */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
}

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

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

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

/* ==================== UTILITY ==================== */
.hidden {
    display: none !important;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0;
    }

    .main-container {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--header-height);
        width: 280px;
        height: calc(100vh - var(--header-height));
        z-index: 99;
        transition: left 0.3s;
    }

    .sidebar.active {
        left: 0;
    }

    .header-content {
        padding: 0 1rem;
    }

    .logo {
        font-size: 1.2rem;
    }

    .video-grid {
        grid-template-columns: 1fr;
    }

    .content {
        padding: 1rem;
    }

    .player-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        justify-content: space-between;
    }

    .toast-container {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }

    .toast {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 95%;
        max-width: none;
    }

    .upload-area {
        padding: 2rem 1rem;
    }
}
