/* =============================================================================
   Schaefer File Drop — Stylesheet
   ============================================================================= */

/* === CSS Reset === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.6; }

/* === Theme Variables === */
:root {
    --bg: #ffffff;
    --bg-elev: #f5f7fa;
    --bg-card: #ffffff;
    --fg: #1a1d23;
    --fg-muted: #6b7280;
    --border: #e5e7eb;
    --accent: #7c9cff;
    --accent-hover: #6b8ae6;
    --accent-fg: #ffffff;
    --success: #10b981;
    --warn: #f59e0b;
    --error: #ef4444;
    --code-bg: #f3f4f6;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.10), 0 4px 10px rgba(0,0,0,0.06);
    --radius: 10px;
    --radius-sm: 6px;
    --transition: 0.18s ease;
}

[data-theme="dark"] {
    --bg: #0a0c10;
    --bg-elev: #141923;
    --bg-card: #11141b;
    --fg: #e6e9ef;
    --fg-muted: #8b94a3;
    --border: #232834;
    --accent: #7c9cff;
    --accent-hover: #94aeff;
    --accent-fg: #0a0c10;
    --code-bg: #141923;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.3);
}

/* Auto theme — use system preference */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] {
        --bg: #0a0c10;
        --bg-elev: #141923;
        --bg-card: #11141b;
        --fg: #e6e9ef;
        --fg-muted: #8b94a3;
        --border: #232834;
        --accent: #7c9cff;
        --accent-hover: #94aeff;
        --accent-fg: #0a0c10;
        --code-bg: #141923;
        --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
        --shadow-lg: 0 10px 25px rgba(0,0,0,0.4), 0 4px 10px rgba(0,0,0,0.3);
    }
}

/* === Base === */
body {
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background var(--transition), color var(--transition);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace; }
code { background: var(--code-bg); padding: 2px 6px; border-radius: 4px; font-size: 0.92em; }
pre { background: var(--code-bg); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; }

.muted { color: var(--fg-muted); }
.center { text-align: center; }
.hidden { display: none !important; }

/* === Header === */
.header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: color-mix(in srgb, var(--bg-card) 88%, transparent);
}
.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--accent);
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-text { letter-spacing: -0.02em; }

.nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* === Icon Button === */
.icon-btn {
    background: transparent;
    border: none;
    color: var(--fg);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}
.icon-btn:hover { background: var(--bg-elev); }
.icon-btn:active { transform: scale(0.95); }

/* Theme icons */
.theme-icon { display: none; }
[data-theme="auto"] .theme-icon-auto { display: inline; }
[data-theme="light"] .theme-icon-light { display: inline; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

/* === Main === */
.main {
    flex: 1;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* === Card === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 12px;
}
.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--fg);
}

/* === Setup Banner === */
.setup-banner {
    background: color-mix(in srgb, var(--warn) 12%, var(--bg-card));
    border: 1px solid var(--warn);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 20px;
}
.setup-banner h2 { color: var(--warn); margin-bottom: 8px; font-size: 1.1rem; }

/* === Login Form === */
.login-form-wrap { max-width: 480px; }
.form-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.form-row input { flex: 1; }

/* === Form Controls === */
input, select, textarea {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color var(--transition), background var(--transition);
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
input::placeholder { color: var(--fg-muted); }

.checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.checkbox input { width: auto; }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-group label {
    font-size: 0.85rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

/* === Buttons === */
.btn {
    background: var(--accent);
    color: var(--accent-fg);
    border: none;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    transition: background var(--transition), transform var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-ghost { background: transparent; color: var(--fg); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-elev); }
.btn-danger { background: var(--error); color: white; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; justify-content: center; }

/* === Dropzone === */
.upload-area { margin-top: 16px; }
.dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    background: var(--bg-elev);
}
.dropzone:hover, .dropzone.dragover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 5%, var(--bg-elev));
}
.dropzone-icon { color: var(--accent); margin-bottom: 12px; }
.dropzone-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 6px; }
.dropzone-subtitle { font-size: 0.85rem; color: var(--fg-muted); }

/* === Upload Options === */
.upload-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

/* === Upload List === */
.upload-list {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.upload-item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
}
.upload-item-name {
    font-weight: 600;
    margin-bottom: 4px;
    word-break: break-all;
}
.upload-item-meta {
    font-size: 0.85rem;
    color: var(--fg-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
}
.upload-item-meta span { display: inline-flex; align-items: center; gap: 4px; }
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    transition: width 0.3s ease;
}
.upload-item-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}
.upload-result-url {
    flex: 1;
    min-width: 200px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-family: ui-monospace, monospace;
    font-size: 0.85rem;
    word-break: break-all;
    color: var(--fg);
}

/* === File List === */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.file-item {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color var(--transition);
}
.file-item:hover { border-color: var(--accent); }
.file-item-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}
.file-item-body { flex: 1; min-width: 0; }
.file-item-name {
    font-weight: 500;
    word-break: break-all;
    margin-bottom: 2px;
}
.file-item-meta {
    font-size: 0.8rem;
    color: var(--fg-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.file-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* === Stats === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}
.stat-block {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
}
.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--fg-muted);
    margin-bottom: 4px;
}
.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--fg);
}
.stat-sub { font-size: 0.8rem; color: var(--fg-muted); margin-top: 2px; }

/* === Drawer === */
.drawer {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    justify-content: flex-end;
}
.drawer-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(2px);
}
.drawer-content {
    position: relative;
    width: min(380px, 100%);
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    animation: slide-in 0.25s ease;
}
@keyframes slide-in {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.drawer-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.setting-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.setting-row label {
    font-size: 0.85rem;
    color: var(--fg-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* === Toast === */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--fg);
    color: var(--bg);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    font-size: 0.9rem;
    max-width: 90vw;
    animation: toast-in 0.25s ease;
}
.toast.error { background: var(--error); color: white; }
.toast.success { background: var(--success); color: white; }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(10px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 24px 20px;
    color: var(--fg-muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}
.footer a { color: var(--fg-muted); }
.footer a:hover { color: var(--accent); }

/* === QR Modal === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 1500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}
.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
}
.qr-container {
    background: white;
    padding: 16px;
    border-radius: var(--radius-sm);
    display: flex;
    justify-content: center;
    margin: 16px 0;
}
.qr-container img, .qr-container svg { max-width: 100%; height: auto; }

/* === Install Button Pulse === */
#install-btn.pulse {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
    50% { box-shadow: 0 0 0 8px transparent; }
}

/* === Responsive === */
@media (max-width: 640px) {
    .header-inner { padding: 10px 14px; }
    .main { padding: 16px 14px; }
    .card { padding: 16px; }
    .dropzone { padding: 32px 14px; }
    .dropzone-title { font-size: 1rem; }
    .upload-options { grid-template-columns: 1fr; }
    .brand-text { display: none; }
    .file-item { flex-wrap: wrap; }
    .file-item-actions { width: 100%; justify-content: flex-end; }
    .form-row { flex-direction: column; }
    .nav { gap: 0; }
    .icon-btn { width: 36px; height: 36px; font-size: 16px; }
}

/* === Print === */
@media print {
    .header, .footer, .nav, .upload-options, .upload-list { display: none; }
    body { background: white; color: black; }
}

/* === Accessibility === */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
