/* NCRTC Traffic Survey - Mobile-first light theme */

:root {
    --primary: #e85d04;
    --primary-dark: #d00000;
    --primary-light: #f48c06;
    --bg: #f8f9fa;
    --card: #ffffff;
    --text: #212529;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --success: #198754;
    --danger: #dc3545;
    --warning: #ffc107;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* Layout */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 16px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin-bottom: 16px;
}

/* Header */
.app-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-header h1 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
}

.app-header .user-info {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
    text-decoration: none;
    line-height: 1.2;
}

.btn:active {
    opacity: 0.85;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: #e9ecef;
    color: var(--text);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 14px 20px;
    font-size: 1.05rem;
}

/* Forms */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    background: #fff;
    color: var(--text);
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(232, 93, 4, 0.15);
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c757d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 500px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Status badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-success { background: #d1e7dd; color: #0f5132; }
.badge-warning { background: #fff3cd; color: #664d03; }
.badge-danger  { background: #f8d7da; color: #842029; }
.badge-info    { background: #cff4fc; color: #055160; }

/* Offline indicator */
#offline-bar {
    display: none;
    background: #664d03;
    color: #fff;
    text-align: center;
    padding: 8px;
    font-size: 0.9rem;
    position: sticky;
    top: 0;
    z-index: 200;
}

#offline-bar.show {
    display: block;
}

#pending-badge {
    background: var(--danger);
    color: #fff;
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 0.75rem;
    margin-left: 6px;
}

/* Tables */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #f1f3f5;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}

tr:hover td {
    background: #f8f9fa;
}

/* Toggle switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
    display: inline-block;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ced4da;
    border-radius: 24px;
    transition: 0.2s;
}

.toggle .slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
}

.toggle input:checked + .slider {
    background: var(--primary);
}

.toggle input:checked + .slider:before {
    transform: translateX(20px);
}

/* Landing page */
.hero {
    text-align: center;
    padding: 48px 16px 32px;
}

.hero h1 {
    font-size: 1.6rem;
    margin-bottom: 8px;
    color: var(--primary);
}

.hero p {
    color: var(--text-muted);
    margin-bottom: 24px;
}

.survey-cards {
    display: grid;
    gap: 16px;
    max-width: 500px;
    margin: 0 auto;
}

.survey-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    text-align: center;
    border: 2px solid transparent;
    transition: border-color 0.15s;
}

.survey-card:active {
    border-color: var(--primary);
}

.survey-card h3 {
    margin-bottom: 6px;
    font-size: 1.1rem;
}

.survey-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

/* Trip list in survey form */
.trip-item {
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 10px;
    position: relative;
}

.trip-item .trip-num {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.trip-item .remove-trip {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    color: var(--danger);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px;
}

/* Admin filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}

.filters .btn.active {
    background: var(--primary);
    color: #fff;
}

.search-box {
    flex: 1;
    min-width: 180px;
}

/* Login */
.login-box {
    max-width: 380px;
    margin: 60px auto;
    padding: 24px;
}

.login-box h2 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.95rem;
}

.alert-success { background: #d1e7dd; color: #0f5132; }
.alert-danger  { background: #f8d7da; color: #842029; }
.alert-warning { background: #fff3cd; color: #664d03; }
.alert-info    { background: #cff4fc; color: #055160; }

/* Utility */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.d-flex { display: flex; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.w-100 { width: 100%; }

/* Large touch targets for low-end phones */
@media (max-width: 600px) {
    .btn {
        min-height: 44px;
    }
    
    .form-control {
        min-height: 44px;
        font-size: 16px; /* prevents zoom on iOS */
    }
    
    th, td {
        padding: 12px 8px;
    }
}