/**
 * INS Distributor App - Mobile-First PWA Styles
 * Optimized for mobile devices with touch-friendly interface
 */

/* ========================================
   CSS Variables & Theme Colors
   ======================================== */
:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #06b6d4;
    --purple: #8b5cf6;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --header-height: 60px;
    --bottom-nav-height: 60px;
    
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Reset & Base Styles
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.ins-app-body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--bg-secondary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Remove default WordPress admin bar */
body.ins-app-body {
    margin-top: 0 !important;
}

#wpadminbar {
    display: none !important;
}

/* ========================================
   App Header
   ======================================== */
.ins-app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
}

.header-content .logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-content .logo .dashicons {
    font-size: 28px;
    width: 28px;
    height: 28px;
}

.header-content .logo h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.menu-btn .dashicons {
    font-size: 24px;
}

/* ========================================
   Side Menu
   ======================================== */
.ins-app-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ins-app-menu.active {
    pointer-events: all;
    opacity: 1;
}

.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ins-app-menu.active .menu-overlay {
    opacity: 1;
}

.menu-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: white;
    box-shadow: var(--shadow-lg);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.ins-app-menu.active .menu-content {
    transform: translateX(0);
}

.menu-header {
    background: var(--primary);
    color: white;
    padding: 20px;
    position: relative;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.user-details p {
    font-size: 13px;
    opacity: 0.9;
    margin: 0;
}

.menu-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.menu-nav {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.menu-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition);
}

.menu-nav a:hover {
    background: var(--bg-tertiary);
}

.menu-nav a.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    border-left: 3px solid var(--primary);
}

.menu-nav a .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 8px 20px;
}

.logout-link {
    color: var(--danger) !important;
}

/* ========================================
   Main Content Area
   ======================================== */
.ins-app-main {
    padding-top: var(--header-height);
    padding-bottom: var(--bottom-nav-height);
    min-height: 100vh;
}

.view-login .ins-app-main {
    padding: 0;
    padding-bottom: 0;
}

/* ========================================
   Login Page
   ======================================== */
.app-login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-logo {
    text-align: center;
    padding: 40px 20px 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.login-logo .dashicons {
    font-size: 60px;
    width: 60px;
    height: 60px;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 4px 0;
}

.login-logo p {
    font-size: 14px;
    opacity: 0.9;
    margin: 0;
}

.login-error {
    background: #fee2e2;
    color: var(--danger);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.login-form {
    padding: 30px 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-group label .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    color: var(--primary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 16px;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.password-input-wrapper {
    position: relative;
}

.password-input-wrapper .form-input {
    padding-right: 48px;
}

.toggle-password {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
}

.toggle-password:hover {
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.checkbox-group {
    margin-bottom: 24px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-login:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.login-footer {
    text-align: center;
    padding: 20px;
    background: var(--bg-tertiary);
    font-size: 12px;
    color: var(--text-tertiary);
}

/* ========================================
   Dashboard
   ======================================== */
.app-dashboard {
    padding: 20px;
}

.welcome-section {
    margin-bottom: 24px;
}

.welcome-section h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px 0;
}

.welcome-date {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:active {
    transform: scale(0.98);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-primary .stat-icon {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.stat-success .stat-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stat-warning .stat-icon {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stat-icon .dashicons {
    font-size: 24px;
}

.stat-info h3 {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 2px 0;
}

.stat-info p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 24px 0 16px 0;
}

.section-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.view-all {
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.quick-actions {
    display: grid;
    gap: 12px;
    margin-bottom: 28px;
}

.action-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.action-card:active {
    transform: scale(0.98);
}

.action-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.action-primary .action-icon {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
}

.action-success .action-icon {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.action-info .action-icon {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

.action-purple .action-icon {
    background: rgba(139, 92, 246, 0.1);
    color: var(--purple);
}

.action-icon .dashicons {
    font-size: 24px;
}

.action-info {
    flex: 1;
}

.action-info h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 2px 0;
}

.action-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
}

.action-card > .dashicons-arrow-right-alt2 {
    color: var(--text-tertiary);
    font-size: 20px;
}

.activity-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.activity-item {
    background: white;
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-icon .dashicons {
    font-size: 20px;
}

.activity-info {
    flex: 1;
    min-width: 0;
}

.activity-info h4 {
    font-size: 15px;
    font-weight: 600;
    margin: 0 0 4px 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.activity-meta {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 4px;
}

.activity-meta .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.activity-purpose {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0;
}

.rating-badge {
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
}

.rating-high {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.rating-medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.rating-low {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* ========================================
   Bottom Navigation
   ======================================== */
.ins-app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 999;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    text-decoration: none;
    color: var(--text-tertiary);
    transition: var(--transition);
}

.nav-item.active {
    color: var(--primary);
}

.nav-item .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.nav-label {
    font-size: 11px;
    font-weight: 500;
}

/* ========================================
   Loading & Toast
   ======================================== */
.ins-app-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 9999;
}

.ins-app-loading.active {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.ins-app-loading p {
    color: white;
    font-size: 16px;
}

.ins-app-toast {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #323232;
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9998;
    max-width: calc(100% - 40px);
}

.ins-app-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ========================================
   Placeholder Views
   ======================================== */
.app-view {
    padding: 20px;
}

.view-header {
    margin-bottom: 20px;
}

.view-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
}

.coming-soon {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-tertiary);
}

.coming-soon .dashicons {
    font-size: 64px;
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.coming-soon p {
    font-size: 16px;
    margin: 0;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .user-name {
        display: none;
    }
}

@media (min-width: 768px) {
    .ins-app-bottom-nav {
        display: none;
    }
    
    .ins-app-main {
        padding-bottom: 20px;
    }
    
    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ========================================
   Animations & Interactions
   ======================================== */
@media (hover: hover) {
    .stat-card:hover,
    .action-card:hover,
    .activity-item:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }
}

/* Touch feedback */
.stat-card:active,
.action-card:active,
.btn-login:active,
.nav-item:active {
    transform: scale(0.97);
}

/* ========================================
   Visit Form Styles
   ======================================== */
.app-form {
    padding-bottom: 80px;
}

.form-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 20px;
    padding-right: 40px;
    max-height: 200px;
    overflow-y: auto;
}

/* Ensure select options are visible */
select.form-control option {
    padding: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Dealer Type Toggle */
.dealer-type-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.toggle-btn {
    flex: 1;
    padding: 10px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.toggle-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.toggle-btn:active {
    transform: scale(0.97);
}

.dealer-form {
    display: none;
}

.dealer-form.active {
    display: block;
}

/* Rating Slider */
.rating-container {
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.rating-slider {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #ef4444, #f59e0b, #10b981);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.rating-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.rating-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: white;
    border: 3px solid var(--primary);
    cursor: pointer;
    box-shadow: var(--shadow-md);
}

.rating-display {
    text-align: center;
    margin: 12px 0 8px;
}

#rating-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
}

.rating-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Camera Section */
.camera-section {
    text-align: center;
}

#capture-photo-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.photo-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.photo-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 1;
}

.photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-item .remove-photo {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
}

/* Location Section */
.location-section {
    text-align: center;
}

#get-location-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.location-status {
    margin-top: 12px;
    padding: 10px;
    border-radius: var(--radius-md);
    font-size: 14px;
}

.location-status.loading {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

.location-status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.location-status.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.location-display {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    text-align: left;
}

.location-coords {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Order Details */
.order-details {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 4px solid var(--success);
}

/* Form Actions */
.form-actions {
    margin-top: 24px;
    margin-bottom: calc(var(--bottom-nav-height) + 24px);
    padding: 0 16px;
}

.btn-block {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
}

/* Loading State */
.btn-primary.loading {
    opacity: 0.7;
    pointer-events: none;
}

.btn-primary.loading::after {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    display: inline-block;
    margin-left: 8px;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Visits List Styles
   ======================================== */
.filters-section {
    margin-bottom: 16px;
}

.filters-form {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-lg);
    margin-top: 12px;
    box-shadow: var(--shadow-sm);
}

.filter-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.visits-summary {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.visits-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.visit-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.visit-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.visit-dealer h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.dealer-person {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.rating-badge {
    padding: 4px 8px;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.visit-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.visit-feedback p {
    margin: 0;
    color: var(--text-primary);
    line-height: 1.5;
}

.visit-photos-count, .follow-up-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    font-size: 12px;
    margin-top: 8px;
}

.follow-up-badge {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.visit-expand-btn {
    width: 100%;
    margin-top: 12px;
    padding: 8px;
    background: var(--bg-secondary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.visit-details {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.details-section {
    margin-bottom: 16px;
}

.details-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}

.details-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
}

.photo-thumb img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    margin-bottom: 80px;
}

.page-link {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.page-info {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========================================
   Dealers Directory Styles
   ======================================== */
.search-section {
    margin-bottom: 16px;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box .dashicons {
    position: absolute;
    left: 12px;
    color: var(--text-tertiary);
}

.search-box input {
    width: 100%;
    padding: 12px 12px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 16px;
}

.dealers-count {
    margin-bottom: 16px;
    color: var(--text-secondary);
}

.dealers-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 80px;
}

.dealer-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-sm);
}

.dealer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.dealer-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.dealer-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.dealer-status.active {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.dealer-status.prospect {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.dealer-info {
    margin-bottom: 12px;
}

.dealer-info p {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 6px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.dealer-stats {
    display: flex;
    gap: 16px;
    padding: 12px 0;
    margin: 12px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.stat-item {
    flex: 1;
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ========================================
   Statistics Dashboard Styles
   ======================================== */
.stat-section {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.stat-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.districts-list, .top-dealers-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.district-item, .top-dealer-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.district-name, .dealer-name {
    font-weight: 500;
    color: var(--text-primary);
}

.district-stats, .visit-count {
    font-size: 13px;
    color: var(--text-secondary);
}

.top-dealer-item {
    gap: 12px;
}

.rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}

.dealer-name {
    flex: 1;
}

canvas {
    max-height: 200px;
}

