/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f3f4f6;
    color: #1f2937;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.status-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
}

.connection-status {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    backdrop-filter: blur(10px);
}

.pending-count {
    background: #f59e0b;
    padding: 0.25rem 0.5rem;
    border-radius: 0.5rem;
    font-weight: 500;
}

/* Main Layout */
.main {
    max-width: 480px;
    margin: 0 auto;
    padding: 1rem;
    min-height: calc(100vh - 120px);
}

.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* Cards */
.card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
}

.card h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #1e3a8a;
}

.card p {
    color: #6b7280;
    margin-bottom: 1.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
    font-size: 0.875rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 48px;
    gap: 0.5rem;
    text-align: center;
    line-height: 1.2;
}

.btn-primary {
    background: #3b82f6;
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #6b7280;
    color: white;
}

.btn-secondary:hover {
    background: #4b5563;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover {
    background: #059669;
}

.btn-camera {
    background: #8b5cf6;
    color: white;
    width: 100%;
    margin-bottom: 0.5rem;
}

.btn-camera:hover {
    background: #7c3aed;
}

.btn-large {
    padding: 1rem 2rem;
    font-size: 1.125rem;
    width: 100%;
    margin-bottom: 0.75rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.form-actions .btn {
    flex: 1;
    min-width: 120px;
}

/* GPS Info */
.gps-info {
    padding: 0.75rem;
    background: #f3f4f6;
    border-radius: 0.5rem;
    border: 2px dashed #d1d5db;
    text-align: center;
    color: #6b7280;
    font-size: 0.875rem;
}

.gps-info.success {
    background: #ecfdf5;
    border-color: #10b981;
    color: #059669;
}

.gps-info.error {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}

/* Photo Preview */
.photo-preview {
    margin-top: 0.5rem;
}

.photo-preview img {
    width: 100%;
    max-width: 200px;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.photo-preview .remove-photo {
    display: block;
    margin-top: 0.5rem;
    color: #ef4444;
    font-size: 0.875rem;
    text-decoration: underline;
    cursor: pointer;
}

/* Product Counter */
.product-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.product-counter {
    background: #dbeafe;
    color: #1e40af;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Products List */
.products-list {
    margin-top: 2rem;
    margin-bottom: 2rem;
}

.product-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.product-item h4 {
    color: #1e3a8a;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.product-details {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.4;
}

.product-price {
    font-weight: 600;
    color: #059669;
    margin-top: 0.5rem;
}

/* Visit Actions */
.visit-actions {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
    margin-top: 1.5rem;
}

.visit-actions .btn {
    margin-bottom: 0.75rem;
}

/* History */
.history-list {
    max-height: 60vh;
    overflow-y: auto;
}

.history-item {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: #fafafa;
}

.history-item h4 {
    color: #1e3a8a;
    margin-bottom: 0.5rem;
}

.history-meta {
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.5rem;
}

.history-products {
    font-size: 0.875rem;
    color: #374151;
}

.no-data {
    text-align: center;
    color: #9ca3af;
    font-style: italic;
    padding: 2rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-overlay p {
    color: white;
    font-size: 1.125rem;
    font-weight: 500;
}

/* Success Animation */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(16, 185, 129, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 1001;
}

.success-overlay.show {
    display: flex;
}

.success-animation {
    width: 80px;
    height: 80px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #059669;
    margin-bottom: 1rem;
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.success-overlay p {
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
}

/* Camera Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1002;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    padding: 1rem;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
}

#cameraVideo {
    width: 100%;
    max-width: 300px;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.camera-controls {
    display: flex;
    gap: 0.75rem;
}

.camera-controls .btn {
    flex: 1;
}

/* Responsive Design */
@media (max-width: 480px) {
    .main {
        padding: 0.75rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .form-actions {
        flex-direction: column;
    }
    
    .form-actions .btn {
        width: 100%;
    }
    
    .product-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .product-counter {
        align-self: stretch;
        text-align: center;
    }
}

/* Dark mode support for cameras */
@media (prefers-color-scheme: dark) {
    .modal-content {
        background: #1f2937;
        color: white;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        border-width: 2px;
    }
}

/* Focus visible for better accessibility */
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}
/* GPS Toggle Switch */
.gps-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
}
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 28px;
}
.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}
input:checked + .toggle-slider {
    background-color: #10b981;
}
input:checked + .toggle-slider:before {
    transform: translateX(24px);
}
#gpsToggleLabel {
    font-size: 0.9em;
    color: #555;
}

/* Zone Picker */
.zone-section-label {
    font-size: 1rem !important;
    font-weight: 600 !important;
    color: #1e3a8a !important;
    margin-bottom: 0.75rem !important;
}

.zone-map-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 0.75rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.zone-picker {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.zone-card {
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.zone-card:active {
    transform: scale(0.98);
}

.zone-card.selected {
    border-color: var(--zone-color);
    background: var(--zone-bg);
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

.zone-card-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.zone-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.zone-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1f2937;
    flex: 1;
}

.zone-check {
    display: none;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #10b981;
    color: white;
    font-size: 0.85rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.zone-card.selected .zone-check {
    display: inline-flex;
}

.zone-neighborhoods {
    margin-top: 0.375rem;
    margin-left: 40px;
    font-size: 0.8rem;
    color: #6b7280;
    line-height: 1.4;
}

.zone-validation-error {
    margin-top: 0.5rem;
    color: #ef4444;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Address Field */
.address-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.address-field-wrapper input {
    width: 100%;
    padding: 0.75rem;
    padding-right: 2.5rem;
    border: 2px solid #d1d5db;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f9fafb;
}

.address-field-wrapper input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    background: white;
}

.address-spinner {
    position: absolute;
    right: 10px;
    font-size: 1rem;
    animation: spin 1s linear infinite;
}

/* ==================== DASHBOARD V2 ADDITIONS ==================== */
/* Channel Filter Bar */
.channel-filter-bar{display:flex;gap:8px;padding:10px 0;flex-wrap:wrap;align-items:center;margin-bottom:12px}
.ch-btn{padding:6px 16px;border:2px solid #2D6A4F;border-radius:20px;cursor:pointer;font-size:.82rem;font-weight:600;background:#fff;color:#2D6A4F;transition:all .2s}
.ch-btn.active{background:#2D6A4F;color:#fff}
.ch-btn:hover{background:#40916C;color:#fff;border-color:#40916C}
/* Latest Intel Card */
.intel-card{background:#f0faf4;border-left:4px solid #2D6A4F;border-radius:10px;padding:16px 20px;margin-bottom:16px;box-shadow:0 2px 8px rgba(0,0,0,.06)}
.intel-card h3{color:#1B4332;font-size:1rem;margin-bottom:8px}
.intel-card ul{padding-left:16px;font-size:.85rem;line-height:1.8;color:#333}
.intel-card .intel-link{display:inline-block;margin-top:10px;color:#2D6A4F;font-weight:600;font-size:.82rem;cursor:pointer;text-decoration:underline}
/* KPI enhancements */
.kpi-range{font-size:.72rem;color:#666;margin-top:2px}
.kpi-wow{font-size:.8rem;font-weight:700;margin-top:3px}
.kpi-wow.up{color:#16a34a}.kpi-wow.down{color:#dc2626}.kpi-wow.flat{color:#888}
.kpi-zone-callout{font-size:.68rem;color:#555;margin-top:3px;font-style:italic}
/* Store Notes Feed */
.note-feed{display:flex;flex-direction:column;gap:10px}
.note-card{background:#fff;border:1px solid #e0e0e0;border-radius:8px;padding:12px 14px;font-size:.83rem}
.note-card .note-meta{font-size:.75rem;color:#888;margin-bottom:5px}
.note-card .note-text{color:#222;line-height:1.6;margin-bottom:8px}
.note-tags{display:flex;flex-wrap:wrap;gap:4px}
.note-tag{display:inline-block;padding:2px 8px;border-radius:10px;font-size:.68rem;font-weight:600}
.tag-competitive{background:#fde8e8;color:#c0392b}
.tag-pricing{background:#fef9e7;color:#b7950b}
.tag-supply{background:#e8f4fd;color:#1a5276}
.tag-credit{background:#eafaf1;color:#1e8449}
.tag-relationship{background:#f4ecf7;color:#7d3c98}
.tag-quality{background:#fdf2e9;color:#ca6f1e}
/* Coverage bar */
.coverage-bar{background:#fff;border-radius:8px;padding:12px 16px;margin-bottom:12px;box-shadow:0 2px 8px rgba(0,0,0,.06);display:flex;flex-wrap:wrap;gap:12px;align-items:center;font-size:.82rem}
.coverage-stat{font-weight:700;color:#2D6A4F}
/* Upload card */
.upload-card-v2{background:#f9f9f9;border:2px dashed #c0c0c0;border-radius:10px;padding:20px;margin-bottom:16px}
.upload-preview{background:#e8f5e9;border-radius:6px;padding:10px;font-size:.82rem;margin-top:10px;display:none}
.saved-report-card{background:#fff;border:1px solid #e0e0e0;border-radius:8px;padding:12px;margin-bottom:8px;font-size:.82rem;display:flex;justify-content:space-between;align-items:center}
/* Floating note button */
.floating-note-btn{position:fixed;bottom:24px;right:24px;background:#2D6A4F;color:#fff;border:none;border-radius:50%;width:52px;height:52px;font-size:1.3rem;cursor:pointer;box-shadow:0 4px 12px rgba(0,0,0,.25);z-index:1000;display:none}
.floating-note-btn.visible{display:flex;align-items:center;justify-content:center}
/* Submission summary */
.submit-summary{background:#ecfdf5;border:1px solid #6ee7b7;border-radius:10px;padding:16px;margin-top:12px;font-size:.9rem}
.submit-summary h3{color:#065f46;margin-bottom:8px;font-size:1rem}
.submit-summary .stat-row{display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px solid #d1fae5}
.submit-summary .stat-row:last-child{border:none}
