/* ==========================================================================
   Xtream Hesap Paneli — arayüz
   ========================================================================== */

:root {
    --bg:        #0e1116;
    --bg-soft:   #151a22;
    --card:      #1a212b;
    --card-2:    #212a36;
    --line:      #2a3542;
    --text:      #e6edf5;
    --muted:     #8b9aad;
    --primary:   #3b82f6;
    --primary-d: #2563eb;
    --accent:    #f59e0b;
    --accent-d:  #d97706;
    --ok:        #22c55e;
    --bad:       #ef4444;
    --trial:     #a855f7;
    --radius:    12px;
    --shadow:    0 6px 24px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.right { text-align: right; }

/* ---------- üst bar ---------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 58px;
    padding: 0 16px;
    background: var(--bg-soft);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 16px;
    letter-spacing: .2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.brand b { font-weight: 700; }
.brand-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--trial));
    box-shadow: 0 0 12px rgba(59, 130, 246, .8);
    flex: none;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.credit-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(59, 130, 246, .15);
    border: 1px solid rgba(59, 130, 246, .35);
    color: #93c5fd;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}
.credit-badge b { color: #fff; }
.who {
    color: var(--muted);
    font-size: 13px;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.burger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px; height: 40px;
    padding: 0 9px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 9px;
    cursor: pointer;
}
.burger span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: .2s;
}

/* ---------- yerleşim ---------- */

.shell { display: flex; min-height: calc(100vh - 58px); }

.sidebar {
    width: 232px;
    flex: none;
    background: var(--bg-soft);
    border-right: 1px solid var(--line);
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    border-radius: 10px;
    color: var(--muted);
    font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--card); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { width: 19px; height: 19px; flex: none; }

.sidebar-foot { margin-top: auto; padding: 12px 6px 4px; }
.conn {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
    word-break: break-all;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); flex: none; }
.conn.ok .dot { background: var(--ok); }

.backdrop {
    display: none;
    position: fixed;
    inset: 58px 0 0 0;
    background: rgba(0, 0, 0, .55);
    z-index: 25;
}
body.nav-open .backdrop { display: block; }

.content {
    flex: 1;
    min-width: 0;
    padding: 22px 22px 60px;
}

.page-title {
    margin: 0 0 18px;
    font-size: 23px;
    font-weight: 650;
}

/* ---------- kartlar ---------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: var(--shadow);
}

.card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.card-head.bordered {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}
.card-head h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 650;
}
.card-head .link, .card-head .head-actions { margin-left: auto; }
.head-actions { display: flex; gap: 8px; }

.count {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 8px;
    background: var(--card-2);
    border-radius: 20px;
    font-size: 12px;
    color: var(--muted);
}

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

/* ---------- istatistik ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}
.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-left: 3px solid var(--muted);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat.ok    { border-left-color: var(--ok); }
.stat.warn  { border-left-color: var(--accent); }
.stat.bad   { border-left-color: var(--bad); }
.stat.trial { border-left-color: var(--trial); }
.stat.live  { border-left-color: var(--primary); }

.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

/* ---------- form ---------- */

.form-grid, .filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.field-wide { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; color: var(--muted); }
.field .req { color: var(--bad); }

.field input[type=text],
.field input[type=password],
.field input[type=number],
.field input[type=search],
.field select {
    width: 100%;
    padding: 11px 12px;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 9px;
    font-size: 15px;      /* iOS zoom engeli */
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}
.field select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b9aad' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 17px;
    padding-right: 34px;
}
.field input:focus, .field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .18);
}
.field input::placeholder { color: #5d6b7d; }

.field-check {
    flex-direction: row;
    align-items: center;
    gap: 9px;
}
.field-check input { width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.field-check span { font-size: 14px; color: var(--text); }

.field-inline { max-width: 230px; margin-top: 12px; }

.help { font-size: 12px; color: var(--muted); line-height: 1.45; }

/* sayı + birim ikilisi (paket süreleri) */
.dual { display: flex; gap: 8px; }
.dual input { flex: 1 1 40%; min-width: 0; }
.dual select { flex: 1 1 60%; min-width: 0; }

.chip small { color: var(--muted); font-size: 11px; }

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
}

.filter-card { padding-bottom: 18px; }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }

/* ---------- düğmeler ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--card-2);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: filter .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.12); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-accent { background: var(--accent); color: #221a05; }
.btn-accent:hover { background: var(--accent-d); }
.btn-danger { background: transparent; border-color: var(--bad); color: #ff8a8a; }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: var(--card-2); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; margin-top: 6px; padding: 12px; }

.mini-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
}
.mini-toggle input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ---------- bouquet çipleri ---------- */

.chip-list { display: flex; flex-wrap: wrap; gap: 9px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 13px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 30px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: .15s;
}
.chip input { width: 15px; height: 15px; accent-color: var(--primary); margin: 0; }
.chip:has(input:checked) { border-color: var(--primary); background: rgba(59, 130, 246, .14); }
.chip.checked { border-color: var(--primary); background: rgba(59, 130, 246, .14); }

/* ---------- test süresi seçimi ---------- */

.hour-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 10px;
}
.hour-opt input { position: absolute; opacity: 0; pointer-events: none; }
.hour-opt span {
    display: block;
    padding: 14px 8px;
    text-align: center;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: .15s;
}
.hour-opt input:checked + span {
    background: rgba(245, 158, 11, .16);
    border-color: var(--accent);
    color: #ffd08a;
}

/* ---------- tablo ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.table th, .table td {
    padding: 11px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}
.table tbody tr:hover { background: rgba(255, 255, 255, .025); }
.table td .sub {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin-top: 2px;
}
.table td .sub.note { color: #7d8ea3; font-style: italic; }
.actions { white-space: nowrap; display: flex; gap: 6px; justify-content: flex-end; }
.inline { display: inline; margin: 0; }

.live-dot {
    display: inline-block;
    width: 8px; height: 8px;
    margin-left: 5px;
    border-radius: 50%;
    background: var(--ok);
    box-shadow: 0 0 8px var(--ok);
    animation: pulse 1.6s infinite;
}
@keyframes pulse { 50% { opacity: .35; } }

/* ---------- rozetler ---------- */

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .4px;
    white-space: nowrap;
}
.badge-normal { background: rgba(59, 130, 246, .16); color: #93c0ff; }
.badge-trial  { background: rgba(168, 85, 247, .16); color: #dcb0ff; }
.badge-ok     { background: rgba(34, 197, 94, .15);  color: #86efac; }
.badge-bad    { background: rgba(239, 68, 68, .15);  color: #fca5a5; }
.badge-off    { background: rgba(139, 154, 173, .16); color: #b9c6d6; }

/* ---------- sonuç kartı ---------- */

.result-card { border-color: rgba(34, 197, 94, .4); }

.copy-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}
.btn-copy-main {
    font-size: 14px;
    padding: 10px 18px;
    box-shadow: 0 4px 14px rgba(59, 130, 246, .35);
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
}
.kv {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 13px;
    min-width: 0;
    transition: border-color .15s, background .15s;
}
.copyable-box {
    cursor: pointer;
    border-color: rgba(59, 130, 246, .35);
}
.copyable-box:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, .08);
}
.kv-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.copy-icon {
    font-size: 13px;
    opacity: .6;
}
.copyable-box:hover .copy-icon {
    opacity: 1;
}

.link-row { margin-top: 12px; }
.link-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}
.link-row code {
    display: block;
    margin-top: 5px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 9px;
    overflow-x: auto;
    white-space: nowrap;
}
.link-row code.break { white-space: normal; word-break: break-all; }

.copyable { cursor: pointer; }
.copyable:hover { color: #cfe3ff; }

.copy-inline {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 5px;
    transition: background .15s;
}
.copy-inline:hover {
    background: rgba(59, 130, 246, .2);
    color: #93c5fd;
}
.copy-badge {
    font-size: 11px;
    opacity: .5;
}
.copy-inline:hover .copy-badge {
    opacity: 1;
}

.copied-active {
    outline: 2px dashed #22c55e !important;
    background: rgba(34, 197, 94, .25) !important;
    color: #fff !important;
    transition: all .15s ease;
}

/* ---------- uyarılar ---------- */

.alert {
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: 14px;
    border: 1px solid transparent;
    line-height: 1.5;
}
.alert-success { background: rgba(34, 197, 94, .12); border-color: rgba(34, 197, 94, .35); color: #a7f3c0; }
.alert-error   { background: rgba(239, 68, 68, .12); border-color: rgba(239, 68, 68, .35); color: #fecaca; }
.alert-warn    { background: rgba(245, 158, 11, .12); border-color: rgba(245, 158, 11, .35); color: #fde3b0; }
.alert-info    { background: rgba(59, 130, 246, .12); border-color: rgba(59, 130, 246, .35); color: #bfdbfe; }

.hint { font-size: 12.5px; color: var(--muted); margin: 12px 0 0; }

.checklist { color: var(--muted); font-size: 14px; line-height: 1.8; padding-left: 20px; }

/* ---------- sayfalama ---------- */

.pager { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; justify-content: center; }
.pg {
    min-width: 36px;
    padding: 8px 10px;
    text-align: center;
    background: var(--card-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
}
.pg:hover { background: var(--line); text-decoration: none; }
.pg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg.dots { background: transparent; border: none; color: var(--muted); }

/* ---------- giriş ekranı ---------- */

.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(59, 130, 246, .22), transparent 60%),
        radial-gradient(800px 500px at 110% 110%, rgba(168, 85, 247, .18), transparent 60%),
        var(--bg);
}
.login-wrap { width: 100%; max-width: 400px; }
.login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 30px 26px;
    box-shadow: var(--shadow);
}
.login-logo { font-size: 40px; text-align: center; }
.login-card h1 { margin: 10px 0 4px; font-size: 20px; text-align: center; }
.login-card .muted { text-align: center; margin: 0 0 20px; font-size: 13px; }
.login-card .field { margin-bottom: 14px; }
.login-card .hint { text-align: center; }

/* ---------- bildirim ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translate(-50%, 20px);
    padding: 11px 18px;
    background: #10b981;
    color: #04231a;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 90;
    max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Mobil
   ========================================================================== */

@media (max-width: 900px) {

    .burger { display: flex; }

    .sidebar {
        position: fixed;
        top: 58px;
        left: 0;
        bottom: 0;
        width: 240px;
        z-index: 30;
        transform: translateX(-100%);
        transition: transform .22s ease;
    }
    body.nav-open .sidebar { transform: translateX(0); }

    .content { padding: 16px 14px 60px; }
    .page-title { font-size: 20px; }
    .card { padding: 15px; }

    /* tabloları kart görünümüne çevir */
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr {
        background: var(--bg);
        border: 1px solid var(--line);
        border-radius: 10px;
        padding: 6px 4px;
        margin-bottom: 10px;
    }
    .table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 14px;
        border: none;
        padding: 7px 10px;
        text-align: right;
    }
    .table td::before {
        content: attr(data-label);
        flex: none;
        font-size: 11px;
        font-weight: 600;
        color: var(--muted);
        text-transform: uppercase;
        letter-spacing: .4px;
        text-align: left;
    }
    .table td .sub { text-align: right; }
    .actions { justify-content: flex-end; }
    .table tbody tr:hover { background: var(--bg); }

    .filter-actions { justify-content: stretch; }
    .filter-actions .btn { flex: 1; }
    .form-actions .btn { flex: 1 1 auto; }
}

@media (max-width: 420px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-value { font-size: 22px; }
    .who { display: none; }
}
