/* =============================================
   StemDja Short Link - Stylesheet Utama
   Mobile-first, fluid, Bootstrap/DaisyUI feel
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --primary:       #4f46e5;
    --primary-dark:  #4338ca;
    --primary-light: #818cf8;
    --primary-50:    #eef2ff;
    --primary-100:   #e0e7ff;
    --success:       #16a34a;
    --success-bg:    #f0fdf4;
    --success-border:#bbf7d0;
    --error:         #dc2626;
    --error-bg:      #fef2f2;
    --error-border:  #fecaca;
    --bg:            #f1f5f9;
    --card-bg:       #ffffff;
    --text:          #0f172a;
    --text-muted:    #64748b;
    --border:        #e2e8f0;
    --radius-sm:     8px;
    --radius:        12px;
    --radius-lg:     16px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow:        0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
    --transition:    .15s ease;
}

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

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(ellipse 80% 50% at 20% -10%, rgba(79,70,229,.12) 0%, transparent 60%),
        radial-gradient(ellipse 60% 40% at 80% 110%, rgba(16,163,74,.08) 0%, transparent 60%);
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* ===========================
   TYPOGRAPHY
   =========================== */
h1, h2, h3 { line-height: 1.25; font-weight: 700; color: var(--text); }
h1 { font-size: clamp(1.35rem, 4vw, 1.75rem); }
h2 { font-size: clamp(1.1rem, 3vw, 1.35rem); }
h3 { font-size: 1rem; }
p  { color: var(--text-muted); }
a  { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code {
    font-family: ui-monospace, monospace;
    font-size: .85em;
    background: var(--primary-50);
    color: var(--primary-dark);
    padding: .1em .4em;
    border-radius: 4px;
}

/* ===========================
   LAYOUT
   =========================== */
.site-header {
    padding: clamp(16px, 4vw, 28px) clamp(16px, 5vw, 32px);
    text-align: center;
}

.main-content {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: clamp(12px, 3vw, 24px) clamp(12px, 4vw, 20px);
}

.site-footer {
    text-align: center;
    padding: 20px 16px;
    font-size: .82rem;
    color: var(--text-muted);
}

/* ===========================
   NAVBAR / TOP-NAV
   =========================== */
.top-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.top-nav a {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 600;
    color: var(--primary);
    border: 1.5px solid var(--primary-100);
    background: var(--primary-50);
    transition: background var(--transition), border-color var(--transition);
}

.top-nav a:hover {
    background: var(--primary-100);
    text-decoration: none;
}

.top-nav .nav-greet {
    font-size: .8rem;
    color: var(--text-muted);
    padding: 5px 8px;
}

/* ===========================
   LOGO
   =========================== */
.logo {
    font-size: clamp(1.5rem, 5vw, 2rem);
    font-weight: 800;
    color: var(--primary);
    letter-spacing: -1px;
}

.logo span { color: var(--text); }

.site-header > p {
    font-size: clamp(.8rem, 2.5vw, .95rem);
    margin-top: 4px;
}

/* ===========================
   CARD
   =========================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: clamp(20px, 5vw, 36px) clamp(18px, 5vw, 40px);
    width: 100%;
    max-width: 560px;
}

.card .subtitle {
    font-size: .9rem;
    margin-top: 4px;
    margin-bottom: 20px;
}

/* ===========================
   QUOTA INFO
   =========================== */
.quota-info {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-50);
    border: 1px solid var(--primary-100);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: .82rem;
    color: var(--text);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.quota-info::before {
    content: '⚡';
    font-size: .85rem;
}

.quota-info a {
    font-weight: 600;
    color: var(--primary-dark);
}

.quota-info.quota-empty {
    background: var(--error-bg);
    border-color: var(--error-border);
    color: #991b1b;
}

.quota-info.quota-empty::before { content: '🚫'; }

/* ===========================
   ALERT
   =========================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border-width: 1px;
    border-style: solid;
    font-size: .875rem;
    margin-bottom: 16px;
    line-height: 1.5;
}

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

.alert-success::before { content: '✓'; font-weight: 700; margin-top: 1px; }

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

.alert-error::before { content: '!'; font-weight: 700; margin-top: 1px; }

/* ===========================
   FORM
   =========================== */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: .01em;
}

.form-group .badge-optional {
    display: inline-block;
    font-size: .7rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 7px;
    margin-left: 6px;
    vertical-align: middle;
}

.form-group .hint {
    font-size: .75rem;
    color: var(--text-muted);
    margin-top: 5px;
    line-height: 1.4;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .95rem;
    font-family: inherit;
    color: var(--text);
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="password"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

input:disabled {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Alias input dengan prefix domain */
.alias-group {
    display: flex;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.alias-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

.alias-group .prefix {
    background: var(--bg);
    color: var(--text-muted);
    padding: 10px 12px;
    font-size: .8rem;
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    border-right: 1.5px solid var(--border);
    flex-shrink: 0;
    max-width: 55%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.alias-group input {
    border: none;
    border-radius: 0;
    flex: 1;
    min-width: 0;
}

.alias-group input:focus { box-shadow: none; }

/* ===========================
   BUTTONS
   =========================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition),
                box-shadow var(--transition), transform .08s ease, opacity var(--transition);
    white-space: nowrap;
    width: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active { transform: scale(.98); }

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

/* Primary */
.btn-primary, .btn:not(.btn-secondary):not(.btn-danger):not(.btn-ghost) {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 1px 2px rgba(79,70,229,.3);
}

.btn-primary:hover,
.btn:not(.btn-secondary):not(.btn-danger):not(.btn-ghost):hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

/* Secondary / outline */
.btn-secondary {
    background: #fff;
    color: var(--primary);
    border-color: var(--primary-100);
}

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

/* Danger */
.btn-danger {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}

.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* Size variants */
.btn-sm {
    padding: 7px 14px;
    font-size: .8rem;
    width: auto;
}

.btn-full { width: 100%; }

/* ===========================
   RESULT BOX
   =========================== */
#result { margin-top: 20px; }

.result-box {
    display: none;
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    border: 1px solid;
    animation: fadeSlideIn .2s ease;
}

.result-box.show { display: block; }

.result-box:not(.error) {
    background: var(--success-bg);
    border-color: var(--success-border);
}

.result-box.error {
    background: var(--error-bg);
    border-color: var(--error-border);
}

.result-label {
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 8px;
}

.result-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.result-row input {
    flex: 1;
    font-weight: 700;
    font-size: .9rem;
    color: var(--primary-dark);
    background: #fff;
    min-width: 0;
}

.error-text {
    color: #991b1b;
    font-size: .875rem;
    margin: 0;
    line-height: 1.5;
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ===========================
   ERROR PAGES (404/410)
   =========================== */
.error-page { text-align: center; }

.error-page .code {
    font-size: clamp(3rem, 15vw, 5rem);
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
    margin-bottom: 8px;
}

.error-page h2 { margin-bottom: 6px; }
.error-page p  { margin-bottom: 20px; }

/* ===========================
   RESPONSIVE
   =========================== */

/* Alias prefix terlalu panjang di layar kecil: wrap ke bawah */
@media (max-width: 400px) {
    .alias-group {
        flex-direction: column;
    }

    .alias-group .prefix {
        border-right: none;
        border-bottom: 1.5px solid var(--border);
        max-width: 100%;
        font-size: .75rem;
    }

    .result-row {
        flex-direction: column;
        align-items: stretch;
    }

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

    .top-nav a { padding: 5px 10px; }
}

/* Tablet ke atas: sedikit lebih lapang */
@media (min-width: 640px) {
    .card { margin-top: 8px; }
}
