/* ==========================================================================
   Panel Cloudflare — Design System "SaaS Modern"
   Clean, minimalis, profesional. Tanpa library/font eksternal.
   Struktur: 1 Tokens · 2 Reset/Base · 3 Layout · 4 Komponen · 5 Modal · 6 Responsif
   ========================================================================== */

/* --- 1. Tokens --- */
:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --radius: 10px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
    --shadow-modal: 0 12px 32px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.08);
    --ring: 0 0 0 3px rgba(37, 99, 235, 0.18);
    --hairline: #eef2f7;
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --error-bg: #fee2e2;
    --error-text: #991b1b;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --transition: 130ms ease;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* --- 2. Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

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

h1 {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
}

h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

h3 {
    font-size: 13px;
    font-weight: 600;
    margin: 0;
}

p {
    margin: 0 0 12px;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover {
    color: var(--primary-hover);
}

/* Focus ring global yang konsisten */
input:focus-visible,
select:focus-visible,
button:focus-visible,
.btn:focus-visible {
    outline: none;
    box-shadow: var(--ring);
    border-color: var(--primary);
}

.text-muted {
    color: var(--text-muted);
}

/* --- 3. Layout --- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 1360px;
    margin: 0 auto;
    height: 56px;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 0 16px;
}

.brand {
    font-weight: 700;
    font-size: 15px;
    letter-spacing: -0.01em;
}

.nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.nav a {
    color: var(--text-muted);
    font-weight: 500;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
}

.nav a:hover {
    color: var(--text);
    background: #f1f5f9;
    text-decoration: none;
}

.nav a[aria-current="page"] {
    color: var(--text);
}

.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 28px 16px 56px;
}

.page-head {
    margin-bottom: 20px;
}

.page-sub {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

/* --- 4. Komponen --- */

/* 4.1 Tombol — semua tombol dalam satu baris sama tinggi & sejajar tengah */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background var(--transition), border-color var(--transition),
        color var(--transition), box-shadow var(--transition);
}

.btn:hover {
    background: #f1f5f9;
    text-decoration: none;
    color: var(--text);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.btn:disabled:hover {
    background: var(--surface);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #ffffff;
}

.btn-primary:disabled,
.btn-primary:disabled:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

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

.btn-danger:hover {
    background: var(--danger-hover);
    border-color: var(--danger-hover);
    color: #ffffff;
}

.btn-small {
    height: 30px;
    padding: 0 10px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

/* 4.2 Input & select */
input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
select {
    height: 36px;
    width: 100%;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input::placeholder {
    color: #94a3b8;
}

select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 28px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6" viewBox="0 0 10 6"><path d="M1 1l4 4 4-4" stroke="%2364748b" stroke-width="1.5" fill="none" stroke-linecap="round" stroke-linejoin="round"/></svg>');
    background-repeat: no-repeat;
    background-position: right 10px center;
    cursor: pointer;
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
}

.form-group {
    margin-bottom: 16px;
}

/* Form inline (aksi di tabel, dsb) */
.form-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
}

/* Satu baris form: input fleksibel + kontrol sejajar tengah */
.form-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-row input {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

.form-row select {
    flex: 0 0 96px;
    width: 96px;
}

/* Select mode SSL/TLS lebih lebar agar label "Full (Strict)" muat (A7.4) */
.form-row select.select-ssl {
    flex: 0 0 160px;
    width: 160px;
}

/* Hint kecil di bawah form (mis. petunjuk "@" pada form subdomain) */
.form-hint {
    margin: 6px 0 0;
    font-size: 12px;
}

.form-row .btn {
    flex: 0 0 auto;
    height: 36px;
}

/* Baris aksi horizontal (mis. kontrol keamanan) */
.action-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* 4.3 Badge status pill */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    background: #f1f5f9;
    color: #475569;
    white-space: nowrap;
}

.badge-pending {
    background: var(--warning-bg);
    color: var(--warning-text);
}

.badge-active {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error-text);
}

/* 4.4 Card — satu level saja, tanpa card bersarang */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 22px 24px;
    margin-bottom: 20px;
}

/* 4.5 Tabel */
.table-wrap {
    overflow-x: auto;
}

.card .table-wrap {
    margin: -6px -24px;
    padding: 6px 24px 0;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hairline);
    vertical-align: middle;
}

.table tbody tr {
    transition: background var(--transition);
}

.table tbody tr:hover {
    background: #f8fafc;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* Kolom pertama: penekanan utama */
.table tbody td:first-child {
    font-weight: 600;
}

/* Name server: monospace */
.table td.col-ns > div,
.table td.col-ns {
    font-family: var(--mono);
    font-size: 13px;
    color: var(--text-muted);
}

/* Kolom waktu (log): tidak wrap */
.table td.col-waktu {
    white-space: nowrap;
}

/* Daftar subdomain di sel tabel dashboard */
.table td.cell-subs > div {
    font-weight: 400;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.7;
}

.table .actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    white-space: nowrap;
}

.table .actions .form-inline {
    margin: 0;
}

/* Kolom Pengaturan (redirect per subdomain): form tidak turun-turun di desktop */
.table-redirect {
    table-layout: auto;
}

.table-redirect td.pengaturan {
    min-width: 430px;
}

.table-redirect td .text-muted {
    font-size: 13px;
}

/* 4.6 Alert / flash */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
    border: 1px solid transparent;
    font-size: 13px;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: #a7f3d0;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: #fecaca;
}

.alert-warning {
    background: var(--warning-bg);
    color: var(--warning-text);
    border-color: #fde68a;
}

/* 4.7 Info grid (ringkasan domain di halaman/modal Kelola) */
.info-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 32px;
    margin: 0;
}

.info-grid .info-item {
    min-width: 0;
}

.info-grid dt {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.info-grid dd {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    word-break: break-all;
}

.info-grid dd.mono {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 400;
}

/* Info list klasik (halaman Tes Koneksi) */
.info-list {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 8px 16px;
    margin: 0;
}

.info-list dt {
    font-size: 13px;
    color: var(--text-muted);
}

.info-list dd {
    margin: 0;
    font-weight: 500;
}

/* 4.8 Blok/section fitur di halaman Kelola (juga dirender di dalam modal):
   tiap fitur berupa blok berbingkai dengan judul + hairline divider,
   dipisah jarak antar-blok agar setiap bagian mudah dibedakan. */
.manage-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 24px;
}

.manage-section + .manage-section {
    margin-top: 24px;
}

.section-head {
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.section-head h2 {
    margin: 0 0 4px;
}

.section-desc {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.subhead {
    margin: 18px 0 8px;
    color: var(--text);
}

.status-line {
    font-size: 13px;
    color: var(--text-muted);
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.status-line .badge {
    margin: 0 2px;
}

.manage-section .form-row {
    margin-top: 14px;
}

.manage-section .table-wrap {
    margin-top: 0;
}

/* Hasil "Cek SSL" di bloknya sendiri */
.ssl-check-result {
    margin-top: 12px;
    font-size: 13px;
}

.ssl-check-result .check-row {
    padding: 8px 0;
    border-top: 1px solid var(--hairline);
}

.ssl-check-result .check-row:first-of-type {
    border-top: none;
}

/* Baris status + aksi keamanan */
.security-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.security-row .status-label {
    font-size: 13px;
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* 4.9 Login */
.login-wrapper {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
}

.login-card {
    width: 100%;
    max-width: 380px;
    padding: 28px;
    margin-bottom: 0;
}

.login-title {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 20px;
}

.login-card .btn-block {
    height: 38px;
    margin-top: 4px;
}

/* 4.10 Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
    margin: 14px 0 0;
}

/* 4.11 Halaman kosong / 404 */
.empty-state {
    text-align: center;
    padding: 48px 24px;
}

/* --- 5. Modal --- */

/* 5.1 Modal konfirmasi (selalu di atas modal Kelola) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1100; /* di atas modal Kelola Domain (1000) bila keduanya terbuka */
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 400px;
    padding: 22px;
}

.modal-title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 600;
}

.modal-message {
    margin: 0 0 6px;
    color: var(--text);
}

.modal-note {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 13px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

/* 5.2 Modal Kelola Domain */
.manage-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 1000;
}

.manage-overlay[hidden] {
    display: none;
}

.manage-dialog {
    background: var(--surface);
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-modal);
    width: min(960px, 94vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.manage-dialog-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}

.manage-dialog-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.manage-dialog-domain {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.manage-dialog-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.manage-dialog-close:hover {
    background: #f1f5f9;
    color: var(--text);
}

.manage-dialog-body {
    padding: 24px 28px;
    overflow-y: auto;
}

.manage-dialog-error {
    color: var(--error-text);
    font-size: 13px;
    margin: 0 0 12px;
}

/* --- 6. Responsif (≤768px) --- */
@media (max-width: 768px) {
    .container {
        padding: 20px 16px 48px;
    }

    /* Blok fitur lebih rapat di layar kecil */
    .manage-section {
        padding: 16px;
    }

    .topbar-inner {
        gap: 14px;
    }

    .nav {
        gap: 0;
    }

    /* Modal Kelola nyaris fullscreen */
    .manage-overlay {
        padding: 8px;
    }

    .manage-dialog {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 16px);
    }

    .manage-dialog-header {
        padding: 12px 16px;
    }

    .manage-dialog-body {
        padding: 20px 16px;
    }

    /* form-row menjadi kolom (stack) */
    .form-row {
        flex-direction: column;
        align-items: stretch;
    }

    .form-row select {
        flex: 0 0 auto;
        width: 100%;
    }

    .form-row .btn {
        width: 100%;
    }

    /* Tabel scroll horizontal */
    .table-wrap {
        overflow-x: auto;
    }

    .table-redirect td.pengaturan {
        min-width: 320px;
    }

    .info-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .info-list {
        grid-template-columns: 110px 1fr;
    }

    .security-row {
        gap: 10px;
    }
}
