:root {
    --primary: #3b82f6;
    /* Changed to a sleeker blue/indigo mix for VXRIR */
    --primary-hover: #2563eb;
    --secondary: #8b5cf6;
    --bg-gradient-1: #e0f2fe;
    --bg-gradient-2: #ede9fe;
    --text-main: #0f172a;
    --text-muted: #475569;
    --glass-bg: rgba(255, 255, 255, 0.75);
    --glass-border: rgba(255, 255, 255, 0.6);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.08);
    --input-bg: rgba(255, 255, 255, 0.95);
    --danger: #ef4444;
    --success: #10b981;
}

.theme-dark {
    --primary: #60a5fa;
    --primary-hover: #93c5fd;
    --secondary: #a78bfa;
    --bg-gradient-1: #020617;
    --bg-gradient-2: #0f172a;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-bg: rgba(15, 23, 42, 0.65);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
    --input-bg: rgba(30, 41, 59, 0.85);
}

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

body {
    font-family: 'Cairo', 'Outfit', sans-serif;
    background: linear-gradient(135deg, var(--bg-gradient-1), var(--bg-gradient-2));
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.4s ease, color 0.4s ease;
    padding-bottom: 120px;
}

/* Background Canvas */
#bgCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    opacity: 0.6;
}

/* Background Animated Blobs */
.blob {
    position: absolute;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.4;
    animation: float 12s ease-in-out infinite alternate;
}

.blob-1 {
    width: 35vw;
    height: 35vw;
    background: var(--primary);
    top: -5%;
    left: -5%;
    border-radius: 50%;
    opacity: 0.25;
}

.blob-2 {
    width: 45vw;
    height: 45vw;
    background: var(--secondary);
    bottom: 5%;
    right: -5%;
    border-radius: 40%;
    animation-delay: -3s;
    opacity: 0.15;
}

.blob-3 {
    width: 25vw;
    height: 25vw;
    background: #38bdf8;
    top: 40%;
    left: 35%;
    border-radius: 60%;
    animation-delay: -6s;
    opacity: 0.15;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
    }

    100% {
        transform: translate(4vw, 4vh) scale(1.05) rotate(10deg);
    }
}

/* Base Classes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 20px;
}

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

kbd {
    background-color: var(--input-bg);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), inset 0 -2px 0 rgba(0, 0, 0, 0.1);
    color: var(--text-main);
    display: inline-block;
    font-family: inherit;
    font-size: 0.85em;
    font-weight: 700;
    line-height: 1;
    padding: 4px 8px;
    white-space: nowrap;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.header-actions {
    display: flex;
    gap: 10px;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    cursor: pointer;
    transition: 0.3s;
}

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

#settingsBtn:hover {
    transform: rotate(90deg);
}

#helpBtn:hover {
    transform: scale(1.1);
}

.settings-menu {
    position: absolute;
    top: 70px;
    left: 5%;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-10px);
    transition: 0.3s;
    min-width: 200px;
}

html[dir="rtl"] .settings-menu {
    left: auto;
    right: 5%;
}

.settings-menu.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.settings-menu button {
    background: none;
    border: none;
    color: var(--text-main);
    text-align: right;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: 0.2s;
}

html[dir="ltr"] .settings-menu button {
    text-align: left;
}

.settings-menu button:hover {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

/* Layout */
.container {
    max-width: 900px;
    margin: 40px auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.card {
    padding: 30px;
    transition: transform 0.3s, box-shadow 0.3s;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
}

.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--primary);
    position: relative;
    display: inline-block;
}

.card-title::after {
    content: '';
    position: absolute;
    width: 60%;
    height: 3px;
    bottom: -5px;
    right: 0;
    background: linear-gradient(90deg, var(--primary), transparent);
    border-radius: 2px;
}

html[dir="ltr"] .card-title::after {
    right: auto;
    left: 0;
    background: linear-gradient(-90deg, var(--primary), transparent);
}

/* Inputs and Buttons */
.input-group {
    display: flex;
    gap: 10px;
    position: relative;
    align-items: center;
}

.input-icon {
    position: absolute;
    right: 15px;
    color: var(--primary);
    font-size: 1.2rem;
}

html[dir="ltr"] .input-icon {
    right: auto;
    left: 15px;
}

.glass-input {
    width: 100%;
    padding: 14px 45px 14px 15px;
    border-radius: 14px;
    border: 2px solid var(--glass-border);
    background: var(--input-bg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    transition: 0.3s;
}

html[dir="ltr"] .glass-input {
    padding: 14px 15px 14px 45px;
}

.glass-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.btn {
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.btn-primary:active,
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.5);
    filter: brightness(1.1);
}

.btn-secondary {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.2);
}

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

.w-100 {
    width: 100%;
}

.mt-2 {
    margin-top: 10px;
}

.mt-3 {
    margin-top: 15px;
}

.mt-4 {
    margin-top: 20px;
}

.mt-5 {
    margin-top: 30px;
}

/* Skeleton Loader */
.skeleton-container {
    animation: pulse 1.5s infinite;
}

.skeleton-box {
    height: 250px;
    background: rgba(128, 128, 128, 0.2);
    border-radius: 16px;
    margin-bottom: 20px;
}

.skeleton-line {
    height: 20px;
    background: rgba(128, 128, 128, 0.2);
    border-radius: 8px;
    margin-bottom: 15px;
    width: 100%;
}

.skeleton-line.title {
    width: 40%;
    height: 30px;
}

.skeleton-line.short {
    width: 60%;
}

/* Result Layout */
.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 15px;
}

.quality-selector {
    display: flex;
    align-items: center;
    gap: 8px;
}

.glass-input.small {
    padding: 6px 12px;
    border-radius: 8px;
    width: auto;
    font-size: 0.9rem;
}

.m3u8-box {
    background: rgba(0, 0, 0, 0.05);
    padding: 15px 95px 15px 15px;
    border-radius: 12px;
    font-family: monospace;
    word-break: break-all;
    position: relative;
    border: 1px solid var(--glass-border);
}

.theme-dark .m3u8-box {
    background: rgba(0, 0, 0, 0.3);
}

.box-actions {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    display: flex;
    gap: 5px;
}

html[dir="ltr"] .box-actions {
    right: auto;
    left: 10px;
}

html[dir="ltr"] .m3u8-box {
    padding: 15px 15px 15px 95px;
}

.copy-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1rem;
}

.copy-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

/* Video Player */
.video-wrapper {
    margin-top: 20px;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
}

video {
    width: 100%;
    display: block;
    aspect-ratio: 16/9;
}

.pip-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: 0.3s;
}

html[dir="rtl"] .pip-btn {
    left: auto;
    right: 15px;
}

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

.live-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: var(--danger);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: blink 2s infinite;
}

html[dir="rtl"] .live-badge {
    right: auto;
    left: 15px;
}

/* Stream Info */
.stream-profile {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
    padding: 15px;
    background: rgba(59, 130, 246, 0.05);
    border-radius: 16px;
}

.stream-thumb {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stream-details {
    flex: 1;
    overflow: hidden;
}

.stream-title {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stream-owner-area {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.stream-owner {
    font-weight: 600;
    font-size: 1rem;
}

.stream-meta {
    display: flex;
    gap: 15px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
}

/* Dock Toolbar */
.dock {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    padding: 8px 15px;
    border-radius: 30px;
    display: flex;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.27, 1.55);
}

.dock.hidden {
    transform: translateX(-50%) translateY(150%);
}

.dock-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--input-bg);
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.dock-btn:hover {
    transform: translateY(-4px);
    background: var(--primary);
    color: white;
}

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

.divider {
    width: 1px;
    background: var(--glass-border);
    margin: 0 5px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}

.modal.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 90%;
    max-width: 380px;
    padding: 35px;
    text-align: center;
    transform: scale(0.9);
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.active .modal-content {
    transform: scale(1);
}

#helpModal .modal-content {
    max-width: 450px;
}

#helpModal kbd {
    font-size: 0.9em;
    margin: 0 2px;
}

.modal-lock-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.modal-subtitle {
    color: var(--text-muted);
    margin-bottom: 25px;
    font-size: 0.9rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: center;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2100;
    pointer-events: none;
}

html[dir="rtl"] .toast-container {
    right: auto;
    left: 20px;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    border-left: 4px solid var(--primary);
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    font-weight: 600;
    animation: slideInRight 0.4s ease forwards;
}

html[dir="rtl"] .toast {
    border-left: none;
    border-right: 4px solid var(--primary);
    animation: slideInLeft 0.4s ease forwards;
}

.toast.success {
    border-color: var(--success);
    color: var(--success);
}

.toast.error {
    border-color: var(--danger);
    color: var(--danger);
}

.toast.info {
    border-color: var(--primary);
    color: var(--primary);
}

.toast.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

.recent-bubble,
.saved-item {
    background: var(--input-bg);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--glass-border);
    cursor: pointer;
    transition: 0.2s;
    word-break: break-all;
}

.recent-bubble:hover,
.saved-item:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(50px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

@media (max-width: 600px) {
    .stream-profile {
        flex-direction: column;
        text-align: center;
    }

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

    .dock {
        bottom: 10px;
        padding: 6px 12px;
    }
}

/* --- Plyr Customization --- */
:root {
    --plyr-color-main: var(--primary);
    --plyr-video-control-background-hover: rgba(59, 130, 246, 0.2);
}

.theme-dark {
    --plyr-video-background: #000;
}

/* --- Mini Dashboard (Stats) --- */
.stats-dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.stat-box {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    padding: 12px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    transition: 0.3s;
}

.stat-box:hover {
    transform: translateY(-2px);
    border-color: var(--primary);
}

.stat-box i {
    font-size: 1.4rem;
}

.stat-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    width: 100%;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-main);
}

/* --- Cinema Mode --- */
.cinema-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1050;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.cinema-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.video-wrapper.cinema-active {
    position: relative;
    z-index: 1100;
    box-shadow: 0 0 50px rgba(59, 130, 246, 0.3);
    transform: scale(1.02);
    transition: transform 0.5s ease, box-shadow 0.5s ease;
}

.cinema-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: 0.3s;
    z-index: 10;
    font-size: 1.1rem;
}

html[dir="rtl"] .cinema-btn {
    left: auto;
    right: 15px;
}

.cinema-btn:hover {
    background: var(--primary);
    transform: scale(1.1);
}

.video-wrapper.cinema-active .cinema-btn {
    color: var(--primary);
}

/* --- Smart Clipper UI --- */
.clipper-tools {
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    padding: 15px;
    border-radius: 12px;
}

.clipper-header {
    margin-bottom: 10px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.clipper-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.clipper-inputs .glass-input.small {
    width: 140px;
    padding: 8px 12px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
}