/* Outreach v2 — dashboard (light + dark mode)
   Tón: čisté SaaS (Linear/Vercel) — veľa priestoru, jasná typografia,
   decentné farby, žiadne gradienty a neón. */

* { box-sizing: border-box; }

:root {
    --bg: #f7f8fa;
    --surface: #ffffff;
    --surface-hover: #f9fafb;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --danger: #dc2626;
    --shadow: 0 1px 2px rgba(17, 24, 39, .05);
}

[data-theme="dark"] {
    --bg: #0f1115;
    --surface: #16181d;
    --surface-hover: #1b1e24;
    --border: #26292f;
    --text: #e6e8ea;
    --text-muted: #9aa0a6;
    --accent: #3b82f6;
    --accent-hover: #60a5fa;
    --danger: #f08c8c;
    --shadow: none;
}

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* --- tlačidlá --- */

.btn {
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-outline { border-color: var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--surface-hover); }

.btn-ghost { border-color: transparent; color: var(--text-muted); box-shadow: none; }
.btn-ghost:hover { color: var(--text); }

.btn-danger { border-color: var(--border); color: var(--danger); }

.btn-block { width: 100%; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
}
.icon-btn:hover { color: var(--text); background: var(--surface-hover); }

/* svetlá téma: ponúkne prepnutie do dark (mesiac) */
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* --- login --- */

.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.login-card {
    width: 100%;
    max-width: 360px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.login-title { margin: 0; font-size: 24px; font-weight: 700; }
.login-sub { margin: 2px 0 24px; color: var(--text-muted); }
.login-card .btn { margin-top: 8px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 4px; color: var(--text-muted); font-size: 13px; }
.field input, .field select, .field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}
.field input:focus, .field textarea:focus, .field select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
    border-color: transparent;
}

.error-text { color: var(--danger); margin: 10px 0 0; font-size: 13px; }

/* --- topbar + navigácia --- */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 24px; }
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-sub { color: var(--text-muted); font-weight: 500; margin-left: 6px; }

.topnav { display: flex; gap: 4px; }
.topnav button {
    border: none;
    background: none;
    font: inherit;
    font-weight: 500;
    color: var(--text-muted);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
}
.topnav button:hover { color: var(--text); background: var(--surface-hover); }
.topnav button.active { color: var(--text); background: var(--surface-hover); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.current-user { color: var(--text-muted); }

/* --- obsah --- */

.container { max-width: 1080px; margin: 24px auto; padding: 0 16px; }

.add-form {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.add-form textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    resize: vertical;
    background: var(--surface);
    color: var(--text);
}
.add-form textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.add-form select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
    max-width: 200px;
}
.add-form select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.add-form textarea:disabled, .add-form select:disabled { opacity: .55; cursor: not-allowed; }

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow-x: auto;
    box-shadow: var(--shadow);
}
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table th, .leads-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.leads-table th {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.leads-table tbody tr { cursor: pointer; }
.leads-table tbody tr:hover { background: var(--surface-hover); }
.leads-table tbody tr:last-child td { border-bottom: none; }

.company-cell { font-weight: 600; }
.company-cell small { display: block; font-weight: 400; color: var(--text-muted); }

.empty { padding: 32px; text-align: center; color: var(--text-muted); }

/* --- plnenie z portálov --- */

.portal-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.portal-label { color: var(--text-muted); font-size: 13px; }
.portal-bar select {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 10px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
    max-width: 220px;
}
.portal-status { color: var(--text-muted); font-size: 13px; }

/* --- kampane (chips) --- */

.campaign-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 4px 12px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.chip:hover { color: var(--text); background: var(--surface-hover); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.campaign-actions { display: flex; gap: 8px; }
.campaign-card { max-width: 820px; }
.campaign-card .detail-title { margin-bottom: 16px; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* --- prepínač kampaní (topbar) --- */

.campaign-switch {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    font: inherit;
    font-weight: 600;
    background: var(--surface);
    color: var(--text);
    max-width: 240px;
}
.campaign-switch:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* --- info pás kampane --- */

.campaign-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    box-shadow: var(--shadow);
}
.campaign-info-name { font-weight: 700; font-size: 15px; }
.campaign-info-meta { color: var(--text-muted); font-size: 13px; }
.campaign-info-meta a { color: var(--accent); text-decoration: none; }
.warn-text { color: var(--danger); font-weight: 500; }

/* --- formulár kampane --- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.field-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field-head span { margin-bottom: 4px; }
.prompt-area {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.45;
    resize: vertical;
}
.var-hint { color: var(--text-muted); font-size: 12px; margin: -6px 0 14px; line-height: 1.9; }
.var-hint code {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 4px;
    font-size: 11.5px;
}
.send-from { color: var(--text-muted); }
.row-current td { font-weight: 600; background: var(--surface-hover); }

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
    .campaign-switch { max-width: 140px; }
}

/* --- nastavenia --- */

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.card-title { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.hint { color: var(--text-muted); font-size: 12px; margin: 12px 0 0; }
.settings-grid .leads-table tbody tr { cursor: default; }

/* --- štatistiky --- */

.stats-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.stat-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.stat-num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-label { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

@media (max-width: 900px) {
    .settings-grid { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}

#add-campaign {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
    max-width: 220px;
}

/* --- status badge --- */

.badge {
    display: inline-block;
    border-radius: 999px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
}
.badge-new       { background: #f3f4f6; color: #4b5563; }
.badge-generated { background: #eff6ff; color: #1d4ed8; }
.badge-reviewed  { background: #fef3c7; color: #b45309; }
.badge-sent      { background: #f0fdf4; color: #15803d; }
.badge-replied   { background: #ecfdf5; color: #047857; }
.badge-bounced   { background: #fef2f2; color: #b91c1c; }
.badge-draft     { background: #f3f4f6; color: #4b5563; }
.badge-approved  { background: #eff6ff; color: #1d4ed8; }
.badge-emailsent { background: #f0fdf4; color: #15803d; }

[data-theme="dark"] .badge-new       { background: #1f2227; color: #9aa0a6; }
[data-theme="dark"] .badge-generated { background: rgba(59,130,246,.14); color: #93b4f8; }
[data-theme="dark"] .badge-reviewed  { background: rgba(245,158,11,.14); color: #e2a93b; }
[data-theme="dark"] .badge-sent      { background: rgba(34,197,94,.14); color: #6fcf97; }
[data-theme="dark"] .badge-replied   { background: rgba(16,185,129,.14); color: #7ad4b0; }
[data-theme="dark"] .badge-bounced   { background: rgba(239,68,68,.14); color: #f08c8c; }
[data-theme="dark"] .badge-draft     { background: #1f2227; color: #9aa0a6; }
[data-theme="dark"] .badge-approved  { background: rgba(59,130,246,.14); color: #93b4f8; }
[data-theme="dark"] .badge-emailsent { background: rgba(34,197,94,.14); color: #6fcf97; }

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    vertical-align: -2px;
    margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- detail leadu (modal) --- */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, .45);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    overflow-y: auto;
    z-index: 10;
}
[data-theme="dark"] .overlay { background: rgba(0, 0, 0, .6); }
.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%;
    max-width: 720px;
    padding: 28px;
    position: relative;
}
.close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
}
.close-btn:hover { color: var(--text); }

.detail-title { margin: 0 0 2px; font-size: 20px; }
.detail-title a { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 400; margin-left: 8px; }
.detail-meta { color: var(--text-muted); margin-bottom: 18px; }

.section { margin-top: 22px; }
.section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0 0 8px;
}
.section-text { margin: 0; white-space: pre-wrap; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 4px 12px; margin: 0; }
.kv dt { color: var(--text-muted); margin: 0; }
.kv dd { margin: 0; }

.contact-form { display: flex; gap: 10px; flex-wrap: wrap; }
.contact-form .field { flex: 1; min-width: 200px; margin-bottom: 0; }

.email-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.email-actions .field { margin: 0; }

.callout-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 16px;
    white-space: pre-wrap;
}
.callout-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
    border-radius: 8px;
    padding: 10px 12px;
    margin-top: 16px;
}
[data-theme="dark"] .callout-error { background: rgba(239,68,68,.08); border-color: rgba(239,68,68,.3); color: #f08c8c; }
[data-theme="dark"] .callout-info  { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.3); color: #93b4f8; }

/* --- toast --- */

.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #111827;
    color: #fff;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
    z-index: 20;
    max-width: 90vw;
}
.toast.visible { opacity: 1; }
.toast.error { background: var(--danger); color: #fff; }
[data-theme="dark"] .toast:not(.error) { background: #e6e8ea; color: #111827; }

@media (max-width: 640px) {
    .add-form { flex-direction: column; }
    .kv { grid-template-columns: 1fr; }
    .topbar { padding: 0 12px; }
    .topbar-left { gap: 12px; }
    .brand-sub { display: none; }
    .leads-table th:nth-child(4), .leads-table td:nth-child(4),
    .leads-table th:nth-child(6), .leads-table td:nth-child(6) { display: none; }
}
