/* assets/css/app.css */

:root {
    --primary:   #E53935;
    --secondary: #43A047;
    --accent:    #2196F3;
    --bg:        #F5F5F5;
    --white:     #ffffff;
    --text:      #1A1A1A;
    --muted:     #888888;
    --border:    #EBEBEB;
    --dark:      #111111;

    --pending-bg:  #FFF3E0; --pending-fg:  #E65100;
    --assigned-bg: #E3F2FD; --assigned-fg: #1565C0;
    --transit-bg:  #F3E5F5; --transit-fg:  #6A1B9A;
    --done-bg:     #E8F5E9; --done-fg:     #2E7D32;

    --font: 'DM Sans', system-ui, -apple-system, sans-serif;
    --radius-sm: 7px;
    --radius:    12px;
    --radius-lg: 14px;
}

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

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: -0.01em;
}

/* ── TYPOGRAPHY ─────────────────────────────────────────────────────────── */
.logo {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: -0.04em;
    color: var(--dark);
}
.logo span { color: var(--primary); }

.section-title {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 4px 0 14px;
}

/* ── LAYOUT ─────────────────────────────────────────────────────────────── */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 72px;
}

/* ── HEADER ─────────────────────────────────────────────────────────────── */
.app-header {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.badge-active {
    background: #F1F8F1;
    color: var(--secondary);
    font-size: 0.6rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 5px;
}
.badge-active::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--secondary);
    display: inline-block;
}
.badge-active.syncing { color: var(--muted); }
.badge-active.syncing::before { background: var(--muted); }

.btn-logout {
    background: none; border: none;
    color: var(--muted); font-size: 0.8rem;
    cursor: pointer; padding: 4px 8px;
    font-family: var(--font);
}

/* ── STATS GRID ─────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 12px 14px 6px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 4px;
    text-align: center;
}
.stat-card .num {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dark);
    letter-spacing: -0.05em;
    line-height: 1;
}
.stat-card .lbl {
    display: block;
    font-size: 0.55rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
    margin-top: 4px;
}

/* ── OFFLINE BANNER ─────────────────────────────────────────────────────── */
.offline-banner {
    background: var(--pending-bg);
    color: var(--pending-fg);
    font-size: 0.75rem;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    display: none;
}
.offline-banner.show { display: flex; }

/* ── VIEWS ──────────────────────────────────────────────────────────────── */
.view {
    display: none;
    padding: 10px 14px 20px;
    animation: fadeUp 0.2s ease-out;
}
.view.active { display: block; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── SEARCH + FILTERS ───────────────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 12px;
    margin-bottom: 10px;
    gap: 8px;
}
.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 0.88rem;
    font-family: var(--font);
    padding: 11px 0;
    color: var(--text);
    background: transparent;
}
.search-bar input::placeholder { color: #bbb; }
.search-icon { color: var(--muted); font-size: 1rem; }

.filter-chips {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    margin-bottom: 12px;
    scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }

.chip {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--white);
    font-size: 0.78rem;
    font-family: var(--font);
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    color: var(--muted);
    transition: all 0.15s;
    flex-shrink: 0;
}
.chip.active {
    background: var(--dark);
    border-color: var(--dark);
    color: var(--white);
}

/* ── TABS ───────────────────────────────────────────────────────────────── */
.tab-row {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.tab-btn {
    flex: 1;
    padding: 9px 8px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: var(--font);
    color: var(--muted);
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
    text-align: center;
}
.tab-btn.active {
    color: var(--dark);
    border-bottom-color: var(--dark);
}

/* ── CARDS ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 10px;
}
.card.pulse { border: 1.5px solid var(--primary); animation: pulseBorder 2s infinite; }
@keyframes pulseBorder {
    0%, 100% { border-color: var(--primary); }
    50%       { border-color: transparent; }
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}
.card-id {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--dark);
    letter-spacing: -0.02em;
}
.card-amount {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--secondary);
    margin-left: 8px;
}
.card-time {
    font-size: 0.72rem;
    color: var(--muted);
    margin-top: 2px;
}

.card-detail {
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 10px;
}
.card-detail .lbl { color: var(--muted); font-size: 0.75rem; }

/* ── STATUS BADGE ───────────────────────────────────────────────────────── */
.badge {
    font-size: 0.65rem;
    font-weight: 500;
    padding: 4px 9px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.badge-pending  { background: var(--pending-bg);  color: var(--pending-fg); }
.badge-accepted { background: var(--assigned-bg); color: var(--assigned-fg); }
.badge-received { background: var(--assigned-bg); color: var(--assigned-fg); }
.badge-transit  { background: var(--transit-bg);  color: var(--transit-fg); }
.badge-done     { background: var(--done-bg);     color: var(--done-fg); }

/* ── FORM CONTROLS ──────────────────────────────────────────────────────── */
.form-select {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-family: var(--font);
    font-size: 0.85rem;
    color: var(--text);
    outline: none;
    margin-bottom: 6px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}
.form-select:focus { border-color: var(--dark); }

.action-row { display: flex; gap: 6px; align-items: stretch; }
.action-row .form-select { margin-bottom: 0; flex: 1; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-weight: 500;
    font-size: 0.85rem;
    padding: 11px 16px;
    cursor: pointer;
    transition: opacity 0.15s;
    white-space: nowrap;
    letter-spacing: 0.01em;
}
.btn:active { opacity: 0.75; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-dark  { background: var(--dark);      color: var(--white); }
.btn-green { background: var(--secondary); color: var(--white); }
.btn-full  { width: 100%; text-align: center; display: block; margin-top: 8px; }
.btn-outline {
    background: var(--white);
    color: var(--dark);
    border: 1px solid var(--border);
}

/* ── STORE CARD ─────────────────────────────────────────────────────────── */
.store-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.count-chip {
    background: var(--dark);
    color: var(--white);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
}
.count-chip.zero {
    background: var(--bg);
    color: var(--muted);
}

/* ── RIDER CARD ─────────────────────────────────────────────────────────── */
.rider-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.rider-info { display: flex; flex-direction: column; gap: 2px; }
.rider-name { font-size: 0.88rem; font-weight: 500; color: var(--text); }
.rider-phone { font-size: 0.72rem; color: var(--accent); text-decoration: none; }
.rider-status-ok   { color: var(--secondary); font-weight: 500; font-size: 0.85rem; }
.rider-status-busy { color: var(--muted);     font-size: 0.85rem; }

/* ── REPORTS ─────────────────────────────────────────────────────────────── */
.report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.report-row:last-child { border-bottom: none; }
.report-row strong { font-size: 0.88rem; font-weight: 500; }
.report-row small  { font-size: 0.72rem; color: var(--muted); display: block; margin-top: 1px; }
.report-amount     { font-size: 0.88rem; font-weight: 500; color: var(--text); }
.report-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
}
.total-label  { font-size: 0.9rem; font-weight: 500; }
.total-amount { font-size: 1.3rem; font-weight: 500; color: var(--secondary); letter-spacing: -0.04em; }

/* ── BOTTOM NAV ─────────────────────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 68px;
    background: var(--white);
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    z-index: 100;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    cursor: pointer;
    color: #ccc;
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: relative;
    border: none;
    background: none;
    font-family: var(--font);
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.nav-item.active { color: var(--dark); }
.nav-icon { font-size: 1.3rem; line-height: 1; }
.nav-badge {
    position: absolute;
    top: 6px; right: 22%;
    background: var(--primary);
    color: white;
    font-size: 0.55rem;
    font-weight: 600;
    min-width: 16px; height: 16px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
}

/* ── LOGIN ───────────────────────────────────────────────────────────────── */
.login-page {
    background: var(--white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 40px 32px;
    max-width: 420px;
    margin: 0 auto;
}
.login-header { text-align: center; margin-bottom: 44px; }
.login-logo   { font-size: 2rem; font-weight: 600; letter-spacing: -0.05em; color: var(--dark); margin-bottom: 6px; }
.login-logo span { color: var(--primary); }
.login-sub    { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase; }

.login-form input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    font-family: var(--font);
    outline: none;
    color: var(--text);
    background: var(--bg);
    margin-bottom: 12px;
    transition: border-color 0.2s;
}
.login-form input:focus { border-color: var(--dark); background: var(--white); }
.login-form input::placeholder { color: #bbb; }

.login-error {
    color: var(--primary);
    font-size: 0.8rem;
    text-align: center;
    margin-bottom: 12px;
    min-height: 1.2em;
    line-height: 1.5;
    display: none;
}
.login-error.show { display: block; }

.login-diag {
    text-align: center;
    margin-top: 16px;
    font-size: 0.75rem;
    color: var(--muted);
    cursor: pointer;
    text-decoration: underline;
}

/* ── DIAGNOSTIC ─────────────────────────────────────────────────────────── */
.diag-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--bg);
    border-radius: 10px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
}
.diag-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
}
.diag-ok   .diag-icon { background: var(--done-bg);    color: var(--done-fg); }
.diag-fail .diag-icon { background: var(--pending-bg); color: var(--pending-fg); }
.diag-wait .diag-icon { background: var(--bg);         color: var(--muted); }
.diag-label   { font-size: 0.82rem; font-weight: 500; color: var(--dark); }
.diag-detail  { font-size: 0.72rem; color: var(--muted); margin-top: 1px; }
.diag-value   { font-size: 0.7rem;  font-family: monospace; margin-top: 3px; }
.diag-ok   .diag-value { color: var(--done-fg); }
.diag-fail .diag-value { color: var(--pending-fg); }

/* ── EMPTY STATE ─────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--muted);
}
.empty-icon  { font-size: 2.5rem; margin-bottom: 12px; }
.empty-text  { font-size: 0.9rem; }

/* ── SPINNER ─────────────────────────────────────────────────────────────── */
.spinner-wrap { text-align: center; padding: 32px; }
.spinner {
    display: inline-block;
    width: 28px; height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--dark);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── TOAST ───────────────────────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%; transform: translateX(-50%);
    background: var(--dark);
    color: var(--white);
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.82rem;
    font-weight: 500;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
    max-width: 90vw;
    text-align: center;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--primary); }

/* ── RESPONSIVE desktop max-width ───────────────────────────────────────── */
@media (min-width: 480px) {
    .app-shell, .login-page { max-width: 480px; margin: 0 auto; }
    .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); }
}

/* ── RIDER MODAL ─────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.5);
    z-index: 500; display: flex; align-items: flex-end;
    opacity: 0; transition: opacity 0.25s;
}
.modal-overlay.show { opacity: 1; }

.modal-sheet {
    background: var(--white); border-radius: 20px 20px 0 0;
    width: 100%; max-height: 88vh; overflow-y: auto;
    transform: translateY(100%); transition: transform 0.3s cubic-bezier(.4,0,.2,1);
    padding-bottom: 24px;
}
.modal-overlay.show .modal-sheet { transform: translateY(0); }

.modal-handle {
    width: 40px; height: 4px; background: var(--border);
    border-radius: 2px; margin: 12px auto 0;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}
.modal-title   { font-size: 1rem; font-weight: 600; color: var(--dark); letter-spacing: -0.03em; }
.modal-subtitle{ font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.modal-close   { background: var(--bg); border: none; font-size: 1rem; cursor: pointer; padding: 6px 10px; border-radius: 8px; color: var(--muted); }

.modal-body { padding: 14px 16px; }

/* Resumen semanal */
.week-summary {
    background: var(--dark); color: white;
    border-radius: 14px; padding: 16px;
    display: grid; grid-template-columns: 1fr 1fr;
    gap: 12px; margin-bottom: 16px;
}
.ws-item { display: flex; flex-direction: column; gap: 3px; }
.ws-label { font-size: 0.65rem; opacity: .65; text-transform: uppercase; letter-spacing: .05em; }
.ws-value { font-size: 1.4rem; font-weight: 600; letter-spacing: -0.04em; }
.ws-value.green { color: #4ade80; }
.ws-pay-date {
    grid-column: 1/-1;
    background: rgba(255,255,255,.1); border-radius: 8px;
    padding: 8px 12px; font-size: 0.8rem;
    display: flex; justify-content: space-between; align-items: center;
}

/* Detalle por día */
.day-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 9px 0; border-bottom: 1px solid var(--border);
    font-size: 0.85rem;
}
.day-row:last-child { border: none; }
.day-name  { color: var(--text); font-weight: 500; }
.day-count { color: var(--muted); font-size: 0.78rem; }
.day-earn  { color: var(--secondary); font-weight: 500; }

/* Historial de pagos */
.pay-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 0.82rem;
}
.pay-row:last-child { border: none; }
.pay-week  { color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.pay-amount{ color: var(--secondary); font-weight: 600; }

/* Botón pagar */
.btn-pay {
    width: 100%; padding: 14px; background: var(--secondary); color: white;
    border: none; border-radius: 10px; font-size: 0.9rem; font-weight: 500;
    font-family: var(--font); cursor: pointer; margin-top: 16px;
    transition: opacity 0.15s;
}
.btn-pay:active { opacity: .8; }
.btn-pay:disabled { opacity: .5; cursor: not-allowed; }

/* Rider card clickeable */
.rider-card { cursor: pointer; transition: border-color .15s; }
.rider-card:hover { border-color: var(--dark); }

.section-mini {
    font-size: 0.68rem; font-weight: 500; color: var(--muted);
    text-transform: uppercase; letter-spacing: .08em;
    margin: 14px 0 8px;
}
