/* Portal Pelanggan — template layout mengacu FTTHSNMS Standalone */

:root {
    --bottom-nav-height: 64px;
    --header-height: 56px;
    --primary-color: #FF6F00;
    --primary-dark: #E65100;
    --primary-light: #FF8F3C;
    --secondary-color: #000000;
    --secondary-light: #333333;
    --success-color: #2e7d32;
    --warning-color: #FF6F00;
    --danger-color: #000000;
    --info-color: #FF6F00;
    --text-primary: #000000;
    --text-secondary: #424242;
    --text-muted: #757575;
    --bg-primary: #FFFFFF;
    --bg-secondary: #F5F5F5;
    --border-color: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.12);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.18);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

body {
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow: hidden;
}

button, input, select, textarea, .btn-primary, .btn-secondary, .btn-danger, .btn-outline,
.nav-item, .menu-item, .app-title, .card-title, .swal2-popup,
h1, h2, h3, h4, h5, h6, strong, b, label, small, a, span, p, li, td, th {
    font-family: 'Montserrat', sans-serif;
    font-weight: 500;
}

.hidden { display: none !important; }

/* ========== APP SHELL ========== */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg-secondary);
}

.header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    min-height: var(--header-height);
    background: #000000;
    color: #FFFFFF;
    box-shadow: var(--shadow);
    z-index: 200;
    flex-shrink: 0;
}

.header-left {
    grid-column: 1;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-right {
    grid-column: 3;
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-title { font-size: 18px; font-weight: 500; }

.header-stats { display: flex; align-items: center; gap: 6px; }

.stat-pill {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.18);
    border: 1px solid rgba(255,255,255,0.35);
    border-radius: 8px;
    line-height: 1.1;
    color: inherit;
}

.stat-pill .stat-value { font-size: 12px; font-weight: 500; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-pill .stat-label { font-size: 9px; text-transform: uppercase; letter-spacing: .04em; opacity: .9; margin-top: 1px; }

.main-content {
    flex: 1 1 auto;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

.view-container {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px;
    padding-bottom: 24px;
    transition: var(--transition);
}

.view-container.active {
    opacity: 1;
    visibility: visible;
    z-index: 1;
}

/* ========== BOTTOM NAV + FAB ========== */
.bottom-nav {
    display: flex;
    align-items: center;
    justify-content: space-around;
    min-height: var(--bottom-nav-height);
    padding: 8px 0 calc(12px + env(safe-area-inset-bottom, 0px));
    background: white;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.12);
    flex-shrink: 0;
    z-index: 300;
    position: relative;
    overflow: visible;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    font: inherit;
}

.nav-item i { font-size: 20px; }
.nav-item span { font-size: 11px; font-weight: 500; }
.nav-item.active { color: var(--primary-color); }
.nav-item:active { background: var(--bg-secondary); }

.nav-badge {
    position: absolute;
    top: 2px;
    right: calc(50% - 18px);
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 99px;
    background: var(--primary-color);
    color: #fff;
    font-size: 10px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab-container {
    flex: 0 0 56px;
    width: 56px;
    height: 0;
    position: relative;
    overflow: visible;
    pointer-events: none;
    align-self: center;
}

/* Jangan pakai class .fab — bentrok dengan Font Awesome Brands (.fab fa-whatsapp) */
.portal-fab {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: 3px solid white;
    box-shadow: 0 4px 16px rgba(255, 111, 0, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: var(--transition);
    transform: translate(-50%, -50%);
    pointer-events: auto;
}

.portal-fab:active {
    transform: translate(-50%, -50%) scale(0.94);
    background: var(--primary-dark);
}

/* ========== BUTTONS / ICONS ========== */
.icon-btn, .icon-btn-sm {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn { width: 40px; height: 40px; font-size: 20px; }
.icon-btn-sm { width: 32px; height: 32px; font-size: 16px; }
.icon-btn:active, .icon-btn-sm:active { background: rgba(255,255,255,0.2); }

.btn-primary, .btn-secondary, .btn-danger, .btn-outline {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    width: 100%;
    justify-content: center;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:active { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .65; cursor: not-allowed; }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); }
.btn-danger { background: var(--danger-color); color: white; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-primary);
}

/* ========== SIDE MENU ========== */
.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: min(300px, 86vw);
    height: 100%;
    background: white;
    z-index: 500;
    transform: translateX(-105%);
    transition: transform .3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.side-menu.open { transform: translateX(0); }

.side-menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 450;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.side-menu-overlay.open { opacity: 1; visibility: visible; }

.menu-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: #000000;
    color: #FFFFFF;
}

.menu-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.menu-logo {
    width: 52px;
    height: 52px;
    object-fit: contain;
    border-radius: 8px;
    background: #000000;
    flex-shrink: 0;
}

.menu-header h2 { font-size: 16px; line-height: 1.25; }
.menu-sub { opacity: .85; font-size: 12px; }

.menu-content { flex: 1; overflow-y: auto; padding: 8px 0; }

.menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    cursor: pointer;
    color: var(--text-primary);
    transition: var(--transition);
}

.menu-item i { width: 22px; text-align: center; color: var(--text-secondary); }
.menu-item:active { background: var(--bg-secondary); }
.menu-item.danger { color: var(--danger-color); }
.menu-item.danger i { color: var(--danger-color); }
.menu-divider { height: 1px; background: var(--border-color); margin: 8px 16px; }

.menu-footer {
    padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 2px;
    color: var(--text-muted);
    font-size: 12px;
}

.menu-credit { color: var(--primary-color); font-weight: 500; }

/* ========== MODAL ========== */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: flex-end;
    z-index: 600;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    background: rgba(0,0,0,.35);
}

.modal.active { opacity: 1; visibility: visible; }

.modal-content {
    width: 100%;
    max-height: 90vh;
    background: white;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .3s ease;
}

.modal.active .modal-content { transform: translateY(0); }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 { font-size: 18px; }
.modal-header .icon-btn { color: var(--text-secondary); }
.modal-header .icon-btn:active { background: var(--bg-secondary); }

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--border-color);
}

.modal-footer button { flex: 1; }

@media (min-width: 640px) {
    .modal { align-items: center; justify-content: center; padding: 24px; }
    .modal-content {
        max-width: 480px;
        border-radius: 16px;
        transform: translateY(20px) scale(.98);
        opacity: 0;
    }
    .modal.active .modal-content {
        transform: none;
        opacity: 1;
    }
}

/* ========== FORMS ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font: inherit;
    font-size: 15px;
    background: #fff;
    outline: none;
    transition: border-color .2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--primary-color); }

.input-icon-wrap { position: relative; }
.input-icon-wrap > i:first-child {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-muted);
}
.input-icon-wrap input { padding-left: 42px; padding-right: 42px; }
.input-icon-wrap .toggle-pass {
    position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
    border: 0; background: none; color: var(--text-muted); padding: 8px; cursor: pointer;
}

/* ========== CARDS / CONTENT ========== */
.card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--primary-color); }

.hero-card {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: #fff;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.hero-card h3 { font-size: clamp(1rem, 4vw, 1.25rem); margin-bottom: 4px; }
.hero-card p { opacity: .92; font-size: 14px; }

/* ========== PWA ========== */
.pwa-card {
    border: 1px solid #FFE0B2;
    background: linear-gradient(135deg, #FFFFFF 0%, #FFF8F0 100%);
}

.pwa-card.pwa-installed {
    border-color: #C8E6C9;
    background: linear-gradient(135deg, #FFFFFF 0%, #F1F8E9 100%);
}

.pwa-card-inner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    object-fit: cover;
    background: #000;
    flex-shrink: 0;
}

.pwa-title {
    font-size: 15px;
    color: #000;
    margin-bottom: 2px;
}

.pwa-title i { color: var(--success-color); margin-right: 4px; }

.pwa-copy p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.pwa-actions {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.pwa-actions-single {
    grid-template-columns: 1fr;
}

.pwa-actions .btn-primary,
.pwa-actions .btn-outline { width: 100%; }

.pwa-tutorial-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.pwa-steps {
    padding-left: 18px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-primary);
}

.pwa-steps li { margin-bottom: 8px; }

.pwa-tip {
    margin-top: 14px;
    padding: 12px;
    border-radius: 10px;
    background: #FFF3E0;
    color: #E65100;
    font-size: 13px;
    line-height: 1.5;
}

.pwa-tip i { margin-right: 6px; }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-card .icon { font-size: 28px; color: var(--primary-color); margin-bottom: 4px; }
.stat-card .value { font-size: 22px; font-weight: 500; }
.stat-card .label { font-size: 12px; color: var(--text-muted); }

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-secondary); }
.info-value { font-weight: 500; text-align: right; }

.list-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.list-item:last-child { border-bottom: none; }
.list-item-title { font-weight: 500; font-size: 15px; }
.list-item-subtitle { color: var(--text-muted); font-size: 13px; }

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: #fff;
    background: var(--text-muted);
}

.badge-success { background: var(--success-color); }
.badge-danger { background: var(--danger-color); }
.badge-warning { background: var(--warning-color); color: #212121; }
.badge-info { background: var(--info-color); }

.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.empty-state i { font-size: 42px; margin-bottom: 12px; opacity: .5; }

.loading {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-muted);
}

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

.device-card {
    background: white;
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.device-header {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.device-name { font-weight: 500; display: flex; align-items: center; gap: 8px; }
.device-name i { color: var(--primary-color); }

.wifi-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 12px 0;
}

.wifi-stat {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
}

.wifi-stat-label {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 4px;
}

.wifi-stat-value {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
}

.ssid-section {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.ssid-section-title {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ssid-item {
    background: var(--bg-secondary);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 8px;
}

.ssid-item.ssid-off { opacity: .72; }

.ssid-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.ssid-name {
    font-size: 15px;
    color: var(--text-primary);
    word-break: break-word;
}

.ssid-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 10px;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.band-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #000000;
    color: #FFFFFF;
    font-size: 10px;
}

.band-badge.band-24 { background: #FF6F00; color: #fff; }
.band-badge.band-5 { background: #000000; color: #FF6F00; border: 1px solid #FF6F00; }
.band-badge.band-6 { background: #333333; color: #fff; }
.band-badge.band-unk { background: #757575; color: #fff; }

.ssid-pwd-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 8px;
}

.ssid-pwd-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.ssid-pwd {
    font-size: 13px;
    background: #fff;
    padding: 4px 8px;
    border-radius: 6px;
}

.form-stack .form-group { margin-bottom: 14px; }

.modal-footer {
    display: flex;
    gap: 8px;
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary { width: auto; flex: 1; }

@media (max-width: 400px) {
    .wifi-stats { grid-template-columns: repeat(2, 1fr); }
}

.inbox-item {
    width: 100%;
    text-align: left;
    border: none;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 12px;
    font-weight: 500;
    font-size: 14px;
}

.status-bar.pending { background: #fff8e1; color: #f57f17; }
.status-bar.paid { background: #e8f5e9; color: #2e7d32; }
.status-bar.expired, .status-bar.error { background: #FFF3E0; color: #E65100; }

.qris-wrap { display: flex; flex-direction: column; align-items: center; padding: 8px 0 12px; }
#qrCanvas {
    width: min(260px, 72vw);
    height: auto;
    aspect-ratio: 1;
    border-radius: 12px;
    box-shadow: var(--shadow);
    background: #fff;
}

.amount-box {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 12px 0;
}

.amount-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.amount-row:last-child { border-bottom: none; }
.amount-row.total .value { color: var(--primary-color); font-size: 18px; font-weight: 500; }

.unique-badge {
    display: inline-block;
    background: #FFF3E0;
    color: var(--primary-color);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 13px;
    font-weight: 500;
}

.countdown {
    font-size: 28px;
    font-weight: 500;
    color: var(--danger-color);
    text-align: center;
    letter-spacing: .04em;
}

.countdown.ok { color: var(--success-color); }
.countdown.safe { color: var(--warning-color); }

.wa-box {
    margin-top: 12px;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
}

.wa-box.ok { background: #e8f5e9; color: #2e7d32; }
.wa-box.warn { background: #fff8e1; color: #f57f17; }

.portal-company {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin: 16px 0 8px;
}

/* ========== LOGIN ========== */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: #000000;
    overflow-y: auto;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #FFFFFF;
    border-radius: 16px;
    padding: 28px 22px;
    box-shadow: var(--shadow-lg);
    border-top: 4px solid var(--primary-color);
}

.login-brand {
    text-align: center;
    margin-bottom: 14px;
}

.login-logo {
    display: block;
    width: min(220px, 72vw);
    height: auto;
    margin: 0 auto;
    border-radius: 10px;
    background: #000000;
}

.login-card h1 {
    text-align: center;
    font-size: 22px;
    color: #000000;
    margin-bottom: 4px;
}

.login-sub {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 20px;
}

.login-error {
    background: #FFF3E0;
    color: #E65100;
    border: 1px solid #FFCC80;
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}

.login-help {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: none;
    font-size: 14px;
}

.login-footer {
    text-align: center;
    margin-top: 18px;
    color: var(--text-muted);
    font-size: 12px;
}

.swal2-popup { font-family: inherit !important; border-radius: 14px !important; }

@media (max-width: 400px) {
    .app-title { font-size: 15px; }
    .header { padding: 10px 12px; gap: 6px; }
}
