/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: 'Segoe UI', Roboto, Arial, sans-serif;
    background-color: #0f0f0f;
    color: #f1f1f1;
    height: 100%;
    overflow: hidden;
}

#app {
    height: 100%;
}

a {
    color: #3ea6ff;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* === Scrollbar === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #0f0f0f;
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* === Layout === */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background-color: #181818;
    border-bottom: 1px solid #333;
    height: 56px;
    flex-shrink: 0;
    z-index: 100;
}

.top-bar__logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 700;
    color: #ff4444;
    cursor: pointer;
    white-space: nowrap;
}

.top-bar__search {
    flex: 1;
    max-width: 540px;
    margin: 0 24px;
    display: flex;
    border: 1px solid #444;
    border-radius: 20px;
    overflow: hidden;
    background: #121212;
}

.top-bar__search input {
    flex: 1;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #f1f1f1;
    font-size: 14px;
    outline: none;
}

.top-bar__search input::placeholder {
    color: #888;
}

.top-bar__search-btn {
    padding: 8px 16px;
    background: #333;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
}

.top-bar__search-btn:hover {
    background: #444;
}

.top-bar__actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.main-area {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* === Sidebar === */
.sidebar {
    width: 220px;
    background-color: #181818;
    border-right: 1px solid #333;
    overflow-y: auto;
    flex-shrink: 0;
    padding: 8px 0;
    transition: width 0.2s ease;
}

.sidebar.collapsed {
    width: 72px;
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 20px;
    color: #aaa;
    font-size: 14px;
    cursor: pointer;
    border-radius: 0 10px 10px 0;
    margin-right: 8px;
    transition: background 0.15s;
}

.sidebar__item:hover {
    background: #272727;
    color: #fff;
}

.sidebar__item.active {
    background: #333;
    color: #fff;
}

.sidebar__item-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar__divider {
    border-top: 1px solid #333;
    margin: 8px 0;
}

.sidebar__section-label {
    padding: 8px 20px 4px;
    color: #666;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar.collapsed .sidebar__item-text,
.sidebar.collapsed .sidebar__section-label {
    display: none;
}

/* === Content Area === */
.content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* === Playlist Grid === */
.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.playlist-grid__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.playlist-grid__title {
    font-size: 18px;
    font-weight: 600;
}

.playlist-grid__sort {
    color: #aaa;
    font-size: 13px;
    cursor: pointer;
}

/* === Playlist Card === */
.playlist-card {
    background: #181818;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

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

.playlist-card__thumbnail {
    position: relative;
    height: 160px;
    background-color: #222;
    overflow: hidden;
}

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

.playlist-card__count {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0,0,0,0.85);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    color: #fff;
}

.playlist-card__favorite {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 18px;
    color: #ff4444;
}

.playlist-card__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.playlist-card:hover .playlist-card__overlay {
    opacity: 1;
}

.playlist-card__play-btn {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #111;
}

.playlist-card__body {
    padding: 12px;
}

.playlist-card__title {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-card__meta {
    font-size: 12px;
    color: #aaa;
}

/* === Video Item === */
.video-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.video-item:hover {
    background: #272727;
}

.video-item__drag-handle {
    cursor: grab;
    color: #666;
    font-size: 16px;
    padding: 4px;
}

.video-item__drag-handle:active {
    cursor: grabbing;
}

.video-item.dragging {
    opacity: 0.5;
    background: #333;
}

.video-item.drag-over {
    border-top: 2px solid #3ea6ff;
}

.video-item.selected {
    background: #1a2a3a;
    border-left: 3px solid #ff0000;
}

.video-item__checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #ff0000;
    flex-shrink: 0;
}

.video-item__index {
    width: 24px;
    text-align: center;
    color: #666;
    font-size: 13px;
    flex-shrink: 0;
}

.video-item__thumbnail {
    width: 120px;
    height: 68px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: #222;
}

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

.video-item__info {
    flex: 1;
    min-width: 0;
}

.video-item__title {
    font-size: 14px;
    color: #fff;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-item__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.video-item__channel {
    font-size: 12px;
    color: #aaa;
}

.video-item__date {
    font-size: 12px;
    color: #777;
}

.video-item__date::before {
    content: "•";
    margin-right: 8px;
    color: #555;
}

.video-item__actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.15s;
}

.video-item:hover .video-item__actions {
    opacity: 1;
}

/* === Context Menu === */
.context-menu {
    position: fixed;
    background: #282828;
    border: 1px solid #444;
    border-radius: 8px;
    padding: 4px 0;
    min-width: 180px;
    z-index: 1000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.context-menu__item {
    padding: 8px 16px;
    font-size: 14px;
    color: #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
}

.context-menu__item:hover {
    background: #333;
}

.context-menu__item--danger {
    color: #ff4444;
}

/* === Player === */
.player-page {
    display: flex;
    gap: 20px;
    height: 100%;
}

.player-page__main {
    flex: 1;
    min-width: 0;
}

.player-page__video {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

.player-page__video iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.player-page__info {
    padding: 16px 0;
}

.player-page__title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.player-page__actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.player-page__sidebar {
    width: 360px;
    flex-shrink: 0;
    overflow-y: auto;
}

.player-page__sidebar-header {
    padding: 12px;
    background: #181818;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
    font-weight: 600;
}

/* === Buttons === */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.btn--primary {
    background: #3ea6ff;
    color: #0f0f0f;
    font-weight: 600;
}

.btn--primary:hover {
    background: #60b8ff;
}

.btn--secondary {
    background: #333;
    color: #fff;
}

.sort-select {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.sort-select:hover {
    border-color: #888;
}

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

.btn--danger {
    background: #ff4444;
    color: #fff;
}

.btn--danger:hover {
    background: #ff6666;
}

.btn--icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    color: #aaa;
    border: none;
    cursor: pointer;
}

.btn--icon:hover {
    background: #333;
    color: #fff;
}

/* === Modal === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: #282828;
    border-radius: 12px;
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
}

.modal__title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* === Form === */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    color: #aaa;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: #121212;
    border: 1px solid #444;
    border-radius: 8px;
    color: #f1f1f1;
    font-size: 14px;
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: #3ea6ff;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group select {
    appearance: none;
    cursor: pointer;
}

/* === Toast === */
.toast-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 24px;
    background: #333;
    border-radius: 8px;
    font-size: 14px;
    color: #fff;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    animation: toast-in 0.3s ease;
}

.toast--error {
    background: #cc3333;
}

.toast--success {
    background: #2e7d32;
}

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

/* === Quota Bar === */
.quota-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #aaa;
}

.quota-bar__track {
    width: 80px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}

.quota-bar__fill {
    height: 100%;
    background: #3ea6ff;
    border-radius: 2px;
    transition: width 0.3s;
}

.quota-bar__fill.warning {
    background: #ff9800;
}

.quota-bar__fill.danger {
    background: #ff4444;
}

/* === Stats === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: #181818;
    border-radius: 12px;
    padding: 20px;
}

.stat-card__value {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
}

.stat-card__label {
    font-size: 13px;
    color: #aaa;
    margin-top: 4px;
}

.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bar-chart__row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-chart__label {
    width: 150px;
    font-size: 13px;
    color: #ccc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex-shrink: 0;
}

.bar-chart__bar {
    flex: 1;
    height: 20px;
    background: #333;
    border-radius: 4px;
    overflow: hidden;
}

.bar-chart__fill {
    height: 100%;
    background: #3ea6ff;
    border-radius: 4px;
    transition: width 0.3s;
}

.bar-chart__value {
    width: 40px;
    text-align: right;
    font-size: 13px;
    color: #aaa;
    flex-shrink: 0;
}

/* === Duplicates === */
.duplicate-group {
    background: #181818;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
}

.duplicate-group__header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.duplicate-group__locations {
    padding-left: 16px;
}

.duplicate-group__location {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    color: #ccc;
    border-bottom: 1px solid #272727;
}

/* === Loading === */
.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #333;
    border-top-color: #3ea6ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 40px;
    color: #aaa;
    font-size: 14px;
}

/* === Progress Bar === */
.progress-bar {
    width: 100%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar__fill {
    height: 100%;
    background: #3ea6ff;
    border-radius: 2px;
    transition: width 0.3s;
}

/* === Avatar === */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #fff;
    cursor: pointer;
}

/* === Utility === */
.text-muted { color: #aaa; }
.text-danger { color: #ff4444; }
.text-small { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
