/* ==========================================================================
   Adetsis Fatura Ödeme
   ========================================================================== */

:root {
    --bg: #f3f5fa;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;

    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-soft: #eff4ff;
    --brand-dark: #1e3a8a;

    --success: #15803d;
    --success-soft: #ecfdf3;
    --danger: #b91c1c;
    --danger-soft: #fef2f2;
    --warning: #a16207;
    --warning-soft: #fefce8;

    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 10px 30px -12px rgba(15, 23, 42, .12);
    --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
p { margin: 0; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.container.narrow { max-width: 620px; }

.page { flex: 1; padding: 28px 0 48px; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .95em; }
.text-danger { color: var(--danger) !important; }

/* ---------- Topbar ---------- */
.topbar {
    background: linear-gradient(135deg, var(--brand-dark), var(--primary));
    color: #fff;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; letter-spacing: -.01em; }
.brand-logo-wrap { display: inline-flex; align-items: center; height: 40px; padding: 4px 8px; border-radius: 9px; background: #fff; }
.brand-logo { height: 32px; max-width: 140px; width: auto; display: block; object-fit: contain; }
.brand-mark {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    border-radius: 9px;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .28);
    font-size: 17px;
}
.secure-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .12);
    font-size: 13px; font-weight: 500;
}

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; padding-top: 18px; padding-bottom: 18px; }
.footer strong { color: var(--text-2); font-weight: 600; }
.footer .sep { margin: 0 6px; }
.footer-contact { display: flex; gap: 16px; flex-wrap: wrap; }
.footer-contact a { color: var(--muted); text-decoration: none; }
.footer-contact a:hover { color: var(--primary); }

/* ---------- Steps ---------- */
.steps {
    list-style: none; margin: 0 auto 24px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    max-width: 560px;
}
.step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 500; flex: 1; }
.step:last-child { flex: 0 0 auto; }
.step:not(:last-child)::after {
    content: ""; flex: 1; height: 2px; margin: 0 12px;
    background: var(--border-strong); border-radius: 2px;
}
.step.done:not(:last-child)::after { background: var(--primary); }
.step-dot {
    display: grid; place-items: center; flex: none;
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: var(--surface);
    font-size: 13px; font-weight: 700;
}
.step.active { color: var(--text); }
.step.active .step-dot { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 0 0 4px var(--primary-soft); }
.step.done { color: var(--text-2); }
.step.done .step-dot { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------- Card / Alerts / Badges ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 16px; margin-bottom: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 14px;
}
.alert svg { flex: none; margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: #bbf7d0; color: var(--success); }
.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.alert-muted { background: var(--surface-2); border-color: var(--border); color: var(--muted); }

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 42px; padding: 10px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font: inherit; font-weight: 600; font-size: 15px;
    text-decoration: none; cursor: pointer;
    transition: background-color .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 4px rgba(29, 78, 216, .25); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px -6px rgba(29, 78, 216, .55); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: .75; cursor: progress; }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--muted); }
.btn-lg { min-height: 50px; font-size: 16px; }
.btn-xl { min-height: 58px; font-size: 18px; border-radius: 12px; }
.btn-block { display: flex; width: 100%; }

.spinner {
    display: none;
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255, 255, 255, .4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.btn.is-loading .spinner { display: inline-block; }
.btn.is-loading svg { display: none; }
.spinner-lg { display: inline-block; width: 36px; height: 36px; border-width: 3.5px; border-color: rgba(29, 78, 216, .2); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Preview layout ---------- */
.preview-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 24px;
    align-items: start;
}

.sheet { padding: 36px 40px; }

.sheet-head {
    display: flex; justify-content: space-between; gap: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.seller { font-size: 13px; color: var(--muted); line-height: 1.6; max-width: 55%; }
.seller-name { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }

.doc-meta { text-align: right; }
.doc-title-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 12px; }
.doc-title { font-size: 26px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--brand-dark); }
.meta-list { margin: 0; display: grid; gap: 4px; font-size: 14px; }
.meta-list div { display: flex; justify-content: flex-end; gap: 12px; }
.meta-list dt { color: var(--muted); }
.meta-list dd { margin: 0; font-weight: 600; min-width: 110px; }

.bill-to {
    margin: 24px 0;
    padding: 16px 18px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.customer-name { font-size: 17px; font-weight: 700; }
.customer-details { margin-top: 4px; font-size: 13.5px; color: var(--muted); line-height: 1.6; }

/* Kalem tablosu */
.lines { width: 100%; border-collapse: collapse; font-size: 14px; }
.lines th {
    text-align: left; font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
    padding: 10px 12px; border-bottom: 1.5px solid var(--border-strong);
    white-space: nowrap;
}
.lines td { padding: 14px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.lines .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lines .col-no { width: 36px; color: var(--muted); }
.lines .col-desc { font-weight: 500; }
.lines .col-total { font-weight: 600; }
.lines tbody tr:hover { background: var(--surface-2); }

.sheet-bottom {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
    gap: 24px; margin-top: 20px;
}
.notes p { font-size: 13.5px; color: var(--text-2); white-space: pre-line; }

.totals { margin: 0; font-size: 14px; font-variant-numeric: tabular-nums; }
.totals div { display: flex; justify-content: space-between; gap: 16px; padding: 7px 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 600; }
.totals .grand { border-top: 1.5px solid var(--border-strong); margin-top: 6px; padding-top: 12px; font-size: 17px; }
.totals .grand dt { color: var(--text); font-weight: 700; }
.totals .grand dd { font-weight: 800; }
.totals .payable {
    margin-top: 8px; padding: 10px 12px;
    background: var(--primary-soft); border-radius: 8px;
    color: var(--primary);
}
.totals .payable dt { color: var(--primary); font-weight: 600; }

/* Sağ kolon */
.side { position: sticky; top: 20px; display: grid; gap: 16px; }
.pay-card { padding: 24px; display: grid; gap: 12px; }
.pay-card-label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.pay-card-amount { font-size: 32px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.pay-card-due { font-size: 13.5px; color: var(--muted); margin-bottom: 6px; }
.paid-stamp {
    justify-self: start;
    padding: 6px 14px;
    border: 2.5px solid var(--success);
    border-radius: 8px;
    color: var(--success);
    font-weight: 800; letter-spacing: .15em;
    transform: rotate(-4deg);
    margin: 4px 0 8px;
}

.trust { padding: 16px 18px; display: flex; gap: 12px; align-items: flex-start; font-size: 13px; color: var(--muted); }
.trust svg { flex: none; color: var(--success); }
.trust strong { color: var(--text-2); }

/* Havale / EFT */
.bank-card { padding: 20px; display: grid; gap: 12px; }
.container.narrow > .bank-card { margin-top: 18px; }
.bank-card-head { display: flex; align-items: center; gap: 8px; color: var(--brand-dark); }
.bank-card-head h2 { font-size: 16px; font-weight: 700; color: var(--text); }
.bank-card-note { font-size: 13.5px; color: var(--text-2); }
.bank-account { margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); display: grid; gap: 8px; }
.bank-account div { display: grid; gap: 1px; }
.bank-account dt { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.bank-account dd { margin: 0; font-size: 14.5px; font-weight: 600; overflow-wrap: anywhere; }
.bank-iban { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.bank-iban .mono { font-size: 14px; letter-spacing: .02em; }
.copy-btn { flex: none; padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--primary); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.copy-btn:hover { border-color: var(--primary); }
.bank-card-foot { font-size: 12.5px; color: var(--muted); }

/* Mobil sabit ödeme çubuğu */
.mobile-paybar { display: none; }

/* ---------- Pay page ---------- */
.pay-summary { padding: 28px; }
.pay-summary-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.h1 { font-size: 22px; font-weight: 700; }
.link-muted { font-size: 14px; color: var(--muted); }
.link-muted:hover { color: var(--primary); }

.kv { margin: 0; display: grid; }
.kv div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 14.5px; }
.kv div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); flex: none; }
.kv dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.kv-compact { margin: 20px auto 0; max-width: 380px; text-align: left; }

.amount-box {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin: 18px 0 20px; padding: 18px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary-soft), #f5f8ff);
    border: 1px solid #dbe5ff;
}
.amount-box span { font-weight: 600; color: var(--text-2); }
.amount-box strong { font-size: 30px; font-weight: 800; color: var(--brand-dark); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.check {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 14px 16px; margin-bottom: 16px;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; font-size: 14px; color: var(--text-2);
    transition: border-color .15s, background-color .15s;
}
.check:hover { border-color: var(--border-strong); }
.check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.check input { width: 18px; height: 18px; margin: 1px 0 0; flex: none; accent-color: var(--primary); }

.email-field { display: grid; gap: 6px; margin-bottom: 14px; }
.email-field label { font-weight: 600; font-size: 14px; color: var(--text-2); }
.email-field input {
    min-height: 48px; padding: 10px 14px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
}
.email-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, .15); }
.email-field small { color: var(--muted); font-size: 12.5px; }

.form-error { margin: -6px 0 14px; color: var(--danger); font-size: 14px; }

/* PayTR kart formu (iframe yüksekliği iframeResizer ile ayarlanır) */
.paytr-card { margin-top: 18px; padding: 0; overflow: hidden; }
.paytr-frame { display: block; width: 100%; min-height: 560px; border: 0; }

.redirect-note { margin-top: 14px; font-size: 13px; color: var(--muted); text-align: center; }

.secure-strip {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 20px;
    margin-top: 18px; color: var(--muted); font-size: 13px; font-weight: 500;
}
.secure-strip-item { display: inline-flex; align-items: center; gap: 6px; }
.card-brands { display: inline-flex; gap: 6px; }
.card-brand {
    padding: 3px 8px; border: 1px solid var(--border-strong); border-radius: 6px;
    background: var(--surface); font-size: 11px; font-weight: 800; letter-spacing: .04em; color: var(--text-2);
}

.back-link {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-top: 22px; font-size: 14px; color: var(--muted); text-decoration: none;
}
.back-link:hover { color: var(--primary); }

/* ---------- Result ---------- */
.result-card { padding: 40px 28px; text-align: center; }
.result-icon {
    display: grid; place-items: center;
    width: 76px; height: 76px; margin: 0 auto 18px; border-radius: 50%;
}
.result-icon-success { background: var(--success-soft); color: var(--success); box-shadow: 0 0 0 8px rgba(21, 128, 61, .06); }
.result-icon-danger { background: var(--danger-soft); color: var(--danger); box-shadow: 0 0 0 8px rgba(185, 28, 28, .06); }
.result-icon-primary { background: var(--primary-soft); color: var(--primary); }
.result-icon-muted { background: var(--surface-2); color: var(--muted); }
.result-title { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.result-card > .muted { max-width: 440px; margin: 0 auto 20px; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .preview-layout { grid-template-columns: minmax(0, 1fr); }
    .side { position: static; }
    .has-paybar .page { padding-bottom: 110px; }

    .mobile-paybar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
        display: flex; align-items: center; justify-content: space-between; gap: 12px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, .96);
        backdrop-filter: blur(8px);
        border-top: 1px solid var(--border);
        box-shadow: 0 -8px 24px -12px rgba(15, 23, 42, .18);
    }
    .mobile-paybar-amount { display: grid; line-height: 1.2; }
    .mobile-paybar-amount small { font-size: 12px; color: var(--muted); }
    .mobile-paybar-amount strong { font-size: 19px; font-variant-numeric: tabular-nums; }
}

@media (max-width: 640px) {
    body { font-size: 14.5px; }
    .page { padding-top: 20px; }
    .topbar-inner { height: 56px; }
    .secure-pill span { display: none; }
    .secure-pill { padding: 8px; }

    .step-label { display: none; }
    .step.active .step-label { display: inline; white-space: nowrap; }
    .step:not(:last-child)::after { margin: 0 8px; }

    .sheet { padding: 20px 16px; }
    .sheet-head { flex-direction: column; gap: 18px; }
    .seller { max-width: none; order: 2; }
    .doc-meta { text-align: left; order: 1; }
    .doc-title-row { justify-content: space-between; }
    .meta-list div { justify-content: space-between; }
    .meta-list dd { min-width: 0; text-align: right; }

    /* Tablo → kart görünümü */
    .lines thead { display: none; }
    .lines, .lines tbody, .lines tr, .lines td { display: block; }
    .lines tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
    .lines td { padding: 2px 0; border: 0; }
    .lines .col-no { display: none; }
    .lines .col-desc { font-size: 15px; margin-bottom: 6px; }
    .lines td.num { display: flex; justify-content: space-between; text-align: right; }
    .lines td[data-label]::before { content: attr(data-label); color: var(--muted); font-weight: 400; }
    .lines tbody tr:hover { background: none; }

    .sheet-bottom { grid-template-columns: minmax(0, 1fr); }
    .totals { order: -1; }

    .pay-summary { padding: 20px 16px; }
    .amount-box { flex-direction: column; align-items: flex-start; gap: 2px; }
    .amount-box strong { font-size: 28px; }
    .btn-xl { font-size: 16px; }
    .result-card { padding: 32px 16px; }
}

/* ---------- Print ---------- */
@media print {
    body { background: #fff; font-size: 12px; }
    .topbar, .footer, .steps, .side, .mobile-paybar, .alert { display: none !important; }
    .page { padding: 0; }
    .container { max-width: none; padding: 0; }
    .preview-layout { display: block; }
    .card { box-shadow: none; border: 0; }
    .sheet { padding: 0; }
    .lines tbody tr:hover { background: none; }
    .badge { border: 1px solid currentColor; }
}
