/* ─────────────────────────────────────
   Scribe — Design System
   Modern, light, professional
   ───────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

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

:root {
    /* Primary palette */
    --primary-50: #f0f4ff;
    --primary-100: #dbe4ff;
    --primary-200: #bac8ff;
    --primary-400: #748ffc;
    --primary-500: #5c7cfa;
    --primary-600: #4c6ef5;
    --primary-700: #4263eb;
    --primary-800: #3b5bdb;

    /* Accent */
    --accent-400: #38d9a9;
    --accent-500: #20c997;
    --accent-600: #12b886;

    /* Neutral */
    --gray-50: #f8f9fc;
    --gray-100: #f1f3f9;
    --gray-200: #e2e6ef;
    --gray-300: #cdd3e0;
    --gray-400: #a3adc2;
    --gray-500: #7c879e;
    --gray-600: #5f6b82;
    --gray-700: #44506a;
    --gray-800: #2d3652;
    --gray-900: #1a2138;

    /* Semantic */
    --danger-50: #fff5f5;
    --danger-100: #ffe3e3;
    --danger-500: #ff6b6b;
    --danger-600: #fa5252;

    --warning-50: #fff9db;
    --warning-500: #fcc419;

    --success-50: #ebfbee;
    --success-500: #51cf66;
    --success-600: #40c057;

    /* Surface */
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.72);
    --bg: #f4f6fb;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(26, 33, 56, 0.04), 0 1px 2px rgba(26, 33, 56, 0.06);
    --shadow-md: 0 4px 12px rgba(26, 33, 56, 0.06), 0 2px 4px rgba(26, 33, 56, 0.04);
    --shadow-lg: 0 12px 40px rgba(26, 33, 56, 0.08), 0 4px 12px rgba(26, 33, 56, 0.04);
    --shadow-xl: 0 20px 60px rgba(26, 33, 56, 0.10);
    --shadow-primary: 0 4px 16px rgba(76, 110, 245, 0.25);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;
    --radius-full: 9999px;

    /* Typography */
    --font: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

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

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Decorative Blobs ────────────── */
.blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    pointer-events: none;
    z-index: 0;
}
.blob-1 {
    width: 500px; height: 500px;
    background: var(--primary-200);
    top: -120px; right: -100px;
    animation: blobFloat 20s ease-in-out infinite alternate;
}
.blob-2 {
    width: 400px; height: 400px;
    background: var(--accent-400);
    bottom: -80px; left: -80px;
    animation: blobFloat 25s ease-in-out infinite alternate-reverse;
}
.blob-3 {
    width: 300px; height: 300px;
    background: var(--primary-100);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation: blobFloat 18s ease-in-out infinite alternate;
}
@keyframes blobFloat {
    0%   { transform: translate(0, 0) scale(1); }
    50%  { transform: translate(30px, -20px) scale(1.05); }
    100% { transform: translate(-20px, 15px) scale(0.95); }
}

/* ── App Container ───────────────── */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 860px;
    margin: 0 auto;
    padding: 32px 20px 60px;
}

/* ── Header ──────────────────────── */
header {
    text-align: center;
    margin-bottom: 36px;
}
.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}
.logo-icon {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    border-radius: var(--radius-md);
    display: grid;
    place-items: center;
    color: white;
    box-shadow: var(--shadow-primary);
}
.logo-text {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--primary-700), var(--primary-500));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.tagline {
    font-size: 0.95rem;
    color: var(--gray-500);
    font-weight: 400;
}

/* ── Section Title ───────────────── */
.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.section-title svg {
    color: var(--primary-500);
}

/* ── API Dashboard ───────────────── */
.api-dashboard {
    margin-bottom: 28px;
}
.api-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}
.api-card {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s var(--ease);
    position: relative;
    overflow: hidden;
    user-select: none;
}
.api-card:hover {
    border-color: var(--primary-400);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    background: var(--surface);
}
.api-card.selected {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px var(--primary-100), var(--shadow-md);
    background: var(--primary-50);
}

/* Gauge (SVG circle) */
.gauge-wrapper {
    position: relative;
    width: 88px; height: 88px;
}
.gauge-svg {
    transform: rotate(-90deg);
    width: 88px; height: 88px;
}
.gauge-bg {
    fill: none;
    stroke: var(--gray-200);
    stroke-width: 4.5;
}
.gauge-fill {
    fill: none;
    stroke: url(#gaugeGradient);
    stroke-width: 4.5;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s var(--ease);
}
.gauge-text {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    text-align: center;
}
.gauge-time {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--gray-900);
    letter-spacing: -0.3px;
}
.gauge-label {
    font-size: 0.58rem;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.api-card-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--gray-700);
    text-align: center;
}
.api-card-percent {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--primary-500);
    background: var(--primary-50);
    padding: 2px 8px;
    border-radius: var(--radius-full);
}
.api-card-meta {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 0.72rem;
    color: var(--gray-500);
}
.api-card-renewal {
    display: flex;
    align-items: center;
    gap: 3px;
}
.renewal-icon {
    display: flex;
    align-items: center;
    color: var(--accent-500);
}
.renewal-icon.urgent {
    color: var(--danger-500);
    animation: iconPulse 1.5s infinite;
}
@keyframes iconPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Hidden select for form submission */
#apiKeySelect {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 0; height: 0;
}

/* ── Workspace (Main Card) ───────── */
.workspace {
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-2xl);
    padding: 32px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 24px;
}

/* ── Upload Area ─────────────────── */
.upload-label {
    cursor: pointer;
    display: block;
}
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-xl);
    padding: 48px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    transition: all 0.35s var(--ease);
    background: var(--gray-50);
}
.upload-area:hover {
    border-color: var(--primary-400);
    background: var(--primary-50);
}
.upload-area.dragover {
    border-color: var(--primary-500);
    background: var(--primary-100);
    transform: scale(1.01);
    box-shadow: 0 0 0 4px var(--primary-50);
}

.upload-icon-wrapper {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-100), var(--primary-50));
    display: grid;
    place-items: center;
    color: var(--primary-500);
    transition: transform 0.35s var(--ease);
}
.upload-area:hover .upload-icon-wrapper {
    transform: translateY(-4px);
}

.upload-text-group {
    text-align: center;
}
.upload-title {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.upload-subtitle {
    font-size: 0.9rem;
    color: var(--gray-500);
}
.upload-subtitle strong {
    color: var(--primary-600);
}
.upload-formats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}
.format-badge {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: var(--gray-100);
    color: var(--gray-600);
    border: 1px solid var(--gray-200);
}
.upload-limit {
    font-size: 0.78rem;
    color: var(--gray-400);
}

/* ── File Card ───────────────────── */
.file-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    background: var(--primary-50);
    border: 1px solid var(--primary-200);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    animation: slideUp 0.35s var(--ease);
}
.file-card-icon {
    width: 44px; height: 44px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    display: grid;
    place-items: center;
    color: white;
    flex-shrink: 0;
}
.file-card-details {
    flex: 1;
    min-width: 0;
}
.file-name {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-800);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-meta {
    display: flex;
    gap: 12px;
    margin-top: 2px;
}
.file-size {
    font-size: 0.8rem;
    color: var(--gray-500);
}
.file-duration {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-600);
}
.file-remove {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--gray-400);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: all 0.2s var(--ease);
    flex-shrink: 0;
}
.file-remove:hover {
    background: var(--danger-100);
    color: var(--danger-600);
}

/* ── Transcribe Button ───────────── */
.transcribe-btn {
    width: 100%;
    padding: 16px 24px;
    border: none;
    border-radius: var(--radius-lg);
    font-family: var(--font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s var(--ease);
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    color: white;
    box-shadow: var(--shadow-primary);
    margin-top: 24px;
}
.transcribe-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(76, 110, 245, 0.35);
}
.transcribe-btn:active:not(:disabled) {
    transform: translateY(0);
}
.transcribe-btn:disabled {
    background: var(--gray-300);
    color: var(--gray-500);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
.loading-spinner {
    width: 20px; height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Progress Card ───────────────── */
.progress-card {
    margin-top: 24px;
    padding: 20px 24px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    animation: slideUp 0.35s var(--ease);
}
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.progress-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--gray-700);
}
.progress-percent {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--primary-600);
}
.progress-track {
    width: 100%;
    height: 6px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 8px;
}
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-500), var(--accent-500));
    border-radius: var(--radius-full);
    transition: width 0.4s var(--ease);
}
.progress-text {
    font-size: 0.78rem;
    color: var(--gray-500);
}

/* ── Result Card ─────────────────── */
.result-card {
    margin-top: 24px;
    animation: slideUp 0.35s var(--ease);
}
.result-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: var(--success-600);
}
.result-header h3 {
    color: var(--gray-800);
    font-size: 1.1rem;
    font-weight: 600;
}
#transcriptText {
    width: 100%;
    min-height: 200px;
    padding: 20px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.88rem;
    line-height: 1.7;
    color: var(--gray-800);
    background: var(--gray-50);
    resize: vertical;
    transition: border-color 0.2s var(--ease);
}
#transcriptText:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px var(--primary-100);
}
.result-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ── Buttons ─────────────────────── */
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s var(--ease);
}
.action-primary {
    background: var(--primary-600);
    color: white;
    border-color: var(--primary-600);
}
.action-primary:hover {
    background: var(--primary-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.action-secondary {
    background: var(--accent-500);
    color: white;
    border-color: var(--accent-500);
}
.action-secondary:hover {
    background: var(--accent-600);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.action-ghost {
    background: transparent;
    color: var(--gray-600);
    border-color: var(--gray-300);
}
.action-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-800);
    border-color: var(--gray-400);
}
.action-danger {
    background: var(--danger-600);
    color: white;
    border-color: var(--danger-600);
}
.action-danger:hover {
    background: var(--danger-500);
}

/* ── Error Card ──────────────────── */
.error-card {
    margin-top: 24px;
    padding: 20px 24px;
    background: var(--danger-50);
    border: 1px solid var(--danger-100);
    border-radius: var(--radius-lg);
    animation: slideUp 0.35s var(--ease);
}
.error-content {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
    color: var(--danger-600);
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ── Tips Section ────────────────── */
.tips-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.tip-block {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: box-shadow 0.3s var(--ease);
}
.tip-block[open] {
    box-shadow: var(--shadow-md);
}
.tip-block summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--gray-700);
    cursor: pointer;
    list-style: none;
    transition: background 0.2s var(--ease);
}
.tip-block summary::-webkit-details-marker {
    display: none;
}
.tip-block summary::after {
    content: '';
    margin-left: auto;
    width: 8px; height: 8px;
    border-right: 2px solid var(--gray-400);
    border-bottom: 2px solid var(--gray-400);
    transform: rotate(-45deg);
    transition: transform 0.3s var(--ease);
}
.tip-block[open] summary::after {
    transform: rotate(45deg);
}
.tip-block summary:hover {
    background: var(--gray-50);
}
.tip-block summary svg {
    color: var(--primary-500);
    flex-shrink: 0;
}
.tip-content {
    padding: 0 20px 20px 48px;
    font-size: 0.85rem;
    color: var(--gray-600);
    line-height: 1.7;
}
.tip-content ol {
    padding-left: 1.2rem;
    margin-top: 6px;
}
.tip-content li {
    margin-bottom: 4px;
}
.tip-content a {
    color: var(--primary-600);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s var(--ease);
}
.tip-content a:hover {
    color: var(--primary-700);
    text-decoration: underline;
}

/* ── Animations ──────────────────── */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Credits Warning ─────────────── */
#creditsWarning {
    background: #fff5f5;
    border: 1px solid #ffe3e3;
    color: var(--danger-700);
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    margin: 16px 0;
    font-size: 0.88rem;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    line-height: 1.5;
    box-shadow: 0 4px 12px rgba(250, 82, 82, 0.08);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
#creditsWarning strong {
    color: var(--danger-800);
    font-weight: 700;
}
#creditsWarning svg {
    flex-shrink: 0;
    margin-top: 2px;
}

/* ── Responsive ──────────────────── */
@media (max-width: 640px) {
    .app-container {
        padding: 20px 14px 40px;
    }
    .logo-text {
        font-size: 1.6rem;
    }
    .logo-icon {
        width: 40px; height: 40px;
    }
    .api-cards {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .api-card {
        padding: 16px 10px;
    }
    .gauge-wrapper {
        width: 76px; height: 76px;
    }
    .gauge-svg {
        width: 76px; height: 76px;
    }
    .gauge-time {
        font-size: 0.82rem;
    }
    .workspace {
        padding: 20px 16px;
        border-radius: var(--radius-xl);
    }
    .upload-area {
        padding: 32px 16px;
    }
    .upload-icon-wrapper {
        width: 64px; height: 64px;
    }
    .upload-svg {
        width: 36px; height: 36px;
    }
    .upload-title {
        font-size: 1rem;
    }
    .result-actions {
        flex-direction: column;
    }
    .action-btn {
        justify-content: center;
    }
    .blob-1 { width: 300px; height: 300px; }
    .blob-2 { width: 250px; height: 250px; }
    .blob-3 { display: none; }
}

@media (max-width: 380px) {
    .api-cards {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .api-card-meta {
        font-size: 0.65rem;
    }
    .gauge-wrapper {
        width: 52px; height: 52px;
    }
    .gauge-svg {
        width: 52px; height: 52px;
    }
}