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

:root {
    --bg: #050505;
    --bg-card: rgba(0, 255, 135, 0.02);
    --bg-card-hover: rgba(0, 255, 135, 0.04);
    --border: rgba(0, 255, 135, 0.08);
    --border-focus: rgba(0, 255, 135, 0.45);
    --text: #e4e4e7;
    --text-2: #8a8a8f;
    --text-3: #444448;
    --accent: #00ff87;
    --accent-2: #10b981;
    --accent-bg: rgba(0, 255, 135, 0.06);
    --green: #00ff87;
    --green-bg: rgba(0, 255, 135, 0.05);
    --green-border: rgba(0, 255, 135, 0.18);
    --red: #ff4444;
    --red-bg: rgba(255, 68, 68, 0.06);
    --red-border: rgba(255, 68, 68, 0.14);
    --radius: 12px;
    --radius-lg: 16px;
    --fast: 0.15s ease;
    --smooth: 0.25s ease;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    position: relative;
}

/* ===== Background ===== */
.bg-orbs {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.15;
    animation: orbDrift 25s ease-in-out infinite;
}

.orb--1 {
    width: 600px; height: 600px;
    background: #00ff87;
    top: -20%; left: -10%;
}

.orb--2 {
    width: 500px; height: 500px;
    background: #a855f7;
    bottom: -15%; right: -10%;
    animation-delay: -8s;
}

.orb--3 {
    width: 350px; height: 350px;
    background: #10b981;
    top: 40%; left: 55%;
    animation-delay: -16s;
    opacity: 0.08;
}

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

.bg-noise {
    position: fixed;
    inset: 0;
    opacity: 0.03;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* ===== Container ===== */
.container {
    width: 100%;
    max-width: 640px;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 1;
}

/* ===== Header ===== */
header { text-align: center; margin-bottom: 2.5rem; }

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0.6rem;
}

.logo-icon {
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius);
    background: linear-gradient(135deg, #10b981 0%, #00ff87 100%);
    color: #050505;
    box-shadow: 0 0 24px -4px rgba(0, 255, 135, 0.4);
    flex-shrink: 0;
}

header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
}

.subtitle {
    color: var(--text-3);
    font-size: 0.9rem;
    font-weight: 400;
}

/* ===== Input Group ===== */
.search-form { margin-bottom: 0; }

.input-group {
    display: flex;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    border: 1px solid var(--border);
    transition: border-color var(--smooth), box-shadow var(--smooth);
}

.input-group:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(0, 255, 135, 0.08), 0 8px 32px -8px rgba(0, 0, 0, 0.5);
}

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

.input-icon {
    position: absolute;
    left: 1rem;
    color: var(--text-3);
    pointer-events: none;
    transition: color var(--smooth);
}

.input-wrapper:focus-within .input-icon { color: var(--accent); }

#url-input {
    width: 100%;
    padding: 0.95rem 1rem 0.95rem 2.85rem;
    font-size: 0.92rem;
    font-family: inherit;
    font-weight: 500;
    border: none;
    background: transparent;
    color: var(--text);
    outline: none;
}

#url-input::placeholder { color: var(--text-3); font-weight: 400; }

#url-input.pasted { animation: flash 0.5s ease; }

@keyframes flash {
    0% { background: rgba(0, 255, 135, 0.1); }
    100% { background: transparent; }
}

/* ===== Fetch Button ===== */
#fetch-btn {
    display: flex; align-items: center; justify-content: center; gap: 0.45rem;
    padding: 0.95rem 1.5rem;
    font-size: 0.88rem;
    font-family: inherit;
    font-weight: 600;
    border: none;
    background: linear-gradient(135deg, #10b981 0%, #00ff87 100%);
    color: #050505;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity var(--fast), transform var(--fast);
}

#fetch-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
#fetch-btn:active:not(:disabled) { transform: scale(0.97); }
#fetch-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-icon { flex-shrink: 0; }
.btn-label { transition: opacity var(--fast); }

.btn-spinner {
    width: 18px; height: 18px;
    border: 2.5px solid rgba(5,5,5,0.3);
    border-top-color: #050505;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* ===== Cards ===== */
.card {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: background var(--smooth);
}

.card-header {
    display: flex; align-items: center; gap: 0.5rem;
    margin-bottom: 0.85rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-2);
}

.card-header svg { color: var(--accent); }

.card-body { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* ===== Format Select ===== */
.formats-body { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.select-wrapper { flex: 1; min-width: 180px; position: relative; }

#format-select {
    width: 100%;
    padding: 0.65rem 2.2rem 0.65rem 0.85rem;
    font-size: 0.85rem;
    font-family: inherit;
    font-weight: 500;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(9, 9, 11, 0.8);
    color: var(--text);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color var(--smooth);
}

#format-select:focus { border-color: var(--border-focus); }
#format-select option { background: #0a0a0a; color: var(--text); }

.select-chevron {
    position: absolute; right: 0.6rem; top: 50%; transform: translateY(-50%);
    color: var(--text-3); pointer-events: none;
}

/* ===== Primary Button ===== */
.btn-primary {
    display: flex; align-items: center; gap: 0.45rem;
    padding: 0.65rem 1.25rem;
    font-size: 0.88rem;
    font-family: inherit;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #10b981 0%, #00ff87 100%);
    color: #050505;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity var(--fast), transform var(--fast);
}

.btn-primary:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: scale(0.97); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary.loading { pointer-events: none; }

/* ===== Status Card ===== */
.status-card {
    display: flex; align-items: center; gap: 1rem;
    position: relative;
    padding: 1.25rem;
}

.progress-ring-container { position: relative; width: 72px; height: 72px; flex-shrink: 0; }
.progress-ring { transform: rotate(-90deg); }
.progress-ring__bg { stroke: rgba(255,255,255,0.04); }

.progress-ring__fill {
    stroke: var(--accent);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
    filter: drop-shadow(0 0 6px rgba(0, 255, 135, 0.4));
}

.progress-pct {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.82rem; font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

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

.status-text {
    color: var(--text-2);
    font-size: 0.82rem;
    font-weight: 500;
    margin-bottom: 0.6rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.progress-track {
    width: 100%; height: 4px;
    background: rgba(255,255,255,0.04);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #10b981, #00ff87);
    border-radius: 2px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-bar__glow {
    position: absolute; inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shimmer 1.5s ease-in-out infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.cancel-btn {
    position: absolute; top: 0.75rem; right: 0.75rem;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border: 1px solid var(--red-border);
    border-radius: 50%;
    background: transparent;
    color: var(--red);
    cursor: pointer;
    transition: background var(--fast), transform var(--fast);
}

.cancel-btn:hover:not(:disabled) { background: var(--red-bg); transform: scale(1.08); }
.cancel-btn:active:not(:disabled) { transform: scale(0.95); }
.cancel-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Result Card ===== */
.result-card {
    display: flex; align-items: center; gap: 0.85rem;
    border-color: var(--green-border) !important;
    background: var(--green-bg) !important;
    animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes popIn {
    0% { transform: scale(0.95); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.result-icon {
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(0, 255, 135, 0.1);
    color: var(--green);
    flex-shrink: 0;
}

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

.result-label {
    font-size: 0.72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.06em;
    color: var(--green);
    margin-bottom: 0.15rem;
}

.result-name {
    font-size: 0.82rem; color: var(--text-2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.btn-save {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    background: linear-gradient(135deg, #10b981 0%, #00ff87 100%);
    color: #050505;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.82rem; font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
    transition: opacity var(--fast), transform var(--fast);
}

.btn-save:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-save:active { transform: scale(0.97); }

/* ===== Error Card ===== */
.error-card {
    display: flex; align-items: center; gap: 0.7rem;
    border-color: var(--red-border) !important;
    background: var(--red-bg) !important;
    animation: shake 0.35s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}

.error-icon {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(255, 68, 68, 0.1);
    color: var(--red);
    flex-shrink: 0;
}

#error-text {
    flex: 1;
    color: var(--red);
    font-size: 0.82rem; font-weight: 500;
    line-height: 1.4;
}

.error-dismiss {
    width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: transparent;
    color: var(--text-3); cursor: pointer;
    flex-shrink: 0;
    transition: color var(--fast), background var(--fast);
}

.error-dismiss:hover { color: var(--red); background: rgba(248, 113, 113, 0.1); }

/* ===== Footer ===== */
footer { margin-top: 1rem; text-align: center; }

.platforms {
    display: flex; flex-wrap: wrap; justify-content: center;
    gap: 0.35rem; margin-bottom: 0.85rem;
}

.platform-badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    font-size: 0.65rem; font-weight: 600;
    color: var(--text-3);
    background: transparent;
    border: 1px solid rgba(255,255,255,0.04);
    border-radius: 100px;
    transition: all var(--smooth);
    cursor: default;
}

.footer-note {
    color: var(--text-3);
    font-size: 0.68rem; font-weight: 500;
}

.footer-note a {
    color: var(--text-3);
    text-decoration: none;
    transition: color 0.2s;
}
.footer-note a:hover { color: var(--accent); }

.admin-link {
    color: var(--text-3);
    text-decoration: none;
    transition: color 0.2s;
}
.admin-link:hover { color: var(--accent); }

/* ===== Utility ===== */
.hidden { display: none !important; }

.animate-in { animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }

@keyframes slideUp {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .container { padding: 1.5rem 1rem; }
    header h1 { font-size: 1.4rem; }
    .logo-icon { width: 38px; height: 38px; }
    .logo-icon svg { width: 22px; height: 22px; }

    .input-group { flex-direction: column; }
    .input-wrapper { border-bottom: 1px solid var(--border); }
    #fetch-btn { padding: 0.85rem; }

    .formats-body { flex-direction: column; }
    .select-wrapper { min-width: 100%; }
    .btn-primary { width: 100%; justify-content: center; }

    .status-card { flex-direction: column; text-align: center; padding: 1.25rem 1rem; }
    .cancel-btn { position: static; margin-top: 0.5rem; }
    .status-text { white-space: normal; }

    .result-card { flex-direction: column; text-align: center; }
    .result-name { white-space: normal; word-break: break-all; }
    .btn-save { width: 100%; justify-content: center; }

    .error-card { flex-direction: column; text-align: center; position: relative; padding-top: 1.25rem; }
    .error-dismiss { position: absolute; top: 0.4rem; right: 0.4rem; }
}

@media (max-width: 360px) {
    .container { padding: 1rem 0.75rem; }
    header h1 { font-size: 1.2rem; }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .orb { animation: none; }
    .progress-bar__glow { animation: none; }
    .btn-spinner { animation-duration: 0.6s !important; animation-iteration-count: infinite !important; }
}

/* ===== Selection & Scrollbar ===== */
::selection { background: rgba(0, 255, 135, 0.2); color: #fff; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }
