/**
 * Credit Card Acceptance Map - Styles
 * Map-friendly responsive layout with split-screen design
 */

/* ===================================
   CSS Variables for Easy Theming
   =================================== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-color: #1e293b;
    --text-light: #64748b;
    --border-color: #e2e8f0;
    --background: #ffffff;
    --background-alt: #f8fafc;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --font-main: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

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

body {
    font-family: var(--font-main);
    color: var(--text-color);
    background: var(--background-alt);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===================================
   Container and Layout
   =================================== */
.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
}

header {
    background: var(--primary-color);
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
}

header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
}

/* ===================================
   Controls Panel
   =================================== */
.controls-panel {
    background: var(--background);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.search-container {
    position: relative;
    flex: 1;
    min-width: 250px;
}

#business-search {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: border-color 0.3s;
}

#business-search:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===================================
   Suggestions Dropdown
   =================================== */
.suggestions-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--background);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: none;
}

.suggestions-dropdown.active {
    display: block;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background: var(--background-alt);
}

.suggestion-name {
    font-weight: 600;
    color: var(--text-color);
    display: block;
}

.suggestion-address {
    font-size: 0.875rem;
    color: var(--text-light);
    display: block;
}

.suggestion-distance {
    font-size: 0.75rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* ===================================
   Control Buttons
   =================================== */
.control-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

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

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

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

.btn-secondary:hover {
    background: #475569;
    transform: translateY(-1px);
}

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

.select-control {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--background);
    cursor: pointer;
}

/* ===================================
   Filter Panel
   =================================== */
.filter-panel {
    background: var(--background);
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--border-color);
    background: var(--background);
    border-radius: 50px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

/* ===================================
   Main Content: Split Layout
   Desktop: Side by side (60/40)
   Mobile: Stacked
   =================================== */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.map-container {
    flex: 0 0 60%;
    position: relative;
    background: var(--background-alt);
}

#map {
    width: 100%;
    height: 100%;
}

/* ===================================
   Map Legend
   =================================== */
.map-legend {
    position: absolute;
    top: 10px;
    right: 10px;
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-width: 200px;
}

.map-legend h4 {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
}

.legend-pin {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-pin.green { background: #10b981; }
.legend-pin.yellow { background: #f59e0b; }
.legend-pin.red { background: #ef4444; }
.legend-pin.gray { background: #9ca3af; }

/* ===================================
   Loading Overlay
   =================================== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===================================
   Info Panel
   =================================== */
.info-panel {
    flex: 0 0 40%;
    background: var(--background);
    overflow-y: auto;
    border-left: 1px solid var(--border-color);
}

.panel-view {
    padding: 2rem;
}

.panel-view.hidden {
    display: none;
}

.panel-view h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.panel-view h3 {
    font-size: 1.125rem;
    margin: 1.5rem 0 1rem;
    color: var(--text-color);
}

.panel-view ol, .panel-view ul {
    padding-left: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel-view li {
    margin-bottom: 0.5rem;
}

.back-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 0.875rem;
    cursor: pointer;
    margin-bottom: 1rem;
    padding: 0.5rem 0;
    font-weight: 600;
}

.back-btn:hover {
    text-decoration: underline;
}

/* ===================================
   Quick Actions
   =================================== */
.quick-actions {
    margin: 2rem 0;
}

.info-box {
    background: var(--background-alt);
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    border-radius: var(--radius);
    margin-top: 1.5rem;
}

.info-box p {
    font-size: 0.875rem;
    color: var(--text-light);
}

/* ===================================
   Business Details View
   =================================== */
.business-address {
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.business-distance {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.875rem;
}

.business-cards {
    margin: 2rem 0;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.card-item {
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.card-item.accepted {
    border-color: var(--success-color);
    background: #f0fdf4;
    color: var(--success-color);
}

.card-item.cash-only {
    border-color: var(--danger-color);
    background: #fef2f2;
    color: var(--danger-color);
}

.business-meta {
    background: var(--background-alt);
    padding: 1rem;
    border-radius: var(--radius);
    margin: 1rem 0;
}

.business-meta p {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

.business-meta p:last-child {
    margin-bottom: 0;
}

.business-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.business-actions .btn {
    flex: 1;
}

/* ===================================
   Form Styles
   =================================== */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font-main);
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group small {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

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

/* ===================================
   Checkbox Grid for Cards
   =================================== */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.3s;
}

.checkbox-label:hover {
    border-color: var(--primary-color);
    background: var(--background-alt);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"]:checked + span {
    font-weight: 700;
    color: var(--primary-color);
}

.form-actions {
    margin-top: 2rem;
    display: flex;
    gap: 0.5rem;
}

/* ===================================
   Statistics View
   =================================== */
.stats-content {
    margin-top: 1rem;
}

.stat-card {
    background: var(--background-alt);
    padding: 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    margin-bottom: 1rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

.card-stats-list {
    margin-top: 1rem;
}

.card-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--background-alt);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.card-stat-name {
    font-weight: 600;
    text-transform: capitalize;
}

.card-stat-value {
    color: var(--primary-color);
    font-weight: 700;
}

/* ===================================
   Toast Notification
   =================================== */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-color);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
}

.toast.hidden {
    display: none;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===================================
   Modal
   =================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--background);
    padding: 2rem;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
}

.modal-close:hover {
    color: var(--text-color);
}

/* ===================================
   Footer
   =================================== */
footer {
    background: var(--background);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-light);
}

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

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

/* ===================================
   Custom Leaflet Marker Colors
   =================================== */
.leaflet-marker-icon.green-marker {
    filter: hue-rotate(90deg);
}

.leaflet-marker-icon.red-marker {
    filter: hue-rotate(0deg);
}

.leaflet-marker-icon.yellow-marker {
    filter: hue-rotate(45deg);
}

/* ===================================
   Responsive Design
   =================================== */
@media (max-width: 968px) {
    .container {
        height: auto;
        min-height: 100vh;
    }

    .main-content {
        flex-direction: column;
        overflow: visible;
        flex: none;
    }

    .map-container {
        flex: none;
        height: 50vh;
        min-height: 350px;
        max-height: 500px;
    }

    .info-panel {
        flex: none;
        min-height: 50vh;
        border-left: none;
        border-top: 1px solid var(--border-color);
        position: relative;
        overflow-y: auto;
    }

    .map-legend {
        font-size: 0.75rem;
        padding: 0.75rem;
    }
}

@media (max-width: 640px) {
    header h1 {
        font-size: 1.25rem;
    }

    /* Reduce map height on small mobile screens */
    .map-container {
        flex: none;
        height: 40vh;
        min-height: 250px;
        max-height: 350px;
    }

    .controls-panel {
        flex-direction: column;
    }

    .control-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .control-buttons .btn,
    .control-buttons .select-control {
        flex: 1;
    }

    .filter-panel {
        justify-content: center;
    }

    .panel-view {
        padding: 1rem;
    }

    .cards-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .business-actions {
        flex-direction: column;
    }

    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}
