/* ============================================================
   3SR Quality — فخم
   ============================================================ */

:root {
    --bg: #000000;
    --bg-2: #0a0a12;
    --surface: rgba(255, 255, 255, 0.03);
    --surface-2: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-hi: rgba(255, 255, 255, 0.15);
    --text: #ffffff;
    --text-dim: #a1a1aa;
    --text-muted: #52525b;
    --primary: #3b82f6;
    --primary-bright: #60a5fa;
    --primary-deep: #2563eb;
    --accent: #06b6d4;
    --accent-2: #a78bfa;
    --success: #10b981;
    --danger: #ef4444;
    --radius: 20px;
    --radius-sm: 14px;
    --radius-lg: 28px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    user-select: none;
    overscroll-behavior: none;
    position: relative;
}

/* ============================================================
   خلفية فخمة
   ============================================================ */

.bg-layer {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.glow-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #3b82f6, transparent 70%);
    top: -150px;
    right: -100px;
    animation-delay: 0s;
}

.glow-2 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #a78bfa, transparent 70%);
    bottom: -120px;
    left: -100px;
    animation-delay: -7s;
}

.glow-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, #06b6d4, transparent 70%);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.15;
    animation-delay: -14s;
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, black 30%, transparent 70%);
}

@keyframes float {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    33% {
        transform: translate(30px, -40px) scale(1.1);
    }
    66% {
        transform: translate(-30px, 30px) scale(0.95);
    }
}

/* ============================================================
   App Container
   ============================================================ */

.app {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ============================================================
   Header
   ============================================================ */

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 20px 12px;
    flex-shrink: 0;
}

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

.brand-logo {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(167, 139, 250, 0.1));
    border: 1px solid rgba(96, 165, 250, 0.25);
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    animation: logoPulse 4s ease-in-out infinite;
}

.brand-logo svg {
    width: 100%;
    height: 100%;
}

@keyframes logoPulse {
    0%, 100% {
        box-shadow: 0 8px 32px rgba(59, 130, 246, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    }
    50% {
        box-shadow: 0 8px 40px rgba(96, 165, 250, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    }
}

.brand-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-title {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #ffffff 0%, #60a5fa 50%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.brand-dot {
    color: #60a5fa;
    -webkit-text-fill-color: #60a5fa;
}

.brand-sub {
    font-size: 8px;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 3px;
    text-transform: uppercase;
}

.badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.25);
    border-radius: 999px;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.15);
}

.badge-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(1.3); }
}

.badge-text {
    font-size: 10px;
    font-weight: 800;
    color: var(--success);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============================================================
   Screens
   ============================================================ */

.screen {
    display: none;
    flex: 1;
    padding: 16px 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.screen.active {
    display: flex;
    flex-direction: column;
    animation: screenIn 0.45s var(--ease);
}

@keyframes screenIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================================
   Upload Zone
   ============================================================ */

#screen-main {
    gap: 16px;
    justify-content: center;
}

.upload-zone {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background:
        radial-gradient(circle at 50% 0%, rgba(96, 165, 250, 0.08), transparent 60%),
        linear-gradient(135deg, rgba(20, 20, 30, 0.8), rgba(10, 10, 18, 0.9));
    border: 1.5px dashed rgba(96, 165, 250, 0.3);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.4s var(--ease);
    min-height: 240px;
    max-height: 380px;
    overflow: hidden;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.upload-zone::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1.5px;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.5), transparent 40%, transparent 60%, rgba(167, 139, 250, 0.5));
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.6;
    pointer-events: none;
    animation: borderShine 3s linear infinite;
}

@keyframes borderShine {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.9; }
}

.upload-zone:active,
.upload-zone.drag-over {
    border-color: rgba(96, 165, 250, 0.7);
    background:
        radial-gradient(circle at 50% 0%, rgba(96, 165, 250, 0.15), transparent 60%),
        linear-gradient(135deg, rgba(30, 30, 45, 0.9), rgba(15, 15, 25, 0.95));
    transform: scale(0.985);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 60px rgba(96, 165, 250, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.upload-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.03) 50%, transparent 60%);
    pointer-events: none;
    transform: translateX(-100%);
    animation: shine 4s ease-in-out infinite;
}

@keyframes shine {
    0%, 100% { transform: translateX(-100%); }
    50% { transform: translateX(100%); }
}

.upload-inner {
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
}

.upload-icon {
    width: 68px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(6, 182, 212, 0.08));
    border: 1px solid rgba(96, 165, 250, 0.3);
    border-radius: 20px;
    color: var(--primary-bright);
    box-shadow:
        0 8px 24px rgba(59, 130, 246, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.upload-icon svg {
    width: 36px;
    height: 36px;
}

.upload-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.3px;
}

.upload-hint {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ============================================================
   File Info
   ============================================================ */

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    border: 1px solid var(--border-hi);
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.4s var(--ease-spring);
}

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

.file-info.hidden {
    display: none;
}

.file-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.2), rgba(6, 182, 212, 0.1));
    border-radius: 10px;
    color: var(--primary-bright);
    flex-shrink: 0;
}

.file-icon svg {
    width: 20px;
    height: 20px;
}

.file-details {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 13px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text);
    margin-bottom: 2px;
}

.file-meta {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.remove-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 10px;
    color: var(--danger);
    cursor: pointer;
    font-size: 16px;
    font-weight: 700;
    transition: all 0.2s;
    flex-shrink: 0;
}

.remove-btn:active {
    background: rgba(239, 68, 68, 0.3);
    transform: scale(0.92);
}

/* ============================================================
   Buttons
   ============================================================ */

.btn-primary {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 28px;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1e40af 100%);
    border: none;
    border-radius: var(--radius-sm);
    color: #fff;
    font-family: var(--font);
    font-weight: 800;
    font-size: 16px;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: all 0.3s var(--ease);
    box-shadow:
        0 12px 32px rgba(59, 130, 246, 0.35),
        0 0 0 1px rgba(96, 165, 250, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    width: 100%;
    overflow: hidden;
}

.btn-primary::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.15) 50%, transparent 60%);
    transform: translateX(-100%);
    animation: shine 3s ease-in-out infinite;
}

.btn-shine {
    position: absolute;
    inset: 0;
    background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.2) 50%, transparent 60%);
    pointer-events: none;
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.97);
    box-shadow:
        0 6px 20px rgba(59, 130, 246, 0.4),
        0 0 0 1px rgba(96, 165, 250, 0.4);
}

.btn-primary:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-primary span {
    position: relative;
    z-index: 1;
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    border: 1.5px solid var(--border-hi);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.25s var(--ease);
    width: 100%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.btn-secondary:active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border-color: var(--primary-bright);
    transform: scale(0.97);
}

.btn-ghost {
    padding: 16px;
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: color 0.2s;
    width: 100%;
    letter-spacing: 0.3px;
}

.btn-ghost:active {
    color: var(--primary-bright);
}

/* ============================================================
   Stats Row
   ============================================================ */

.stats-row {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-value {
    font-size: 18px;
    font-weight: 900;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 9px;
    color: var(--text-muted);
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.stat-divider {
    width: 1px;
    height: 24px;
    background: linear-gradient(to bottom, transparent, var(--border-hi), transparent);
}

/* ============================================================
   Processing
   ============================================================ */

#screen-processing {
    align-items: center;
    justify-content: center;
}

.processing-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 340px;
    text-align: center;
}

.spinner-wrap {
    position: relative;
    width: 120px;
    height: 120px;
}

.spinner-outer {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: var(--primary);
    border-right-color: var(--accent-2);
    border-radius: 50%;
    animation: spin 1.2s cubic-bezier(0.5, 0.15, 0.5, 0.85) infinite;
    filter: drop-shadow(0 0 12px rgba(96, 165, 250, 0.5));
}

.spinner-inner {
    position: absolute;
    inset: 16px;
    border: 3px solid transparent;
    border-bottom-color: var(--accent);
    border-left-color: var(--accent-2);
    border-radius: 50%;
    animation: spin 1s linear infinite reverse;
}

.spinner-core {
    position: absolute;
    inset: 40px;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.6), transparent 70%);
    border-radius: 50%;
    animation: pulse 1.5s ease-in-out infinite;
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(0.9);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.15);
        opacity: 1;
    }
}

.proc-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.proc-status {
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 600;
    letter-spacing: 0.3px;
}

.progress-wrap {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa, #a78bfa);
    border-radius: 999px;
    transition: width 0.3s var(--ease);
    box-shadow: 0 0 16px rgba(96, 165, 250, 0.6);
    position: relative;
    overflow: hidden;
}

.progress-fill::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: progressShine 1.5s linear infinite;
}

@keyframes progressShine {
    from { transform: translateX(-100%); }
    to { transform: translateX(100%); }
}

.progress-text {
    font-size: 26px;
    font-weight: 900;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.5px;
}

/* ============================================================
   Done
   ============================================================ */

#screen-done {
    align-items: center;
    justify-content: center;
}

.done-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 18px;
    width: 100%;
    max-width: 340px;
    text-align: center;
}

.done-icon {
    position: relative;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.2), transparent 70%);
    border: 3px solid var(--success);
    border-radius: 50%;
    color: var(--success);
    animation: pop 0.6s var(--ease-spring);
    box-shadow:
        0 0 40px rgba(16, 185, 129, 0.4),
        inset 0 0 20px rgba(16, 185, 129, 0.2);
}

.done-icon svg {
    width: 48px;
    height: 48px;
    filter: drop-shadow(0 0 10px rgba(16, 185, 129, 0.8));
}

.done-pulse {
    position: absolute;
    inset: -10px;
    border: 2px solid rgba(16, 185, 129, 0.4);
    border-radius: 50%;
    animation: pulseRing 2s ease-in-out infinite;
}

@keyframes pulseRing {
    0%, 100% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.15);
        opacity: 0;
    }
}

@keyframes pop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
}

.done-title {
    font-size: 26px;
    font-weight: 900;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, #ffffff, #60a5fa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.done-sub {
    font-size: 14px;
    color: var(--text-dim);
    font-weight: 600;
    margin-bottom: 8px;
}

.done-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* ============================================================
   Footer
   ============================================================ */

.footer {
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    flex-shrink: 0;
}

.footer-line {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border-hi), transparent);
    margin-bottom: 12px;
}

.footer-text {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.footer-icon {
    font-size: 12px;
}

/* ============================================================
   Utility
   ============================================================ */

.hidden {
    display: none !important;
}

/* ============================================================
   Scrollbar
   ============================================================ */

::-webkit-scrollbar {
    width: 0;
    display: none;
}

/* ============================================================
   Small screens
   ============================================================ */

@media (max-width: 360px) {
    .brand-logo { width: 40px; height: 40px; }
    .brand-title { font-size: 20px; }
    .upload-icon { width: 56px; height: 56px; }
    .upload-title { font-size: 18px; }
    .done-title { font-size: 22px; }
}