/* ============================================
   Aqua Lawn Field Service PWA — Mobile-First CSS
   ============================================ */

:root {
    --al-green: #1a5f2a;
    --al-green-light: #2d8a42;
    --al-green-pale: #e8f5e9;
    --al-blue: #2884D6;
    --al-blue-light: #e3f2fd;

    --status-pending: #f59e0b;
    --status-active: #3b82f6;
    --status-complete: #22c55e;
    --status-incomplete: #ef4444;

    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);

    --top-bar-height: 52px;
    --bottom-nav-height: 60px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ---- Offline Banner ---- */
.offline-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 6px 16px;
    background: var(--status-pending);
    color: #1a1a1a;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}
.offline-banner.hidden { display: none; }

/* ---- Top Bar ---- */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--top-bar-height);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--al-green);
    color: white;
    box-shadow: var(--shadow-md);
}
.top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 4px;
}
.app-title {
    font-size: 16px;
    font-weight: 600;
}
.top-bar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sync-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    font-size: 12px;
    font-weight: 700;
    color: white;
    background: var(--status-pending);
    border-radius: 11px;
}
.sync-badge.hidden { display: none; }
.connection-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.connection-dot.online { background: #4ade80; }
.connection-dot.offline { background: #ef4444; }

/* ---- Main Content ---- */
.app-content {
    margin-top: var(--top-bar-height);
    margin-bottom: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    padding: 12px;
    min-height: calc(100vh - var(--top-bar-height) - var(--bottom-nav-height));
}

/* ---- Bottom Navigation ---- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-area-bottom));
    padding-bottom: var(--safe-area-bottom);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: white;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
}
.bottom-nav.hidden { display: none; }
.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 16px;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    min-height: 44px;
    min-width: 64px;
}
.nav-btn.active {
    color: var(--al-green);
}
.nav-btn svg {
    width: 24px;
    height: 24px;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* ---- Work Order Cards ---- */
.wo-card {
    position: relative;
    cursor: pointer;
    transition: box-shadow 0.15s;
}
.wo-card:active {
    box-shadow: var(--shadow-md);
}
.wo-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}
.wo-customer {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-primary);
}
.wo-status {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}
.wo-status.pending { background: #fef3c7; color: #92400e; }
.wo-status.active { background: #dbeafe; color: #1e40af; }
.wo-status.complete { background: #dcfce7; color: #166534; }
.wo-status.incomplete { background: #fee2e2; color: #991b1b; }
.wo-address {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.wo-service {
    font-size: 13px;
    color: var(--text-muted);
}
.wo-time {
    font-size: 13px;
    font-weight: 500;
    color: var(--al-blue);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s;
}
.btn:active { opacity: 0.8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--al-green); color: white; }
.btn-danger { background: var(--status-incomplete); color: white; }
.btn-secondary { background: var(--bg-secondary); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-blue { background: var(--al-blue); color: white; }
.btn-full { width: 100%; }
.btn-lg { padding: 16px 32px; font-size: 18px; min-height: 56px; }

/* ---- Time In/Out Buttons ---- */
.time-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 16px 0;
}

/* ---- Form Fields ---- */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 16px;
    background: white;
    color: var(--text-primary);
    -webkit-appearance: none;
}
.form-input:focus {
    outline: none;
    border-color: var(--al-green);
    box-shadow: 0 0 0 3px rgba(26,95,42,0.15);
}
.form-input::placeholder { color: var(--text-muted); }

/* ---- Login Screen ---- */
.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--top-bar-height) - 24px);
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 360px;
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .logo-text {
    font-size: 28px;
    font-weight: 800;
    color: var(--al-green);
}
.login-logo .logo-sub {
    font-size: 14px;
    color: var(--text-secondary);
}
.login-error {
    padding: 10px 14px;
    margin-bottom: 16px;
    border-radius: 8px;
    background: #fee2e2;
    color: #991b1b;
    font-size: 14px;
}
.login-error.hidden { display: none; }

/* ---- Section Headers ---- */
.section-header {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--al-green-pale);
}

/* ---- Special Needs Box ---- */
.special-needs {
    padding: 10px 14px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    font-size: 14px;
    color: #9a3412;
    margin-bottom: 12px;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}

/* ---- Loading Spinner ---- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Utility ---- */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
