/* Magazine Builders — app.css
   Minimal design system: dark sidebar, light content, cyan accent.
*/

:root {
    --bg:          #f7f8fb;
    --bg-card:     #ffffff;
    --bg-sidebar:  #0f172a;
    --bg-muted:    #f1f5f9;
    --border:      #e2e8f0;
    --text:        #0f172a;
    --text-muted:  #64748b;
    --text-sidebar:#cbd5e1;
    --accent:      #0891b2;
    --accent-bright:#06b6d4;
    --danger:      #dc2626;
    --success:     #16a34a;
    --warning:     #ea580c;
    --radius:      10px;
    --radius-sm:   6px;
    --shadow:      0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.04);
    --shadow-lg:   0 10px 25px rgba(15,23,42,.1), 0 4px 10px rgba(15,23,42,.05);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ───────── Layout ───────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex-shrink: 0;
    background: var(--bg-sidebar); color: var(--text-sidebar);
    display: flex; flex-direction: column;
    padding: 1.5rem 1rem; gap: 1.5rem;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem .75rem; border-bottom: 1px solid #1e293b; }
.brand-icon { font-size: 1.75rem; }
.brand-name { font-weight: 800; color: #fff; line-height: 1.1; font-size: 1rem; }

.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.nav-section-title {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .1em;
    color: #64748b; padding: .5rem .75rem .25rem;
}
.nav-link {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem .75rem; border-radius: var(--radius-sm);
    color: var(--text-sidebar); font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-link.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 1rem; }

.logout-form { margin: 0; }
.nav-link-button {
    width: 100%; background: none; border: 0; text-align: left;
    font: inherit; cursor: pointer;
}

.sidebar-footer {
    display: flex; align-items: center; gap: .6rem;
    padding: .75rem .5rem 0; border-top: 1px solid #1e293b;
}
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
}
.user-meta { min-width: 0; }
.user-name { color: #fff; font-weight: 600; font-size: .85rem; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; }
.user-role { color: #64748b; font-size: .72rem; text-transform: capitalize; }

.main {
    flex: 1; padding: 2rem 2.5rem;
    max-width: 1400px; width: 100%;
}

/* ───────── Page header ───────── */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.subtitle { color: var(--text-muted); font-size: .9rem; margin-top: .2rem; }

/* ───────── Buttons ───────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .55rem 1rem; border-radius: var(--radius-sm);
    font-weight: 600; font-size: .875rem;
    border: 1px solid transparent; cursor: pointer;
    transition: transform .05s, background .15s, box-shadow .15s;
    text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-bright); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-muted); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-lg { padding: .85rem 1.4rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ───────── Cards ───────── */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 1.25rem;
    box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.card-header h3 { font-size: 1rem; font-weight: 700; }
.card-subtitle { color: var(--text-muted); font-size: .8rem; }
.card-body { padding: 1.25rem; }

/* ───────── Grid ───────── */
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat-card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1.25rem;
    box-shadow: var(--shadow);
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--accent); }
.stat-label { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; }

/* ───────── Forms ───────── */
label { display: block; margin-bottom: .9rem; font-size: .85rem; font-weight: 600; color: var(--text); }
label > span { display: block; margin-bottom: .3rem; }
label.checkbox { display: flex; gap: .5rem; align-items: center; font-weight: 400; }
label.checkbox input { margin: 0; }
label.full { grid-column: 1 / -1; }
label small { display: block; color: var(--text-muted); font-weight: 400; margin-top: .3rem; font-size: .75rem; }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
    width: 100%; padding: .55rem .75rem; font: inherit; color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: #fff; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(8,145,178,.12);
}

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: .5rem; }
.form-row[data-show-for]:not(.visible) { display: none; }
.form-actions { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; }

.key-input { display: flex; gap: .4rem; align-items: stretch; }
.key-input input { flex: 1; }

.test-result { font-size: .85rem; }
.test-result.ok  { color: var(--success); }
.test-result.err { color: var(--danger); }

/* ───────── Alerts & flashes ───────── */
.alert {
    padding: .8rem 1rem; margin-bottom: 1rem;
    border-radius: var(--radius-sm); border-left: 4px solid;
    font-size: .88rem;
}
.alert-error { background: #fef2f2; border-color: var(--danger); color: #991b1b; }
.alert-ok    { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-info  { background: #ecfeff; border-color: var(--accent); color: #155e75; }

.flash { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 500; }
.flash-success { background: #f0fdf4; color: #166534; border-left: 4px solid var(--success); }
.flash-error   { background: #fef2f2; color: #991b1b; border-left: 4px solid var(--danger); }
.flash-floating { position: fixed; top: 1rem; right: 1rem; max-width: 360px; z-index: 99; box-shadow: var(--shadow-lg); }

/* ───────── Tables ───────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { text-align: left; padding: .7rem .5rem; border-bottom: 1px solid var(--border); font-size: .875rem; }
.data-table th { color: var(--text-muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; }
.text-muted { color: var(--text-muted); }

.badge {
    display: inline-block; padding: .2rem .55rem; border-radius: 999px;
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge-draft      { background: #f1f5f9; color: #475569; }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-completed, .badge-published { background: #d1fae5; color: #065f46; }
.badge-error      { background: #fee2e2; color: #991b1b; }
.badge-pending    { background: #e2e8f0; color: #475569; }
.badge-generating { background: #fed7aa; color: #9a3412; }

.fit-badge { font-size: .7rem; font-weight: 700; padding: .15rem .5rem; border-radius: 4px; }
.fit-ok        { background: #d1fae5; color: #065f46; }
.fit-overflow  { background: #fee2e2; color: #991b1b; }
.fit-underfull { background: #fef3c7; color: #92400e; }
.fit-unknown   { background: #e2e8f0; color: #475569; }

/* ───────── Empty / errors ───────── */
.empty-state {
    background: var(--bg-card); border: 2px dashed var(--border);
    border-radius: var(--radius); padding: 3rem 1.5rem;
    text-align: center;
}
.empty-icon { font-size: 3.5rem; margin-bottom: .75rem; }
.empty-state h3 { margin-bottom: .5rem; }
.empty-state p { color: var(--text-muted); }

.error-wrap { max-width: 480px; margin: 4rem auto; text-align: center; padding: 2rem; }
.error-code { font-size: 5rem; font-weight: 900; color: var(--accent); line-height: 1; }
.error-wrap h1 { margin: .5rem 0 .75rem; }
.error-wrap p { color: var(--text-muted); margin-bottom: 1.5rem; }

/* ───────── Auth pages ───────── */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #0891b2 100%);
    padding: 2rem 1rem;
}
.auth-card {
    background: #fff; border-radius: var(--radius);
    padding: 2.5rem; max-width: 420px; width: 100%;
    box-shadow: var(--shadow-lg);
}
.auth-brand { text-align: center; margin-bottom: 1.75rem; }
.auth-brand .brand-icon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.auth-brand h1 { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.auth-brand p { color: var(--text-muted); margin-top: .25rem; }
.auth-form label { margin-bottom: 1rem; }
.auth-footer { text-align: center; margin-top: 1.25rem; color: var(--text-muted); font-size: .85rem; }

/* ───────── Landing ───────── */
.landing { min-height: 100vh; background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%); color: #e2e8f0; }
.landing-header { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 3rem; }
.landing-header .brand { display: flex; align-items: center; gap: .5rem; font-size: 1.2rem; font-weight: 800; color: #fff; }
.landing-nav { display: flex; gap: .75rem; }
.landing-nav .btn-ghost { color: #e2e8f0; border-color: #334155; }
.landing-nav .btn-ghost:hover { background: #1e293b; color: #fff; }

.hero { text-align: center; padding: 5rem 2rem 3rem; max-width: 820px; margin: 0 auto; }
.hero h1 { font-size: 2.5rem; font-weight: 900; color: #fff; line-height: 1.15; margin-bottom: 1rem; }
.hero-sub { color: #94a3b8; font-size: 1.1rem; line-height: 1.6; margin-bottom: 2rem; }
.hero-cta { display: flex; justify-content: center; gap: .75rem; flex-wrap: wrap; }
.hero-cta .btn-ghost { color: #e2e8f0; border-color: #334155; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; padding: 3rem 3rem 5rem; max-width: 1100px; margin: 0 auto; }
.feature { background: rgba(30, 41, 59, .7); border: 1px solid #334155; border-radius: var(--radius); padding: 1.75rem; }
.feature-icon { font-size: 2rem; margin-bottom: .5rem; }
.feature h3 { color: #fff; margin-bottom: .5rem; }
.feature p { color: #94a3b8; line-height: 1.55; }

.landing-footer { text-align: center; padding: 2rem; color: #64748b; font-size: .85rem; border-top: 1px solid #1e293b; }
.landing-footer a { color: #94a3b8; }
.landing-footer a:hover { color: #fff; }

/* ───────── Info list ───────── */
.info-list { display: grid; grid-template-columns: 140px 1fr; gap: .5rem .75rem; }
.info-list dt { font-weight: 600; color: var(--text-muted); }

#image-test-thumb img {
    margin-top: 1rem; max-width: 128px; border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

/* ───────── Live progress card (editor) ───────── */
.progress-card {
    background: linear-gradient(135deg, #ecfeff 0%, #f0fdf4 100%);
    border: 1px solid #a5f3fc;
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
}
.progress-card[hidden] { display: none; }
.progress-row {
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: .85rem;
}
.progress-icon {
    font-size: 1.6rem; flex-shrink: 0;
}
.progress-text { flex: 1; min-width: 0; }
.progress-step {
    font-weight: 700; color: var(--text);
    text-transform: capitalize; font-size: .95rem;
}
.progress-detail {
    color: var(--text-muted); font-size: .8rem;
    margin-top: .15rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.progress-counts {
    text-align: right; flex-shrink: 0;
    color: var(--text); font-weight: 700;
}
.progress-count { font-size: 1.5rem; color: var(--accent); }
.progress-sep { color: #94a3b8; margin: 0 .15rem; }
.progress-total { font-size: 1.25rem; color: var(--text-muted); }
.progress-label { display: block; font-size: .7rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }

.progress-bar-track {
    width: 100%; height: 8px;
    background: rgba(8,145,178,.15); border-radius: 999px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-bright));
    border-radius: 999px;
    transition: width .5s ease;
    background-size: 200% 100%;
    animation: shimmer 2.2s linear infinite;
}
@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.progress-meta {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: .55rem; font-size: .75rem; color: var(--text-muted);
}
.progress-stalled-warn {
    color: #b45309; font-weight: 600;
}

/* Dashboard mini progress bar */
.mini-progress {
    width: 90px; height: 4px; margin-top: .35rem;
    background: rgba(8,145,178,.18); border-radius: 999px; overflow: hidden;
}
.mini-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--accent-bright));
    background-size: 200% 100%;
    animation: shimmer 2.2s linear infinite;
    transition: width .5s ease;
}

/* Spinning gear */
.spin {
    display: inline-block;
    animation: spin 2.4s linear infinite;
    transform-origin: center center;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ───────── Responsive ───────── */
@media (max-width: 900px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; padding: .75rem 1rem; align-items: center; gap: .5rem; }
    .sidebar-brand { border: none; padding: 0; }
    .sidebar-nav { flex-direction: row; align-items: center; flex: 1; overflow-x: auto; gap: .25rem; }
    .nav-section-title { display: none; }
    .sidebar-footer { border: none; padding: 0; }
    .user-meta { display: none; }
    .main { padding: 1.25rem; }
    .landing-header { padding: 1rem 1.25rem; }
    .features { padding: 2rem 1.25rem 4rem; }
    .hero { padding: 3rem 1.25rem 2rem; }
    .hero h1 { font-size: 1.9rem; }
}
