/* =========================================================
   Koperasi AJA - Base Design System
   Shared tokens, reset, typography, form & button primitives
   ========================================================= */

:root {
    --primary: #0f9d6e;
    --primary-dark: #0b7a56;
    --primary-light: #e4f7ef;
    --accent: #f5a524;
    --accent-dark: #c97e0e;

    --ink: #16211d;
    --ink-soft: #5b6b64;
    --line: #e4e9e6;
    --surface: #ffffff;
    --bg: #f2f6f4;

    --danger: #e5484d;
    --danger-light: #fdeceb;
    --warning: #f5a524;
    --warning-light: #fef3e0;
    --success: #0f9d6e;
    --success-light: #e4f7ef;
    --muted: #8a978f;
    --muted-light: #eef1ef;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 1px 2px rgba(22, 33, 29, 0.06);
    --shadow: 0 8px 24px -8px rgba(22, 33, 29, 0.14);
    --shadow-lg: 0 16px 40px -12px rgba(22, 33, 29, 0.22);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font);
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    line-height: 1.45;
}

h1, h2, h3, h4, p { margin: 0 0 4px; }
a { color: var(--primary-dark); text-decoration: none; }
img { max-width: 100%; display: block; }

.text-muted { color: var(--ink-soft); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
    text-align: center;
    line-height: 1.2;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 13px; border-radius: 8px; }

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

.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-dark); }

.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--muted-light); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: var(--danger-light); color: var(--danger); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    color: var(--ink);
    background: var(--surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }
.input-group { position: relative; }
.input-group .form-control { padding-left: 40px; }
.input-icon {
    position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
    color: var(--muted); width: 18px; height: 18px;
}
.toggle-pass {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px;
}

/* ---------- Card ---------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
    border: 1px solid var(--line);
}

/* ---------- Badge ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}
.badge-success { background: var(--success-light); color: var(--primary-dark); }
.badge-warning { background: var(--warning-light); color: var(--accent-dark); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-muted { background: var(--muted-light); color: var(--ink-soft); }

/* ---------- Avatar ---------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---------- Alerts / Flash ---------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-success { background: var(--success-light); color: var(--primary-dark); }
.alert-danger { background: var(--danger-light); color: var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--accent-dark); }
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

/* ---------- Auth screens (login/register) ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 20px;
    background: linear-gradient(160deg, var(--primary-dark) 0%, var(--primary) 45%, #12b382 100%);
}
.auth-logo {
    width: 64px; height: 64px;
    border-radius: 18px;
    background: rgba(255,255,255,0.16);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 14px;
    color: #fff;
}
.auth-title { color: #fff; font-size: 22px; font-weight: 800; text-align: center; margin-bottom: 2px; }
.auth-subtitle { color: rgba(255,255,255,0.85); font-size: 13.5px; text-align: center; margin-bottom: 26px; }
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 28px 24px;
}
.auth-card h2 { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.auth-card .sub { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 20px; }
.auth-switch { text-align: center; font-size: 13.5px; color: var(--ink-soft); margin-top: 18px; }
.auth-switch a { font-weight: 700; }
.auth-divider { text-align: center; color: var(--muted); font-size: 12px; margin: 4px 0 18px; }

@media (max-width: 420px) {
    .auth-card { padding: 24px 18px; }
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15, 27, 22, 0.5);
    display: none; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; font-weight: 800; }
.modal-head button { background: none; border: none; cursor: pointer; color: var(--ink-soft); padding: 4px; }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
