/* ============================================
   LAUNDRY SAAS - TENANT STYLE
   Container mengikuti ukuran device
   ============================================ */

:root {
    --primary: #4A7C59;
    --primary-dark: #3A6347;
    --secondary: #8FB996;
    --accent: #D4A574;
    --bg: #FAF9F6;
    --surface: #FFFFFF;
    --text: #2C3E2D;
    --muted: #7A8B7B;
    --border: #E8EAE6;
    --danger: #C77B6B;
    --warning: #E0B973;
    --success: #6B9E78;
    --radius: 14px;
    --radius-sm: 10px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

img, svg, video {
    max-width: 100%;
    height: auto;
}

/* ========== APP CONTAINER ==========
   Mengikuti lebar device.
   Max 900px untuk desktop biar tidak terlalu lebar. */
.app-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    position: relative;
    overflow-x: hidden;
}

/* ========== HEADER ========== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--surface);
    padding: 14px 18px;
    padding-top: calc(14px + env(safe-area-inset-top, 0));
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    gap: 8px;
}

.page-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.saldo-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    background: rgba(74,124,89,0.1);
    color: var(--primary);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 1.6s infinite;
    flex-shrink: 0;
}

.live-dot.offline { background: var(--muted); animation: none; }

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.2); }
}

/* ========== MAIN ========== */
.app-main {
    padding: 16px 18px 100px;
    overflow-x: hidden;
    width: 100%;
}

/* ========== BOTTOM NAV ==========
   Mengikuti lebar container (max 900px) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 900px;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0));
    z-index: 100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    color: var(--muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    transition: color 0.2s;
}

.nav-item.active { color: var(--primary); }

.nav-fab {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 6px 16px rgba(74,124,89,0.35);
    transform: translateY(-14px);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.nav-fab:active { transform: translateY(-14px) scale(0.95); }

/* ========== CARD ========== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

/* ========== BUTTON ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    min-height: 46px;
    font-family: inherit;
    box-sizing: border-box;
    transition: all 0.15s;
    max-width: 100%;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:active { background: var(--primary-dark); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:active { background: rgba(74,124,89,0.06); }
.btn-danger { background: var(--danger); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; min-height: 36px; font-size: 12px; }

/* ========== FORM ========== */
.form-group {
    margin-bottom: 14px;
    width: 100%;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    background: var(--surface);
    color: var(--text);
    box-sizing: border-box;
    min-height: 46px;
    line-height: 1.4;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,124,89,0.12);
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

/* ========== SELECT ========== */
.form-select,
select.form-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 42px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234A7C59' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    cursor: pointer;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

.form-select option {
    padding: 10px;
    font-size: 15px;
}

/* ========== STAT ========== */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    min-width: 0;
}

.stat-label {
    font-size: 11px;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    word-break: break-word;
}

/* ========== BADGE ========== */
.badge {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-diterima { background: #E8EAE6; color: #566A57; }
.badge-dicuci { background: #D6E5F5; color: #3A6EA5; }
.badge-disetrika { background: #F5E5D6; color: #A56A3A; }
.badge-siap { background: #D6F0DC; color: #3A8A4E; }
.badge-selesai { background: #E2E2E2; color: #666; }
.badge-lunas { background: #D6F0DC; color: #3A8A4E; }
.badge-belum { background: #F5DFD6; color: #A5503A; }

/* ========== LIST ========== */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
    width: 100%;
    gap: 10px;
}

.list-item-left { flex: 1; min-width: 0; }

.list-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.list-item-sub {
    font-size: 12px;
    color: var(--muted);
}

/* ========== AVATAR ========== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--secondary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 15px;
    flex-shrink: 0;
    margin-right: 12px;
}

.avatar-lg { width: 60px; height: 60px; font-size: 22px; }

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
}

.empty-state p { font-size: 13px; }

/* ========== AUTH ========== */
.auth-page {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 30px 24px;
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo-icon {
    width: 68px;
    height: 68px;
    border-radius: 20px;
    background: var(--primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.auth-logo h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.auth-logo p {
    font-size: 13px;
    color: var(--muted);
}

/* ========== STEPS ========== */
.steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 24px;
}

.step-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border);
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    flex-shrink: 0;
}

.step-dot.active { background: var(--primary); color: white; }
.step-dot.done { background: var(--secondary); color: white; }

.step-line {
    width: 20px;
    height: 2px;
    background: var(--border);
    border-radius: 2px;
}

.step-line.done { background: var(--secondary); }

.step-content { display: none; }
.step-content.active { display: block; }

/* ========== LOCK ========== */
.lock-screen {
    min-height: 100vh;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px 24px;
    text-align: center;
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.lock-icon {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(199,123,107,0.1);
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
}

.lock-screen h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 8px;
}

.lock-screen p {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 24px;
    line-height: 1.6;
}

.lock-info {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    width: 100%;
    margin-bottom: 22px;
}

.lock-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    gap: 10px;
}

.lock-info-row + .lock-info-row { border-top: 1px solid var(--border); }
.lock-info-label { color: var(--muted); }
.lock-info-value { font-weight: 600; color: var(--text); text-align: right; }

.waiting-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: rgba(74,124,89,0.08);
    color: var(--primary);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    margin-top: 18px;
}

.waiting-dot {
    width: 8px;
    height: 8px;
    background: var(--primary);
    border-radius: 50%;
    animation: pulse 1.6s infinite;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--text);
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s;
    max-width: calc(100% - 40px);
    text-align: center;
    pointer-events: none;
    box-sizing: border-box;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* ========== MODAL ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44,62,45,0.4);
    z-index: 1000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal-sheet {
    background: var(--surface);
    width: 100%;
    max-width: 900px;
    border-radius: 20px 20px 0 0;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom, 0));
    max-height: 90vh;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal-handle {
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 16px;
}

/* ========== SECTION ========== */
.section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin: 18px 0 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.section-title a {
    font-size: 12px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

/* ========== BANNERS ========== */
.warning-banner {
    background: rgba(224,185,115,0.15);
    border: 1px solid rgba(224,185,115,0.4);
    color: #8B6A1F;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    box-sizing: border-box;
}

.saldo-banner {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.saldo-label {
    font-size: 12px;
    opacity: 0.85;
    margin-bottom: 6px;
}

.saldo-amount {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    word-break: break-word;
}

.saldo-note {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 6px;
}

/* ========== TIMELINE ========== */
.timeline {
    position: relative;
    padding-left: 28px;
}

.timeline-item {
    position: relative;
    padding-bottom: 22px;
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-item::before {
    content: '';
    position: absolute;
    left: -22px;
    top: 20px;
    bottom: -6px;
    width: 2px;
    background: var(--border);
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
    position: absolute;
    left: -28px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--border);
    border: 3px solid var(--bg);
}

.timeline-item.active .timeline-dot {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(74,124,89,0.15);
}

.timeline-item.done .timeline-dot { background: var(--success); }

.timeline-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.timeline-time {
    font-size: 11.5px;
    color: var(--muted);
}

/* ========== SPINNER ========== */
.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ========== UTIL ========== */
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }

/* ============================================
   RESPONSIVE — MENGIKUTI DEVICE
   ============================================ */

/* HP kecil ≤ 360px */
@media (max-width: 360px) {
    .app-header { padding: 12px; padding-top: calc(12px + env(safe-area-inset-top, 0)); }
    .app-main { padding: 12px 12px 100px; }
    .card { padding: 12px; }
    .page-title { font-size: 15px; }
    .stat-grid { gap: 8px; }
    .stat-value { font-size: 16px; }
    .nav-fab { width: 46px; height: 46px; }
    .saldo-amount { font-size: 22px; }
    .step-line { width: 14px; }
}

/* HP sedang 361-480px */
@media (min-width: 361px) and (max-width: 480px) {
    .app-main { padding: 14px 16px 100px; }
    .card { padding: 14px; }
}

/* HP besar 481-767px */
@media (min-width: 481px) and (max-width: 767px) {
    .app-main { padding: 16px 20px 100px; }
}

/* Tablet & Desktop ≥ 768px */
@media (min-width: 768px) {
    .app-main { padding: 20px 24px 100px; }
    
    .stat-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
    
    .stat-card { padding: 16px; }
    .stat-value { font-size: 20px; }
    
    .card { padding: 18px; }
    .card-title { font-size: 15px; }
    
    .form-input,
    .form-textarea,
    .form-select {
        font-size: 15px;
        padding: 13px 16px;
    }
    
    .btn { font-size: 14.5px; }
}

/* Desktop besar ≥ 1024px */
@media (min-width: 1024px) {
    .app-main { padding: 24px 32px 100px; }
    
    .page-title { font-size: 20px; }
    
    .saldo-badge { font-size: 13px; padding: 6px 12px; }
}

/* iOS anti-zoom */
@media (max-width: 767px) {
    input,
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Landscape HP */
@media (max-height: 500px) and (orientation: landscape) {
    .app-header {
        position: relative;
        padding-top: 10px;
    }
    .auth-page,
    .lock-screen {
        justify-content: flex-start;
        padding-top: 20px;
    }
    .lock-icon { width: 60px; height: 60px; margin-bottom: 12px; }
    .lock-screen h1 { font-size: 18px; }
}

/* Print */
@media print {
    .bottom-nav,
    .app-header,
    .nav-fab,
    .btn {
        display: none !important;
    }
    .app-container {
        max-width: 100%;
        box-shadow: none;
    }
}