/* ============================================================
   Vidya URL Shortener - Style Utama
   Desain: Modern, minimalis, responsif, Card UI.
   ============================================================ */

:root {
    --primary: #2563EB;
    --primary-dark: #1D4ED8;
    --primary-light: #DBEAFE;
    --bg: #F1F5F9;
    --card: #FFFFFF;
    --text: #0F172A;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --green: #10B981;
    --green-light: #D1FAE5;
    --orange: #F59E0B;
    --orange-light: #FEF3C7;
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
    --shadow-hover: 0 4px 12px rgba(37, 99, 235, .18);
    --font: 'Segoe UI', system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: var(--font);
    background:
        radial-gradient(1000px 400px at 80% -10%, rgba(37, 99, 235, .10), transparent 60%),
        radial-gradient(800px 400px at 0% 0%, rgba(37, 99, 235, .06), transparent 50%),
        var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 20px 48px;
}

/* ===== Header ===== */
.app-header {
    text-align: center;
    margin-bottom: 28px;
}

.logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 14px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: var(--card);
    border-radius: 20px;
    box-shadow: var(--shadow);
}

.logo svg {
    width: 32px;
    height: 32px;
}

.app-header h1 {
    font-size: 1.9rem;
    font-weight: 800;
    letter-spacing: -.02em;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 6px;
    font-size: .95rem;
}

/* ===== Card ===== */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 18px;
}

/* ===== Form ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: .85rem;
    font-weight: 600;
}

.required {
    color: var(--danger);
}

.form-group small {
    font-size: .75rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="url"] {
    width: 100%;
    padding: 12px 14px;
    font-size: .95rem;
    font-family: inherit;
    color: var(--text);
    background: #F8FAFC;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input[type="text"]:focus,
input[type="url"]:focus {
    outline: none;
    background: var(--card);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 14px;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-actions {
    margin-top: 18px;
}

/* ===== Button ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 20px;
    font-size: .9rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .15s ease, background .15s ease;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(37, 99, 235, .3);
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-hover);
}

.btn-lg {
    padding: 14px 28px;
    font-size: .95rem;
    width: 100%;
    letter-spacing: .02em;
}

.btn:disabled {
    opacity: .6;
    cursor: not-allowed;
    transform: none;
}

/* ===== Hasil form (AJAX) ===== */
.form-result {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
}

.form-result.success {
    background: var(--green-light);
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.form-result.error {
    background: var(--danger-light);
    color: #991B1B;
    border: 1px solid #FECACA;
}

.form-result a {
    color: inherit;
    font-weight: 700;
    word-break: break-all;
}

/* ===== Statistik ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 20px;
    margin-bottom: 0;
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 14px;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.icon-blue { background: var(--primary-light); color: var(--primary); }
.icon-green { background: var(--green-light); color: var(--green); }
.icon-orange { background: var(--orange-light); color: var(--orange); }

.stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.1;
}

.stat-label {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Toolbar & Search ===== */
.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.table-toolbar .card-title {
    margin-bottom: 0;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-box input {
    padding-left: 38px;
    width: 260px;
    max-width: 100%;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    min-width: 640px;
}

.data-table th {
    text-align: left;
    padding: 12px 10px;
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: background .12s ease;
}

.data-table tbody tr:hover {
    background: #F8FAFC;
}

.col-center {
    text-align: center;
}

.url-cell {
    display: inline-block;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.url-cell:hover {
    text-decoration: underline;
}

.chip {
    font-family: 'Cascadia Code', Consolas, 'Courier New', monospace;
    font-size: .8rem;
}

.chip-code {
    display: inline-block;
    padding: 4px 10px;
    background: var(--primary-light);
    color: var(--primary-dark);
    border-radius: 8px;
    font-weight: 700;
}

.click-count {
    display: inline-block;
    min-width: 34px;
    padding: 3px 8px;
    background: var(--green-light);
    color: #065F46;
    border-radius: 8px;
    font-weight: 700;
    font-size: .8rem;
}

.date-cell {
    color: var(--text-muted);
    font-size: .82rem;
    white-space: nowrap;
}

.empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 36px 16px;
}

/* ===== Aksi (tombol ikon) ===== */
.actions {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: color .12s ease, background .12s ease, border-color .12s ease;
}

.icon-btn svg {
    width: 17px;
    height: 17px;
}

.icon-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
    border-color: var(--primary-light);
}

.icon-btn-danger:hover {
    color: var(--danger);
    background: var(--danger-light);
    border-color: var(--danger-light);
}

/* ===== Footer ===== */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: .8rem;
    padding: 12px 0;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: var(--text);
    color: #FFFFFF;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: .9rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .3);
    opacity: 0;
    transition: opacity .25s ease, transform .25s ease;
    z-index: 100;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: var(--danger);
}

/* ===== Halaman 404 ===== */
.page-404 {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.notfound {
    text-align: center;
    max-width: 480px;
}

.notfound-code {
    font-size: 5rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -.03em;
}

.notfound h1 {
    font-size: 1.5rem;
    margin: 12px 0 8px;
}

.notfound p {
    color: var(--text-muted);
    margin-bottom: 22px;
}

.notfound .btn {
    margin-top: 4px;
}

.notfound .chip {
    padding: 3px 8px;
    background: var(--border);
    border-radius: 6px;
}

/* ===== Responsive ===== */
@media (max-width: 720px) {
    .container {
        padding: 24px 14px 40px;
    }

    .app-header h1 {
        font-size: 1.5rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card {
        padding: 18px;
    }

    .search-box input {
        width: 100%;
    }
}
