:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --success: #22c55e;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.4;
    animation: move 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #4f46e5;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: #7c3aed;
    bottom: -50px;
    right: -50px;
    animation-delay: -5s;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: #2563eb;
    top: 40%;
    left: 60%;
    animation-delay: -10s;
}

@keyframes move {
    from { transform: translate(0, 0); }
    to { transform: translate(100px, 100px); }
}

/* Container */
.container {
    width: 90%;
    max-width: 800px;
    padding: 2rem;
    z-index: 1;
}

header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 3.5rem;
    font-weight: 600;
    letter-spacing: -1px;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-top: 0.5rem;
}

/* Card */
.downloader-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease;
}

.downloader-card:hover {
    transform: translateY(-3px);
}

/* Format Selector */
.format-selector {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.4rem;
    border-radius: 12px;
    width: fit-content;
}

.format-btn {
    padding: 0.55rem 1.2rem;
    font-size: 0.85rem;
    min-width: auto;
    border-radius: 8px;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.25s ease;
}

.format-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--text-main);
    transform: none;
}

.format-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.35);
}

/* OCR Language Panel */
.ocr-panel {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    animation: slideDown 0.25s ease;
}

.ocr-panel.visible {
    display: flex;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ocr-panel label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.ocr-panel select {
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 0.6rem 1rem;
    color: white;
    font-size: 0.95rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.2s;
}

.ocr-panel select:focus {
    outline: none;
    border-color: var(--primary);
}

.ocr-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.7;
}

/* Input Group */
.input-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
}

input {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    color: white;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

button {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 0 2rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    min-width: 140px;
    font-family: inherit;
}

button:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

button:active {
    transform: scale(0.98);
}

button.loading .btn-text {
    visibility: hidden;
}

.loader {
    display: none;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s ease-in-out infinite;
    position: absolute;
    top: calc(50% - 10px);
    left: calc(50% - 10px);
}

button.loading .loader {
    display: block;
}

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

/* Progress */
.progress-container {
    margin-bottom: 1.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.progress-container.active {
    opacity: 1;
}

.status-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 8px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, #6366f1, #a855f7);
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

/* Download Result Banner */
.download-result {
    display: none;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 12px;
    margin-bottom: 1.5rem;
    animation: slideDown 0.3s ease;
}

.download-result.visible {
    display: flex;
}

.result-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.result-label {
    font-size: 0.85rem;
    color: var(--success);
    font-weight: 600;
}

.result-filename {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: 'Monaco', 'Consolas', monospace;
    word-break: break-all;
}

.save-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: var(--success);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.save-btn:hover {
    background: #16a34a;
    transform: scale(1.03);
}

/* Logs */
.log-container {
    background: rgba(0, 0, 0, 0.4);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    padding: 1rem;
}

.log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#clearLogs {
    background: transparent;
    padding: 4px 8px;
    min-width: auto;
    font-size: 0.7rem;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    color: var(--text-muted);
}

#clearLogs:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--text-muted);
}

.log-content {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.log-entry {
    margin-bottom: 0.4rem;
    line-height: 1.4;
    word-break: break-all;
}

.log-entry.error   { color: #f87171; }
.log-entry.success { color: #4ade80; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

footer {
    text-align: center;
    margin-top: 3rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
