/* YT Mirror - Стили */
/* Светлая минималистичная тема в стиле Яндекса */

:root {
    --color-bg: #ffffff;
    --color-bg-secondary: #f7f8fa;
    --color-bg-tertiary: #eef0f3;
    --color-text: #1a1a1a;
    --color-text-secondary: #5c5c5c;
    --color-text-tertiary: #8a8a8a;
    --color-border: #e5e7eb;
    --color-border-hover: #d1d5db;
    --color-primary: #1a73e8;
    --color-primary-hover: #1557b0;
    --color-accent: #ff0000;
    --color-error: #dc2626;
    --color-success: #16a34a;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --header-height: 64px;
    --max-width: 1400px;
}

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

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    font-size: 15px;
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

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

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

img, video {
    max-width: 100%;
    height: auto;
}

/* ========== HEADER ========== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    height: var(--header-height);
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.logo-icon {
    font-size: 24px;
    color: var(--color-accent);
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

.header-search {
    flex: 1;
    max-width: 500px;
    display: flex;
    gap: 8px;
}

.header-search-input {
    flex: 1;
    height: 40px;
    padding: 0 16px;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-bg-secondary);
    color: var(--color-text);
    transition: border-color 0.2s, background 0.2s;
}

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

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

.header-search-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: var(--color-bg-secondary);
    color: var(--color-text-secondary);
    transition: background 0.2s, color 0.2s;
}

.header-search-btn:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    border-radius: var(--radius-full);
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.nav-link.active {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.nav-link span {
    display: none;
}

@media (min-width: 768px) {
    .nav-link span {
        display: inline;
    }
}

/* ========== MAIN ========== */
.main {
    flex: 1;
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* ========== SEARCH SECTION ========== */
.search-section {
    padding: 48px 0 32px;
    text-align: center;
}

.search-title {
    font-size: 28px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 24px;
}

.search-form {
    display: flex;
    gap: 12px;
    max-width: 640px;
    margin: 0 auto;
}

.search-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 18px;
    color: var(--color-text-tertiary);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 52px;
    padding: 0 48px;
    font-size: 16px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px rgba(26, 115, 232, 0.1);
}

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

.search-clear {
    position: absolute;
    right: 12px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--color-text-tertiary);
    transition: background 0.2s, color 0.2s;
}

.search-clear:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.search-btn {
    height: 52px;
    padding: 0 28px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: background 0.2s;
}

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

/* ========== CATEGORIES ========== */
.categories {
    padding: 0 0 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.categories::-webkit-scrollbar {
    display: none;
}

.categories-inner {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.category-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
}

.category-btn:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.category-btn.active {
    background: var(--color-text);
    color: var(--color-bg);
}

/* ========== VIDEO GRID ========== */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 8px 0 48px;
}

.video-card {
    display: block;
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: transform 0.2s;
}

.video-card:hover {
    transform: translateY(-2px);
}

.video-card:hover .video-thumb img {
    transform: scale(1.02);
}

.video-thumb {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--color-bg-tertiary);
    overflow: hidden;
    border-radius: var(--radius-md);
}

.video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.video-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 3px 6px;
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    background: rgba(0, 0, 0, 0.8);
    border-radius: 4px;
}

.video-card-info {
    padding: 12px 4px;
}

.video-card-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.video-card-channel {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 2px;
}

.video-card-meta {
    font-size: 13px;
    color: var(--color-text-tertiary);
}

/* ========== LOADING ========== */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 48px;
    color: var(--color-text-secondary);
}

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

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

/* ========== ERROR MESSAGE ========== */
.error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 64px 24px;
    text-align: center;
    color: var(--color-text-secondary);
}

.error-message h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.error-message p {
    font-size: 14px;
}

.btn-retry {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: background 0.2s;
}

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

/* ========== LOAD MORE ========== */
.load-more-wrapper {
    display: flex;
    justify-content: center;
    padding: 24px 0 48px;
}

.load-more-btn {
    padding: 14px 32px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-bg);
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-full);
    transition: background 0.2s, color 0.2s;
}

.load-more-btn:hover {
    background: var(--color-primary);
    color: #fff;
}

/* ========== FOOTER ========== */
.footer {
    padding: 24px 20px;
    text-align: center;
    color: var(--color-text-tertiary);
    font-size: 13px;
    border-top: 1px solid var(--color-border);
}

.footer-note {
    margin-top: 4px;
    font-size: 12px;
}

/* ========== WATCH PAGE ========== */
.watch-page {
    background: var(--color-bg-secondary);
}

.watch-main {
    flex: 1;
    padding: 20px 0;
}

.watch-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .watch-container {
        grid-template-columns: 1fr 360px;
    }
}

.watch-primary {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Player */
.player-wrapper {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.player-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #fff;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10;
}

.video-player {
    width: 100%;
    height: 100%;
    background: #000;
}

/* Quality selector */
.quality-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
}

.quality-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.quality-buttons {
    display: flex;
    gap: 8px;
}

.quality-btn {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
}

.quality-btn:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

.quality-btn.active {
    background: var(--color-primary);
    color: #fff;
}

/* Video info */
.video-info {
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.video-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
    margin-bottom: 12px;
}

.video-meta {
    display: flex;
    gap: 16px;
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 16px;
}

.video-actions {
    display: flex;
    gap: 8px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 16px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
    transition: background 0.2s, color 0.2s;
}

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

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

.action-btn.active svg {
    fill: var(--color-accent);
}

/* Channel info */
.channel-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.channel-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--color-bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text-secondary);
}

.channel-details {
    flex: 1;
}

.channel-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.channel-name:hover {
    color: var(--color-primary);
}

.channel-subs {
    font-size: 13px;
    color: var(--color-text-tertiary);
}

/* Description */
.video-description {
    position: relative;
}

.description-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--color-text-secondary);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 80px;
    overflow: hidden;
}

.description-content.expanded {
    max-height: none;
}

.description-toggle {
    display: flex;
    align-items: center;
    margin-top: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.description-toggle:hover {
    color: var(--color-text);
}

/* Related videos */
.watch-secondary {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.related-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    padding: 0 4px;
}

.related-videos {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.related-card {
    display: flex;
    gap: 12px;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

.related-card:hover {
    background: var(--color-bg);
}

.related-thumb {
    width: 160px;
    flex-shrink: 0;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-bg-tertiary);
    position: relative;
}

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

.related-info {
    flex: 1;
    min-width: 0;
}

.related-title-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.related-channel {
    font-size: 12px;
    color: var(--color-text-tertiary);
    margin-bottom: 2px;
}

.related-meta {
    font-size: 12px;
    color: var(--color-text-tertiary);
}

/* ========== MODAL ========== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

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

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

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    color: var(--color-text-secondary);
    transition: background 0.2s;
}

.modal-close:hover {
    background: var(--color-bg-secondary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--color-border);
}

.share-url-wrapper {
    display: flex;
    gap: 8px;
}

.share-url-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.share-copy-btn {
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

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

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--color-primary);
    border-radius: var(--radius-full);
    transition: background 0.2s;
}

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

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

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

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    background: var(--color-error);
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

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

/* ========== LIST PAGES ========== */
.list-page {
    padding-top: 24px;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.list-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 600;
}

.btn-clear {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
    transition: background 0.2s, color 0.2s;
}

.btn-clear:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-error);
}

/* Empty state */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 80px 24px;
    text-align: center;
    color: var(--color-text-tertiary);
}

.empty-state h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--color-text);
}

.empty-state p {
    font-size: 15px;
    max-width: 320px;
}

/* Video list (horizontal cards) */
.video-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 48px;
}

.video-list-card {
    display: flex;
    gap: 16px;
    padding: 12px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

.video-list-card:hover {
    background: var(--color-bg-tertiary);
}

.video-list-thumb {
    width: 200px;
    flex-shrink: 0;
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--color-bg-tertiary);
    position: relative;
}

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

.video-list-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.video-list-title {
    font-size: 16px;
    font-weight: 500;
    color: var(--color-text);
    line-height: 1.3;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.video-list-channel {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.video-list-meta {
    font-size: 13px;
    color: var(--color-text-tertiary);
}

.video-list-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.video-list-actions button {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
}

.video-list-actions button:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text);
}

/* ========== ERROR OVERLAY ========== */
.error-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    z-index: 1000;
    padding: 20px;
}

.error-content {
    text-align: center;
    max-width: 400px;
}

.error-content svg {
    color: var(--color-text-tertiary);
    margin-bottom: 24px;
}

.error-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 12px;
}

.error-content p {
    font-size: 15px;
    color: var(--color-text-secondary);
    margin-bottom: 24px;
}

.error-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-secondary);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-full);
    transition: background 0.2s;
}

.btn-home:hover {
    background: var(--color-bg-tertiary);
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .header-search {
        display: none;
    }

    .search-section {
        padding: 32px 0 24px;
    }

    .search-title {
        font-size: 22px;
    }

    .search-form {
        flex-direction: column;
    }

    .search-btn {
        width: 100%;
    }

    .categories-inner {
        justify-content: flex-start;
        padding: 0 20px;
        margin: 0 -20px;
    }

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

    .watch-container {
        gap: 16px;
    }

    .video-title {
        font-size: 18px;
    }

    .related-thumb {
        width: 120px;
    }

    .video-list-card {
        flex-direction: column;
    }

    .video-list-thumb {
        width: 100%;
    }

    .list-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Hidden utility */
[hidden] {
    display: none !important;
}
