/* ================================================================
   StreamIt — Modern Dark Theme Stylesheet
   ================================================================ */

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

:root {
    /* Palette */
    --bg-deep: #0a0a0f;
    --bg-surface: #12121a;
    --bg-card: #1a1a26;
    --bg-card-hover: #22222f;
    --bg-input: #16161f;

    --accent-primary: #7c5cfc;
    --accent-secondary: #5c9cfc;
    --accent-glow: rgba(124, 92, 252, 0.25);
    --accent-gradient: linear-gradient(135deg, #7c5cfc, #5c9cfc);

    --text-primary: #eaeaf0;
    --text-secondary: #9898a8;
    --text-muted: #6a6a7a;

    --border: #2a2a38;
    --border-focus: #7c5cfc;

    --success: #3cda8a;
    --warning: #f0a830;
    --danger: #f05050;

    /* Sizing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-pill: 100px;

    --max-width: 840px;

    /* Fonts */
    --font-latin: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-arabic: 'Noto Kufi Arabic', 'Inter', sans-serif;

    /* Transitions */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* RTL font override */
[dir="rtl"] {
    font-family: var(--font-arabic);
}

/* Ensure HTML hidden attribute always wins */
[hidden] {
    display: none !important;
}

/* --- Base ------------------------------------------------------- */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-latin);
    background: var(--bg-deep);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-secondary);
    text-decoration: none;
    transition: color 0.2s var(--ease);
}
a:hover {
    color: var(--accent-primary);
}

/* --- Ambient Glow Backgrounds ----------------------------------- */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}
.glow-1 {
    width: 500px;
    height: 500px;
    background: var(--accent-primary);
    top: -150px;
    left: -100px;
    animation: float-glow 12s ease-in-out infinite alternate;
}
.glow-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-secondary);
    bottom: -100px;
    right: -80px;
    animation: float-glow 10s ease-in-out infinite alternate-reverse;
}

@keyframes float-glow {
    0%   { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 30px) scale(1.15); }
}

/* --- Header ----------------------------------------------------- */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}
.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.85rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}
.logo:hover { color: var(--text-primary); }

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    color: #fff;
    box-shadow: 0 0 20px var(--accent-glow);
}

.lang-switch {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all 0.25s var(--ease);
}
.lang-switch:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
    background: rgba(124, 92, 252, 0.08);
}

/* --- Main ------------------------------------------------------- */
.main {
    flex: 1;
    position: relative;
    z-index: 1;
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* --- Hero / Home Page ------------------------------------------- */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: 55vh;
    gap: 1rem;
}

.hero-title {
    font-size: clamp(2.2rem, 6vw, 3.4rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: title-in 0.6s var(--ease) both;
}

.hero-tagline {
    font-size: 1.05rem;
    color: var(--text-secondary);
    max-width: 380px;
    animation: fade-up 0.6s 0.15s var(--ease) both;
}

/* --- Extract Form ----------------------------------------------- */
.extract-form {
    width: 100%;
    max-width: 600px;
    margin-top: 1.25rem;
    animation: fade-up 0.6s 0.3s var(--ease) both;
}

.input-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-input);
    transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.input-group:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 8px 32px rgba(0,0,0,0.25);
}

.url-input {
    flex: 1;
    padding: 0.95rem 1.25rem;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: inherit;
}
.url-input::placeholder {
    color: var(--text-muted);
}

[dir="rtl"] .url-input {
    text-align: right;
    font-family: var(--font-arabic);
}

.extract-btn {
    padding: 0.95rem 1.6rem;
    background: var(--accent-gradient);
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
    white-space: nowrap;
}
.extract-btn:hover {
    opacity: 0.9;
}
.extract-btn:active {
    transform: scale(0.97);
}

.extract-btn .btn-loader { display: inline-flex; align-items: center; gap: 0.45rem; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Error message */
.error-msg {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: rgba(240, 80, 80, 0.1);
    border: 1px solid rgba(240, 80, 80, 0.25);
    border-radius: var(--radius-md);
    color: #f07070;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: shake 0.4s var(--ease);
}

.error-icon { font-size: 1.1rem; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-6px); }
    40%      { transform: translateX(6px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* --- Result Page ------------------------------------------------ */
.result-page {
    animation: fade-up 0.5s var(--ease) both;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color 0.2s var(--ease);
}
.back-link:hover { color: var(--accent-primary); }

/* Media Card */
.media-card {
    display: flex;
    gap: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
    animation: card-in 0.5s 0.1s var(--ease) both;
}

.media-thumb-wrap {
    position: relative;
    flex-shrink: 0;
    width: 220px;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.media-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.78);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    backdrop-filter: blur(4px);
}

[dir="rtl"] .duration-badge {
    right: auto;
    left: 8px;
}

.media-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.6rem;
    min-width: 0;
}

.media-title {
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.media-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}
.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.meta-icon { font-size: 0.95rem; }

/* Best Quality Bar */
.best-quality-bar {
    margin-bottom: 1.5rem;
    animation: card-in 0.5s 0.2s var(--ease) both;
}

.best-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.85rem 1.25rem;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    transition: opacity 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
    box-shadow: 0 4px 20px var(--accent-glow);
}
.best-btn:hover {
    color: #fff;
    opacity: 0.92;
    transform: translateY(-1px);
    box-shadow: 0 6px 28px var(--accent-glow);
}
.best-icon { font-size: 1.15rem; }

/* Format Section */
.format-section {
    margin-bottom: 2rem;
    animation: card-in 0.5s 0.3s var(--ease) both;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 0.85rem;
    color: var(--text-primary);
}
.section-icon { font-size: 1.15rem; }

.format-count {
    margin-inline-start: auto;
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.15rem 0.6rem;
    border-radius: var(--radius-pill);
}

/* Table */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

.format-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.format-table thead th {
    text-align: start;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-surface);
}

.format-table tbody td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid rgba(42, 42, 56, 0.5);
    vertical-align: middle;
}

.format-row {
    transition: background 0.15s var(--ease);
}
.format-row:hover {
    background: var(--bg-card-hover);
}
.format-row:last-child td {
    border-bottom: none;
}

/* Quality badge */
.quality-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(124, 92, 252, 0.12);
    color: var(--accent-primary);
}

/* High quality highlights */
.quality-2160, .quality-1440 {
    background: rgba(60, 218, 138, 0.12);
    color: var(--success);
}
.quality-1080 {
    background: rgba(92, 156, 252, 0.12);
    color: var(--accent-secondary);
}

/* Type tag */
.type-tag {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.size-cell {
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Action buttons */
.actions-cell {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s var(--ease);
    white-space: nowrap;
}

.play-btn {
    background: rgba(124, 92, 252, 0.1);
    color: var(--accent-primary);
    border: 1px solid rgba(124, 92, 252, 0.2);
}
.play-btn:hover {
    background: rgba(124, 92, 252, 0.2);
    color: #9a80ff;
    border-color: rgba(124, 92, 252, 0.35);
}

.dl-btn {
    background: rgba(60, 218, 138, 0.08);
    color: var(--success);
    border: 1px solid rgba(60, 218, 138, 0.15);
}
.dl-btn:hover {
    background: rgba(60, 218, 138, 0.18);
    border-color: rgba(60, 218, 138, 0.3);
}

/* VLC button */
.vlc-btn {
    background: rgba(255, 140, 0, 0.08);
    color: #f0a830;
    border: 1px solid rgba(255, 140, 0, 0.15);
    cursor: pointer;
    font-family: inherit;
}
.vlc-btn:hover {
    background: rgba(255, 140, 0, 0.18);
    border-color: rgba(255, 140, 0, 0.3);
}

/* Copy button */
.copy-btn {
    background: rgba(92, 156, 252, 0.08);
    color: var(--accent-secondary);
    border: 1px solid rgba(92, 156, 252, 0.15);
    cursor: pointer;
    font-family: inherit;
}
.copy-btn:hover {
    background: rgba(92, 156, 252, 0.18);
    border-color: rgba(92, 156, 252, 0.3);
}
.copy-btn.copied {
    background: rgba(60, 218, 138, 0.15);
    color: var(--success);
    border-color: rgba(60, 218, 138, 0.3);
}

/* Player Help Section */
.player-help {
    margin-top: 2rem;
    animation: card-in 0.5s 0.4s var(--ease) both;
}

.player-help details {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.player-help summary {
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color 0.2s var(--ease), background 0.2s var(--ease);
    user-select: none;
    list-style: none;
}
.player-help summary::-webkit-details-marker { display: none; }
.player-help summary::before {
    content: "▸ ";
    transition: transform 0.2s var(--ease);
    display: inline-block;
}
.player-help details[open] summary::before {
    transform: rotate(90deg);
}

.player-help summary:hover {
    color: var(--text-primary);
    background: var(--bg-card-hover);
}

.player-help-content {
    padding: 0 1.25rem 1.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.player-help-content p {
    margin-bottom: 0.75rem;
}

.player-help-content ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-help-content li {
    padding: 0.5rem 0.85rem;
    background: var(--bg-surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.player-help-content li strong {
    color: var(--accent-primary);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 1rem;
}

/* --- Footer ----------------------------------------------------- */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 2rem 1.5rem;
    border-top: 1px solid var(--border);
}

.disclaimer {
    font-size: 0.78rem;
    color: var(--text-muted);
    max-width: 520px;
    margin: 0 auto 0.6rem;
    line-height: 1.5;
}

.brand {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
.brand a {
    color: var(--accent-primary);
    font-weight: 600;
}
.brand a:hover {
    text-decoration: underline;
}

/* --- Animations ------------------------------------------------- */
@keyframes title-in {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* --- Responsive ------------------------------------------------- */
@media (max-width: 640px) {
    .header-inner {
        padding: 0.75rem 1rem;
    }

    .main {
        padding: 1.25rem 1rem;
    }

    .hero {
        min-height: 45vh;
    }

    .hero-title {
        font-size: 2rem;
    }

    .input-group {
        flex-direction: column;
        border-radius: var(--radius-md);
    }
    .url-input {
        padding: 0.9rem 1rem;
    }
    .extract-btn {
        border-radius: 0;
        padding: 0.85rem;
    }

    .media-card {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    .media-thumb-wrap {
        width: 100%;
        max-height: 200px;
    }

    .format-table {
        font-size: 0.82rem;
    }
    .format-table thead th,
    .format-table tbody td {
        padding: 0.6rem 0.7rem;
    }

    .actions-cell {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.35rem;
    }

    .best-btn {
        font-size: 0.88rem;
    }
}

@media (max-width: 380px) {
    .hero-title { font-size: 1.65rem; }
    .hero-tagline { font-size: 0.92rem; }
}

