/* opisy.biostima.info - app.css
 * Minimalistyczny, funkcjonalny UI. Bez Bootstrapa.
 */

:root {
    --c-bg: #f5f7f9;
    --c-surface: #ffffff;
    --c-text: #1a1e24;
    --c-muted: #6b7280;
    --c-border: #e2e6eb;
    --c-accent: #0d7a3c;
    --c-accent-dark: #096130;
    --c-danger: #c53030;
    --c-warn: #b7791f;
    --c-info: #1d4ed8;
    --radius: 6px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--c-bg);
    color: var(--c-text);
    line-height: 1.5;
    font-size: 15px;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* Topbar */
.topbar {
    background: var(--c-surface);
    border-bottom: 1px solid var(--c-border);
    padding: 0.9rem 0;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar .container {
    display: flex;
    align-items: center;
    gap: 2rem;
}
.brand {
    font-weight: 700;
    color: var(--c-text);
    text-decoration: none;
    font-size: 1.1rem;
}
.brand-dot { color: var(--c-accent); }
.nav {
    display: flex;
    gap: 1.25rem;
    margin-left: auto;
}
.nav a {
    color: var(--c-muted);
    text-decoration: none;
    padding: 0.4rem 0.2rem;
    border-bottom: 2px solid transparent;
    font-size: 0.95rem;
}
.nav a.active,
.nav a:hover {
    color: var(--c-text);
    border-bottom-color: var(--c-accent);
}

/* Main */
.main {
    padding: 2rem 0 4rem;
    min-height: calc(100vh - 120px);
}
.footer {
    border-top: 1px solid var(--c-border);
    padding: 1rem 0;
    color: var(--c-muted);
    background: var(--c-surface);
}

/* Typo */
h1 { font-size: 1.6rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.25rem; margin: 0 0 0.5rem; }
.lead { color: var(--c-muted); margin: 0 0 1.5rem; max-width: 720px; }
.muted { color: var(--c-muted); }

/* Submit box (glowna strona) */
.submit-box {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}
.lists {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}
@media (max-width: 900px) {
    .lists { grid-template-columns: 1fr; }
}
.list-block {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.list-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.list-head h2 { margin: 0; font-size: 1.05rem; }
.small { font-size: 0.8rem; }

.simple-list { display: flex; flex-direction: column; gap: 0.6rem; }
.list-item {
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
    background: #fafbfc;
}
.list-item header {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}
.list-item footer {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.list-item .sku {
    background: #eef2f7;
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 0.85rem;
}
.list-item .preview {
    margin: 0;
    font-size: 0.82rem;
    color: var(--c-muted);
    line-height: 1.4;
}
.pending-item { border-left: 3px solid #b7791f; }
.generated-item { border-left: 3px solid var(--c-accent); }

/* Generator (deprecated) */
.generator {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
}

/* Widok pojedynczego opisu (opis.php) */
.opis-view {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.75rem;
    box-shadow: var(--shadow);
}
.opis-head h1 { margin: 0 0 0.5rem; }
.opis-meta {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1.25rem;
}
.pending-notice, .fail-notice {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}
.pending-notice { background: #fef3c7; border: 1px solid #fde68a; color: #854d0e; }
.fail-notice { background: #fee2e2; border: 1px solid #fecaca; color: #991b1b; }
.actions-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f9fafb;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
}
.allegro-actions {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.allegro-actions input {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.raw-block {
    margin-top: 1.5rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: #f9fafb;
}
.raw-block summary {
    padding: 0.65rem 1rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
}
.raw-block pre {
    margin: 0;
    padding: 0.75rem 1rem;
    background: #fff;
    font-size: 0.82rem;
    white-space: pre-wrap;
    word-break: break-word;
    border-top: 1px solid var(--c-border);
    max-height: 380px;
    overflow: auto;
}
.gen-form .row { margin-bottom: 1rem; }
.gen-form .lbl {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
    color: var(--c-text);
}
.gen-form input[type="text"],
.gen-form textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    background: #fafbfc;
}
.gen-form input:focus,
.gen-form textarea:focus {
    outline: 2px solid var(--c-accent);
    outline-offset: 0;
    border-color: var(--c-accent);
    background: #fff;
}
.gen-form textarea {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 0.9rem;
    line-height: 1.55;
    resize: vertical;
}
.actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.hint { color: var(--c-muted); font-size: 0.85rem; }

/* Btn */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    border: 1px solid var(--c-border);
    background: #fff;
    color: var(--c-text);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.12s;
    text-decoration: none;
}
.btn:hover {
    background: #f0f2f5;
}
.btn-primary {
    background: var(--c-accent);
    color: #fff;
    border-color: var(--c-accent);
}
.btn-primary:hover {
    background: var(--c-accent-dark);
    border-color: var(--c-accent-dark);
}
.btn-secondary {
    background: #fff;
    color: var(--c-accent);
    border-color: var(--c-accent);
}
.btn-small {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
}
.btn[disabled] {
    opacity: 0.55;
    cursor: not-allowed;
}

/* Gen meta / error */
.gen-meta, .gen-error {
    margin-top: 1rem;
    padding: 0.65rem 0.9rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
}
.gen-meta {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}
.gen-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Previews (2 columns) */
.previews {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 2rem;
}
@media (max-width: 1000px) {
    .previews { grid-template-columns: 1fr; }
}
.col {
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.col-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: #f9fafb;
    border-bottom: 1px solid var(--c-border);
    gap: 0.5rem;
    flex-wrap: wrap;
}
.col-head h2 { margin: 0; font-size: 1rem; }
.col-actions { display: flex; gap: 0.4rem; }
.raw-html {
    border-bottom: 1px solid var(--c-border);
    background: #fcfcfd;
}
.raw-html summary {
    padding: 0.45rem 1rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--c-muted);
}
.raw-html pre {
    margin: 0;
    padding: 0.75rem 1rem;
    background: #f3f4f6;
    font-size: 0.75rem;
    max-height: 220px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}
.preview {
    padding: 1.25rem;
    overflow: auto;
    max-height: 820px;
}
.allegro-preview h1, .allegro-preview h2, .allegro-preview h3,
.shoper-preview h1, .shoper-preview h2, .shoper-preview h3 {
    margin-top: 1.1rem;
    margin-bottom: 0.5rem;
}
.allegro-preview table, .shoper-preview table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
}
.allegro-preview th, .allegro-preview td,
.shoper-preview th, .shoper-preview td {
    border: 1px solid var(--c-border);
    padding: 0.4rem 0.6rem;
    text-align: left;
    font-size: 0.9rem;
}

.result {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: var(--c-info);
    font-size: 0.9rem;
}
.result.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.result.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* History */
.history-toolbar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}
.history-toolbar input {
    flex: 1;
    max-width: 360px;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
}
.history-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
    font-size: 0.88rem;
}
.history-table th {
    background: #f9fafb;
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--c-border);
    font-weight: 600;
}
.history-table td {
    padding: 0.55rem 0.75rem;
    border-top: 1px solid var(--c-border);
    vertical-align: top;
}
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    background: #e5e7eb;
    color: #374151;
}
.badge.generated { background: #dbeafe; color: #1e40af; }
.badge.failed, .badge.sync_failed_shoper, .badge.sync_failed_allegro { background: #fee2e2; color: #991b1b; }
.badge.synced_shoper, .badge.synced_allegro, .badge.synced_both { background: #dcfce7; color: #166534; }
.badge.pending { background: #fef3c7; color: #854d0e; }

/* Dialog (details) */
.desc-dialog {
    width: min(1100px, 92vw);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.desc-dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dd-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin: 1rem 0;
}
.dd-grid pre {
    background: #f3f4f6;
    padding: 0.75rem;
    border-radius: var(--radius);
    max-height: 260px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.78rem;
}
.dd-actions { text-align: right; }
