/* frontend/css/style.css — Mobile-first houseboat management app */

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

:root {
  --primary: #0a7c5c;
  --primary-light: #e0f4ee;
  --primary-dark: #085c44;
  --accent: #f5a623;
  --danger: #e53935;
  --success: #2e7d32;
  --warning: #f57c00;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f4f7f6;
  --white: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --nav-height: 64px;
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 15px; line-height: 1.5; }

/* Loading spinner */
#loader { display: none; position: fixed; inset: 0; background: rgba(255,255,255,0.7); z-index: 9999; align-items: center; justify-content: center; }
#loader.active { display: flex; }
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast notifications */
.toast { position: fixed; bottom: calc(var(--nav-height) + 16px); left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: white; padding: 10px 20px; border-radius: 24px; font-size: 14px; opacity: 0; transition: all 0.3s; z-index: 9998; white-space: nowrap; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-error { background: var(--danger); }
.toast.toast-success { background: var(--success); }
.toast.toast-warning { background: var(--warning); }

/* Auth screen */
#auth-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; background: linear-gradient(160deg, var(--primary) 0%, var(--primary-dark) 100%); }
.auth-logo { width: 80px; height: 80px; border-radius: 20px; background: white; display: flex; align-items: center; justify-content: center; margin-bottom: 16px; font-size: 36px; }
.auth-title { color: white; font-size: 24px; font-weight: 700; margin-bottom: 4px; text-align: center; }
.auth-sub { color: rgba(255,255,255,0.8); font-size: 14px; margin-bottom: 32px; text-align: center; }
.auth-card { background: white; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 380px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tab { flex: 1; padding: 8px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; cursor: pointer; background: white; color: var(--text-muted); transition: all 0.2s; text-align: center; }
.auth-tab.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.social-btn { width: 100%; padding: 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: white; display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; font-weight: 500; margin-bottom: 10px; transition: border-color 0.2s; }
.social-btn:hover { border-color: var(--primary); }
.social-btn img { width: 20px; height: 20px; }
.divider { text-align: center; color: var(--text-muted); font-size: 12px; margin: 16px 0; position: relative; }
.divider::before, .divider::after { content: ''; position: absolute; top: 50%; width: 42%; height: 1px; background: var(--border); }
.divider::before { left: 0; } .divider::after { right: 0; }

/* Main app layout */
#app { display: none; min-height: 100vh; padding-bottom: var(--nav-height); }
#app.visible { display: block; }

/* Top header */
.app-header { background: var(--primary); color: white; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 100; }
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; background: rgba(255,255,255,0.2); display: flex; align-items: center; justify-content: center; font-size: 18px; overflow: hidden; }
.header-logo img { width: 100%; height: 100%; object-fit: cover; }
.header-boat-name { font-weight: 700; font-size: 16px; }
.header-greeting { font-size: 12px; opacity: 0.8; }

/* Bottom nav */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: white; border-top: 1px solid var(--border); display: flex; height: var(--nav-height); z-index: 100; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; color: var(--text-muted); transition: color 0.2s; font-size: 10px; font-weight: 500; padding: 6px 4px; border: none; background: none; }
.nav-item.active { color: var(--primary); }
.nav-item svg { width: 22px; height: 22px; }

/* Page container */
.page { display: none; padding: 16px; }
.page.active { display: block; }

/* Cards */
.card { background: white; border-radius: var(--radius); padding: 16px; box-shadow: var(--card-shadow); margin-bottom: 12px; }
.card-title { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.card-value { font-size: 22px; font-weight: 700; color: var(--text); }

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card { background: white; border-radius: var(--radius); padding: 14px; box-shadow: var(--card-shadow); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 20px; font-weight: 700; }
.stat-card.primary { background: var(--primary); }
.stat-card.primary .stat-label, .stat-card.primary .stat-value { color: white; }

/* Buttons */
.btn { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon { padding: 8px; border-radius: 8px; }

/* Form elements */
.form-group { margin-bottom: 14px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-muted); display: block; margin-bottom: 5px; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 11px 14px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 15px; background: white; color: var(--text); transition: border-color 0.2s; appearance: none; -webkit-appearance: none; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--primary); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Sections */
.section-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }

/* List items */
.list-item { background: white; border-radius: var(--radius); padding: 14px; box-shadow: var(--card-shadow); margin-bottom: 10px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: transform 0.15s; }
.list-item:active { transform: scale(0.98); }
.list-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--primary-light); color: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.list-info { flex: 1; min-width: 0; }
.list-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 13px; color: var(--text-muted); }
.list-right { text-align: right; flex-shrink: 0; }

/* Badges */
.badge { display: inline-flex; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-success { background: #e8f5e9; color: var(--success); }
.badge-warning { background: #fff3e0; color: var(--warning); }
.badge-danger { background: #fce4e4; color: var(--danger); }
.badge-info { background: #e3f2fd; color: #1565c0; }
.badge-neutral { background: var(--bg); color: var(--text-muted); }

/* Bottom sheet modal */
.sheet-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200; opacity: 0; pointer-events: none; transition: opacity 0.3s; }
.sheet-overlay.active { opacity: 1; pointer-events: all; }
.sheet { position: fixed; bottom: 0; left: 0; right: 0; background: white; border-radius: 20px 20px 0 0; z-index: 201; padding: 0 0 32px; max-height: 92vh; overflow-y: auto; transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.4,0,0.2,1); }
.sheet.active { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: 12px auto 16px; }
.sheet-title { font-size: 18px; font-weight: 700; padding: 0 20px 16px; border-bottom: 1px solid var(--border); }
.sheet-body { padding: 16px 20px; }
.sheet-actions { padding: 0 20px; display: flex; gap: 10px; }

/* Calendar */
.cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-month { font-size: 17px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-day-name { text-align: center; font-size: 11px; font-weight: 600; color: var(--text-muted); padding: 4px 0; }
.cal-cell { aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; position: relative; transition: background 0.15s; }
.cal-cell.today { background: var(--primary-light); color: var(--primary); font-weight: 700; }
.cal-cell.booked { background: var(--primary); color: white; }
.cal-cell.available { color: var(--text); }
.cal-cell.empty { pointer-events: none; }
.cal-cell.prev-month { color: var(--border); }
.booking-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); position: absolute; bottom: 2px; }

/* Invoice print area */
.invoice-print { display: none; }
@media print {
  body > *:not(.invoice-print) { display: none !important; }
  .invoice-print { display: block !important; padding: 20px; }
}

/* Tabs */
.tabs { display: flex; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 16px; }
.tab { flex: 1; padding: 8px 4px; text-align: center; border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--text-muted); transition: all 0.2s; border: none; background: none; }
.tab.active { background: white; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Search */
.search-bar { position: relative; margin-bottom: 14px; }
.search-bar input { padding-left: 40px; }
.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }

/* Empty state */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 20px; }

/* FAB */
.fab { position: fixed; bottom: calc(var(--nav-height) + 16px); right: 16px; width: 52px; height: 52px; border-radius: 50%; background: var(--primary); color: white; border: none; font-size: 24px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 12px rgba(10,124,92,0.4); cursor: pointer; z-index: 50; transition: transform 0.2s; }
.fab:active { transform: scale(0.92); }

/* Pending payment highlight */
.overdue { border-left: 3px solid var(--danger); }
.due-soon { border-left: 3px solid var(--warning); }

/* Report charts placeholder */
.chart-bar-wrap { margin: 12px 0; }
.chart-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.chart-bar-label { width: 50px; font-size: 12px; color: var(--text-muted); text-align: right; }
.chart-bar-bg { flex: 1; height: 22px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--primary); border-radius: 4px; display: flex; align-items: center; padding-left: 8px; font-size: 11px; color: white; font-weight: 600; transition: width 0.8s ease; }

/* OTP input */
.otp-inputs { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.otp-input { width: 46px; height: 54px; border: 2px solid var(--border); border-radius: var(--radius-sm); font-size: 22px; font-weight: 700; text-align: center; color: var(--text); transition: border-color 0.2s; }
.otp-input:focus { outline: none; border-color: var(--primary); }

/* Share buttons */
.share-btns { display: flex; gap: 10px; margin-top: 12px; }
.share-btn { flex: 1; padding: 12px 8px; border-radius: var(--radius-sm); border: none; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.share-wa { background: #25D366; color: white; }
.share-mail { background: #EA4335; color: white; }
.share-print { background: #4285F4; color: white; }

@media (min-width: 480px) {
  .page { max-width: 500px; margin: 0 auto; }
  .app-header { max-width: 500px; margin: 0 auto; }
}
