/**
 * Public Stylesheet
 * Sales Plan Map System
 */

/* Map Container */
.spms-map-container {
    position: relative;
    width: 100%;
    background: #f0f0f0;
}

.spms-map {
    width: 100%;
    height: 100%;
}

/* Map Controls - Bottom Left */
.spms-map-controls {
    position: absolute;
    bottom: 40px;
    left: 10px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.spms-map-control-btn {
    background: #fff;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    padding: 10px 15px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s;
    white-space: nowrap;
}

.spms-map-control-btn:hover {
    background: #f8f8f8;
    border-color: rgba(0,0,0,0.3);
}

.spms-map-control-btn:active {
    background: #e8e8e8;
}

.spms-map-control-btn.active {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
    font-weight: 700;
}

/* Add Location Button - Make it stand out */
.spms-add-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    font-weight: 600;
}

.spms-add-btn:hover {
    background: linear-gradient(135deg, #5568d3 0%, #653a8b 100%);
    border-color: #5568d3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.spms-add-btn:active {
    background: linear-gradient(135deg, #4a5bc4 0%, #553078 100%);
    transform: translateY(0);
}

/* Icon-only buttons */
.spms-icon-btn {
    padding: 12px;
    font-size: 20px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spms-icon-btn:hover {
    transform: scale(1.05);
}

.spms-icon-btn.active {
    transform: scale(1.1);
}

/* Custom Label Overlays - Positioned 10px right of marker */
.spms-custom-label {
    /* Styles are set inline in JavaScript for performance */
    /* This class is here for any global overrides if needed */
}

/* Search Bar */
.spms-search-bar {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    width: 90%;
    max-width: 400px;
}

.spms-search-input {
    width: 100%;
    padding: 12px 40px 12px 15px;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    font-size: 14px;
}

.spms-search-input:focus {
    outline: none;
    border-color: #2271b1;
}

/* Info Window */
.spms-info-window {
    padding: 10px;
    max-width: 250px;
}

.spms-info-window h3 {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 600;
}

.spms-info-window p {
    margin: 5px 0;
    font-size: 13px;
    color: #666;
}

.spms-info-window .info-label {
    font-weight: 600;
    color: #333;
}

/* Add Location Form */
.spms-add-location-form {
    background: #fff;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    max-width: 600px;
    margin: 20px auto;
}

.spms-add-location-form h2 {
    margin-top: 0;
}

.spms-form-field {
    margin-bottom: 20px;
}

.spms-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.spms-form-field input[type="text"],
.spms-form-field input[type="email"],
.spms-form-field textarea,
.spms-form-field select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.spms-form-field textarea {
    min-height: 100px;
    resize: vertical;
}

.spms-form-field .required {
    color: #d63638;
}

.spms-form-field .description {
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

.spms-form-field.error input,
.spms-form-field.error textarea,
.spms-form-field.error select {
    border-color: #d63638;
}

.spms-form-error {
    margin-top: 5px;
    color: #d63638;
    font-size: 13px;
}

.spms-form-submit {
    background: #2271b1;
    color: #fff;
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.spms-form-submit:hover {
    background: #135e96;
}

.spms-form-submit.error {
    background: #d63638;
}

.spms-form-submit.error:hover {
    background: #b32d2e;
}

/* Drag and Drop */
.spms-field-sortable-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.spms-field-sortable-item {
    background: #f9f9f9;
    border: 1px solid #ddd;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 4px;
    cursor: move;
    display: flex;
    align-items: center;
}

.spms-field-sortable-item:hover {
    background: #f0f0f0;
    border-color: #2271b1;
}

.spms-field-sortable-item.ui-sortable-helper {
    opacity: 0.8;
    border: 2px dashed #2271b1;
}

.spms-field-drag-handle {
    margin-right: 10px;
    color: #666;
}

/* Loading States */
.spms-loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spms-loading-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: spms-spin 1s linear infinite;
}

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

/* Responsive */
@media screen and (max-width: 768px) {
    .spms-search-bar {
        width: 95%;
        max-width: none;
    }
    
    .spms-map-controls {
        /* Keep at bottom-left on mobile */
        bottom: 40px;
        left: 10px;
    }
    
    .spms-map-control-btn {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .spms-add-location-form {
        padding: 15px;
        margin: 10px;
    }
}

/* Theme Support */
body.dark-theme .spms-map-control-btn,
body.dark-theme .spms-search-input,
body.dark-theme .spms-add-location-form {
    background: #1e1e1e;
    color: #fff;
    border-color: #444;
}

body.dark-theme .spms-form-field label {
    color: #eee;
}

body.dark-theme .spms-form-field input,
body.dark-theme .spms-form-field textarea,
body.dark-theme .spms-form-field select {
    background: #2a2a2a;
    color: #fff;
    border-color: #444;
}

/* White Background Override */
body.spms-white-bg .spms-add-location-form,
body.spms-white-bg .spms-modal-content {
    background: #fff !important;
}

/* Marker Labels - applied inline in JavaScript for better performance */

/* Ensure marker labels appear behind marker icons */
div[aria-label] > div > div {
    z-index: 1 !important; /* Pins on top */
}

/* Label containers behind pins */
.gm-style > div > div:nth-child(1) > div:nth-child(3) > div {
    z-index: 0 !important; /* Labels behind */
}

/* Location Modal Popup */
.spms-location-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 999999 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 20px !important;
}

.spms-location-modal {
    background: #fff !important;
    border-radius: 8px !important;
    max-width: 600px !important;
    width: 100% !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
    position: relative !important;
    overflow: visible !important;
}

.spms-modal-header {
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.spms-modal-header h2 {
    margin: 0;
    font-size: 22px;
    color: #333;
    flex: 1;
}

.spms-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.spms-modal-close:hover {
    background: #e0e0e0;
    color: #000;
}

.spms-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-field {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-field:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.modal-field strong {
    display: block;
    color: #555;
    font-size: 13px;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-weight: 600;
}

.modal-field span,
.modal-field a {
    display: block;
    color: #333;
    font-size: 16px;
    line-height: 1.5;
}

.modal-field a {
    color: #2271b1;
    text-decoration: none;
}

.modal-field a:hover {
    text-decoration: underline;
}

.status-badge {
    display: inline-block !important;
    background: #2271b1;
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px !important;
    font-weight: 600;
}

.notes-field {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid #e0e0e0 !important;
}

.notes-content {
    color: #555 !important;
    line-height: 1.6 !important;
    margin-top: 5px !important;
}

.spms-modal-footer {
    padding: 15px 20px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.spms-btn-directions {
    background: #2271b1;
    color: #fff;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s;
    display: inline-block;
}

.spms-btn-directions:hover {
    background: #135e96;
    color: #fff;
}

.spms-btn-close {
    background: #6c757d;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.spms-btn-close:hover {
    background: #5a6268;
}

/* Mobile Responsive - 90% width */
@media screen and (max-width: 768px) {
    .spms-location-modal-overlay {
        padding: 5%;
    }
    
    .spms-location-modal {
        width: 90%;
        max-width: none;
        max-height: 85vh;
    }
    
    .spms-modal-header h2 {
        font-size: 18px;
    }
    
    .spms-modal-header,
    .spms-modal-body,
    .spms-modal-footer {
        padding: 15px;
    }
    
    .modal-field {
        margin-bottom: 12px;
        padding-bottom: 12px;
    }
    
    .modal-field span,
    .modal-field a {
        font-size: 14px;
    }
    
    .spms-modal-footer {
        flex-direction: column;
    }
    
    .spms-btn-directions,
    .spms-btn-close {
        width: 100%;
        text-align: center;
    }
}

/* ── Google Maps box-sizing fix ─────────────────────────────────────────────
   Some themes (including the bundled SPMS theme) apply a global
   box-sizing:border-box reset via * selector. Google Maps internal tile grid
   requires content-box — border-box breaks tile layout causing grey tiles.
   This rule is in the plugin CSS so it applies regardless of active theme. */
#spms-map *,
#spms-pin-map * {
    box-sizing: content-box !important;
    max-width: none !important;
}
