/* ============================================================
   NLP Document Summarizer — Style
   Cloudflare Pages Edition
   ============================================================ */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --primary-glow: rgba(99, 102, 241, 0.25);

    --bg: #0a0a12;
    --bg-card: #111120;
    --bg-card-2: #16162a;
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(99,102,241,0.4);

    --text: #f1f1f8;
    --text-muted: #8888aa;
    --text-dim: #555570;

    --success: #22c55e;
    --error: #f87171;
    --warning: #fb923c;

    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 0 0 1px var(--border), 0 24px 60px rgba(0,0,0,0.5);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    padding: 24px 16px 60px;
}

/* ---- Background Orbs ---- */
.bg-orbs {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.18;
}
.orb-1 {
    width: 500px; height: 500px;
    background: radial-gradient(circle, #6366f1, transparent 70%);
    top: -150px; left: -100px;
    animation: drift 12s ease-in-out infinite alternate;
}
.orb-2 {
    width: 400px; height: 400px;
    background: radial-gradient(circle, #8b5cf6, transparent 70%);
    bottom: -100px; right: -100px;
    animation: drift 15s ease-in-out infinite alternate-reverse;
}
@keyframes drift {
    from { transform: translate(0, 0); }
    to   { transform: translate(40px, 40px); }
}

/* ---- Layout ---- */
.container {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* ---- Header ---- */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 4px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}
.logo svg { color: var(--primary-light); }
.badge {
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding: 4px 10px;
    background: rgba(99,102,241,0.15);
    border: 1px solid rgba(99,102,241,0.3);
    border-radius: 999px;
    color: var(--primary-light);
    text-transform: uppercase;
}

/* ---- Hero ---- */
.hero { text-align: center; padding: 8px 0 4px; }

.hero h1 {
    font-size: clamp(2rem, 5vw, 2.8rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.035em;
    color: var(--text);
    margin-bottom: 14px;
}
.gradient-text {
    background: linear-gradient(135deg, var(--primary-light) 0%, #a78bfa 50%, #60a5fa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-sub {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.65;
    max-width: 480px;
    margin: 0 auto 24px;
}
.hero-stats {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 10px 24px;
}
.stat { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.stat-num { font-size: 0.85rem; font-weight: 700; color: var(--primary-light); }
.stat-lbl { font-size: 0.65rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-divider { width: 1px; height: 28px; background: var(--border); }

/* ---- Main Card ---- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 32px;
    backdrop-filter: blur(12px);
}

/* ---- Step Label ---- */
.step-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 18px;
}
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px; height: 22px;
    background: rgba(99,102,241,0.2);
    color: var(--primary-light);
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
}

/* ---- Upload Zone ---- */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
    background: rgba(255,255,255,0.02);
    margin-bottom: 14px;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--primary);
    background: rgba(99,102,241,0.06);
    transform: translateY(-1px);
}
.upload-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 40px 24px;
    text-align: center;
}
.upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px; height: 64px;
    background: rgba(99,102,241,0.12);
    border-radius: 14px;
    color: var(--primary-light);
    margin-bottom: 4px;
    transition: background 0.2s, transform 0.2s;
}
.upload-zone:hover .upload-icon {
    background: rgba(99,102,241,0.2);
    transform: scale(1.05);
}
.upload-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}
.upload-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
}
.link-text {
    color: var(--primary-light);
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.upload-tags { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.tag {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-dim);
}

/* ---- File Preview ---- */
.file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 16px;
}
.file-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    background: rgba(99,102,241,0.2);
    border-radius: 8px;
    color: var(--primary-light);
    flex-shrink: 0;
}
.file-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.file-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-size { font-size: 0.75rem; color: var(--text-muted); }
.file-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.file-remove:hover { border-color: var(--error); color: var(--error); background: rgba(248,113,113,0.08); }

/* ---- Buttons ---- */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 4px 20px rgba(99,102,241,0.35);
    font-family: inherit;
}
.btn-primary:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}
.btn-primary:not(:disabled):hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 8px 28px rgba(99,102,241,0.45);
}
.btn-primary:not(:disabled):active { transform: translateY(0); }

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 24px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
    font-family: inherit;
}
.btn-secondary:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: rgba(99,102,241,0.06);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-icon:hover { border-color: var(--border-hover); color: var(--text); background: rgba(99,102,241,0.08); }
.btn-icon.copied { border-color: var(--success); color: var(--success); background: rgba(34,197,94,0.08); }

/* ---- Loading ---- */
.loading-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 16px;
    text-align: center;
}
.loading-ring {
    position: relative;
    width: 64px; height: 64px;
    margin-bottom: 8px;
}
.loading-svg {
    width: 64px; height: 64px;
    animation: rotate 2s linear infinite;
}
@keyframes rotate { to { transform: rotate(360deg); } }

.loading-circle {
    stroke: var(--primary);
    stroke-linecap: round;
    stroke-dasharray: 80 200;
    animation: dash 1.5s ease-in-out infinite;
}
@keyframes dash {
    0%   { stroke-dasharray: 1 200; stroke-dashoffset: 0; }
    50%  { stroke-dasharray: 100 200; stroke-dashoffset: -30px; }
    100% { stroke-dasharray: 100 200; stroke-dashoffset: -125px; }
}
.loading-icon {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-light);
}
.loading-title { font-size: 1rem; font-weight: 700; }
.loading-sub { font-size: 0.85rem; color: var(--text-muted); }

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
    width: 100%;
    max-width: 260px;
    text-align: left;
}
.lstep {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-dim);
    transition: color 0.3s;
}
.lstep.active { color: var(--text-muted); }
.lstep.done { color: var(--success); }
.lstep-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: background 0.3s;
}
.lstep.active .lstep-dot { background: var(--primary); box-shadow: 0 0 8px var(--primary-glow); animation: pulse-dot 1.2s ease-in-out infinite; }
.lstep.done .lstep-dot { background: var(--success); }
@keyframes pulse-dot { 0%,100% { transform: scale(1); opacity:1; } 50% { transform: scale(1.4); opacity:0.7; } }

/* ---- Results ---- */
.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.result-title-wrap { display: flex; align-items: center; gap: 10px; }
.result-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px; height: 26px;
    background: rgba(34,197,94,0.15);
    border-radius: 50%;
    color: var(--success);
}
.result-title { font-size: 1.1rem; font-weight: 700; }

.result-body {
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 16px;
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.result-body::-webkit-scrollbar { width: 4px; }
.result-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.summary-text {
    font-size: 0.9rem;
    line-height: 1.8;
    color: #c4c4d4;
    white-space: pre-wrap;
}

.result-meta {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    color: var(--text-dim);
}
.meta-item svg { flex-shrink: 0; }

/* ---- Error ---- */
.error-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 16px;
    text-align: center;
}
.error-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px; height: 56px;
    background: rgba(248,113,113,0.1);
    border-radius: 50%;
    color: var(--error);
    margin-bottom: 4px;
}
.error-wrap h3 { font-size: 1rem; font-weight: 700; }
.error-wrap p { font-size: 0.85rem; color: var(--text-muted); max-width: 320px; }
.error-wrap .btn-secondary { margin-top: 8px; width: auto; padding: 10px 24px; }

/* ---- Footer ---- */
.footer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-dim);
    padding: 0 4px;
}

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

/* ---- Responsive ---- */
@media (max-width: 520px) {
    body { padding: 16px 12px 50px; }
    .container { gap: 20px; }
    .card { padding: 22px 18px; }
    .hero h1 { font-size: 1.75rem; }
    .hero-stats { padding: 8px 16px; gap: 12px; }
    .hero-sub { font-size: 0.9rem; }
    .upload-inner { padding: 28px 16px; }
}
