/* ===================================
   Salesman Route Manager - CSS
   Mobile-First Design
   =================================== */

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

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --success-color: #16a34a;
    --warning-color: #ea580c;
    --danger-color: #dc2626;
    --pending-color: #6b7280;
    --bg-color: #f3f4f6;
    --card-bg: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    padding-bottom: 20px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

header h1 {
    font-size: 24px;
    margin-bottom: 5px;
    font-weight: 700;
}

header .subtitle {
    font-size: 14px;
    opacity: 0.9;
}

.back-link {
    display: inline-block;
    color: white;
    text-decoration: none;
    font-size: 14px;
    margin-bottom: 10px;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.back-link:hover {
    opacity: 1;
}

/* Card Styles */
.filter-card,
.detail-card,
.outlet-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

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

label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.label-icon {
    margin-right: 5px;
}

select,
input[type="tel"],
textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: white;
}

select {
    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='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
}

select:focus,
input[type="tel"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* Button Styles */
.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 14px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    font-family: inherit;
}

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

.btn-primary:hover,
.btn-primary:active {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover,
.btn-secondary:active {
    background: var(--bg-color);
}

.btn-block {
    width: 100%;
    display: block;
}

/* Stats Card */
.stats-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    text-align: center;
}

.stat {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-success .stat-number {
    color: var(--success-color);
}

.stat-warning .stat-number {
    color: var(--warning-color);
}

.stat-pending .stat-number {
    color: var(--pending-color);
}

.stat-info .stat-number {
    color: #1e40af;
}

/* Phone Warning Box */
.phone-warning {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    color: #92400e;
    padding: 10px 12px;
    margin: 10px 0;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

/* Outlet Card */
.outlet-card {
    border-left: 4px solid var(--pending-color);
}

/* Location Group Styles */
.location-group {
    margin-bottom: 30px;
}

.location-header {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 15px 20px;
    border-radius: 12px 12px 0 0;
    border-left: 4px solid var(--primary-color);
    margin-bottom: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.location-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-subtitle {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.location-count {
    background: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.outlets-list {
    background: white;
    border-radius: 0 0 12px 12px;
    padding: 10px;
}

.location-group .outlet-card {
    margin-bottom: 15px;
}

.location-group .outlet-card:last-child {
    margin-bottom: 0;
}

.outlet-card.status-completed,
.outlet-card.status-outlet-created {
    border-left-color: var(--success-color);
    background: #f0fdf4;
}

.outlet-card.status-outlet-not-exist {
    border-left-color: var(--danger-color);
    background: #fef2f2;
}

.outlet-card.status-revisit-needed {
    border-left-color: var(--warning-color);
    background: #fff7ed;
}

.outlet-card.status-pending {
    border-left-color: var(--pending-color);
}

.outlet-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.outlet-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
    margin-right: 10px;
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-badge.status-completed,
.status-badge.status-outlet-created {
    background: #dcfce7;
    color: #166534;
}

.status-badge.status-pending {
    background: #f3f4f6;
    color: #4b5563;
}

.status-badge.status-revisit-needed {
    background: #fed7aa;
    color: #9a3412;
}

.status-badge.status-customer-created {
    background: #dbeafe;
    color: #1e40af;
}

.status-badge.status-outlet-not-exist,
.status-badge.status-outlet-closed {
    background: #fee2e2;
    color: #991b1b;
}

/* Outlet Info */
.outlet-info {
    margin-bottom: 15px;
}

.outlet-info p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.outlet-address {
    font-weight: 500;
    color: var(--text-primary);
}

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

.outlet-date {
    font-size: 12px;
    font-style: italic;
}

/* Outlet Actions */
.outlet-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 15px;
}

.outlet-actions .btn-primary,
.outlet-actions .btn-secondary {
    padding: 12px 16px;
    font-size: 14px;
}

/* Detail Rows */
.detail-card h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
    margin-right: 15px;
}

.detail-row span:last-child {
    text-align: right;
    color: var(--text-primary);
    font-size: 14px;
}

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

/* Alerts */
.alert {
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 14px;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border-left: 4px solid #f59e0b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border-left: 4px solid #16a34a;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-left: 4px solid #dc2626;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state p:first-child {
    font-size: 48px;
    margin-bottom: 10px;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.app-footer {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 20px;
    text-align: center;
    margin-top: 40px;
    border-top: 3px solid var(--primary-color);
    border-radius: 12px 12px 0 0;
}

.app-footer p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.app-footer .footer-credit {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.app-footer .footer-year {
    font-size: 13px;
    color: var(--text-secondary);
}

.app-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.app-footer a:hover {
    text-decoration: underline;
}

/* ===================================
   Sales Recording Popup Styles
   =================================== */

.sales-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.sales-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.sales-popup-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.sales-header {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    padding: 20px;
    border-radius: 16px 16px 0 0;
    text-align: center;
}

.sales-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.outlet-info-header {
    margin: 10px 0 0 0;
    font-size: 14px;
    opacity: 0.95;
}

.sales-body {
    padding: 25px 20px;
}

.outlet-info-summary {
    text-align: center;
    margin-bottom: 25px;
    padding: 15px;
    background: var(--bg-color);
    border-radius: 8px;
}

.outlet-name-summary {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 5px 0;
}

.outlet-phone-summary {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0;
}

.sales-question {
    font-size: 16px;
    font-weight: 500;
    text-align: center;
    margin: 20px 0 30px 0;
    color: var(--text-primary);
}

.sales-instruction {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 0 0 20px 0;
    text-align: center;
}

.sales-buttons {
    display: flex;
    gap: 12px;
    margin-top: 25px;
}

.sales-buttons button {
    flex: 1;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
}

/* Products Container */
.products-container {
    max-height: 50vh;
    overflow-y: auto;
    margin: 0 -5px;
    padding: 0 5px;
}

.product-item {
    background: var(--bg-color);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid transparent;
    transition: all 0.2s ease;
}

.product-item:hover {
    border-color: var(--primary-color);
    background: #f0f4ff;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.product-inputs {
    display: flex;
    gap: 12px;
}

.input-group {
    flex: 1;
}

.input-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.product-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    transition: all 0.2s ease;
}

.product-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #f0f4ff;
}

.product-input::-webkit-inner-spin-button,
.product-input::-webkit-outer-spin-button {
    opacity: 1;
    height: 40px;
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    .sales-popup {
        padding: 0;
        align-items: flex-start;
    }
    
    .sales-popup-content {
        border-radius: 0;
        max-height: 100vh;
        height: 100vh;
    }
    
    .sales-header {
        border-radius: 0;
    }
    
    .sales-header h2 {
        font-size: 20px;
    }
    
    .sales-body {
        padding: 20px 15px;
    }
    
    .product-name {
        font-size: 14px;
    }
    
    .product-input {
        padding: 10px;
        font-size: 14px;
    }
    
    .sales-buttons {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 15px;
        margin: 20px -15px -20px -15px;
        border-top: 1px solid var(--border-color);
    }
    
    .sales-buttons button {
        font-size: 14px;
        padding: 12px 16px;
    }
}

/* Scrollbar styling for products container */
.products-container::-webkit-scrollbar {
    width: 8px;
}

.products-container::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 4px;
}

.products-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.products-container::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}


/* Text Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 13px;
}

/* Loading State */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive Design */
@media (max-width: 480px) {
    .stats-card {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .stat-number {
        font-size: 20px;
    }
    
    .stat-label {
        font-size: 10px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .outlet-actions {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 20px;
    }
}

/* Tablet and Larger */
@media (min-width: 768px) {
    .container {
        padding: 30px;
    }
    
    header {
        padding: 30px;
    }
    
    header h1 {
        font-size: 28px;
    }
}

/* Print Styles */
@media print {
    .btn-primary,
    .btn-secondary,
    .back-link,
    form {
        display: none;
    }
}
