/**
 * Radius Map Territory Builder Plugin Styles
 */

/* WordPress-specific styles */
.radius-map-container {
    margin: 0.75rem auto;
    max-width: 100%;
    width: 1200px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Map container styles */
.map-container {
    width: 100%;
    height: 500px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

/* Enhanced Map Controls box styles */
.controls {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 0.5rem;
    margin-bottom: 0;
    width: 250px; /* Reduced width to reflect vertical stacking of inputs */
    align-self: flex-start; /* Prevent stretching */
}

.controls h2 {
    font-size: 1.125rem;
    font-weight: 500;
    color: #2d3748;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.25rem;
}

.control-split {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.left-controls, .right-controls {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.375rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem; /* Reduced to minimize bottom spacing */
}

.left-controls {
    background-color: #eff6ff; /* Light blue tint */
    border: 1px solid #dbeafe;
}

.right-controls {
    background-color: #f0fdf4; /* Light green tint */
    border: 1px solid #dcfce7;
    align-items: flex-start; /* Aligns content to the left */
    text-align: left; /* Ensures text alignment is left */
    justify-content: flex-start; /* Ensures content starts from the left */
}

.right-controls .control-row {
    align-items: flex-start; /* Override any inherited alignment */
    width: 100%; /* Ensure full width for left alignment */
}

.right-controls .control-row > div {
    justify-content: flex-start; /* Align child elements to the left */
    width: 100%; /* Ensure full width for consistent left alignment */
    align-items: flex-start; /* Ensure vertical alignment is also left */
}

/* Specific alignment for right-controls elements */
.right-controls label {
    text-align: left !important;
    display: block !important;
    width: 100% !important;
}

.right-controls input[type="checkbox"] {
    margin-left: 0 !important;
    margin-right: auto !important;
}

.right-controls select {
    text-align: left !important;
    margin-left: 0 !important;
    margin-right: auto !important;
}

.right-controls .checkbox,
.right-controls .icon-control,
.right-controls .shading-control,
.right-controls .union-control {
    align-items: flex-start !important;
    text-align: left !important;
    width: 100% !important;
}

.right-controls .checkbox > div,
.right-controls .icon-control > div,
.right-controls .shading-control > div,
.right-controls .union-control > div {
    width: 100% !important;
    text-align: left !important;
    display: block !important;
    margin-top: 0.25rem !important;
}

/* Force vertical layout for dropdown controls */
.right-controls .icon-control,
.right-controls .shading-control {
    display: block !important;
}

.right-controls .icon-control label,
.right-controls .shading-control label {
    display: block !important;
    margin-bottom: 0.25rem !important;
    width: 100% !important;
}

.right-controls .icon-control select,
.right-controls .shading-control select {
    display: block !important;
    width: 100% !important;
    margin-top: 0 !important;
}

.right-controls .icon-control > div,
.right-controls .shading-control > div {
    display: block !important;
    width: 100% !important;
}

.right-controls .control-row {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: flex-start;
}

.right-controls .control-row > div {
    display: block;
    width: 100%;
    margin-bottom: 0.5rem;
}

/* Specific override for checkbox containers */
.right-controls .control-row > div.flex.justify-between {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    width: 100% !important;
}

/* Keep checkboxes inline with their labels */
.right-controls .checkbox {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 0.5rem !important;
    margin-bottom: 0.5rem !important;
}

.right-controls .checkbox label {
    display: inline !important;
    width: auto !important;
    margin-bottom: 0 !important;
    margin-right: 0.5rem !important;
}

.right-controls .checkbox > div {
    display: inline-block !important;
    width: auto !important;
    margin-top: 0 !important;
}

.right-controls .checkbox input[type="checkbox"] {
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Override for justify-between checkbox layout */
.right-controls .mb-2.flex.justify-between {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
}

.control-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.control-row > div {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.controls label {
    font-size: 0.875rem;
    color: #4a5568;
    margin-right: 0.5rem;
}

.controls input[type="number"], .controls input[type="range"], .controls select {
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.controls input[type="number"]:focus, .controls input[type="range"]:focus, .controls select:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
}

.controls input[type="color"] {
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: border-color 0.2s ease-in-out;
}

.controls input[type="color"]:hover {
    border-color: #cbd5e0;
}

.controls button, .export-buttons button {
    background-color: #4299e1; /* Brighter blue */
    color: #ffffff;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s ease-in-out, transform 0.2s ease-in-out;
    border: none;
    cursor: pointer;
}

.controls button:hover, .export-buttons button:hover {
    background-color: #3182ce;
    transform: translateY(-1px);
}

/* Enhanced Map Details box styles to match Map Controls */
.details {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    padding: 0.75rem;
    margin-top: 0.75rem;
    margin-bottom: 1rem;
}

.details h2 {
    font-size: 1.125rem;
    font-weight: 500;
    color: #2d3748;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.5rem;
}

.selected-areas {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.selected-areas label {
    font-size: 0.875rem;
    color: #4a5568;
    margin-right: 0.5rem;
}

.areas-text {
    background-color: #f8fafc;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: #2d3748;
    margin-top: 0.25rem;
}

/* Context menu styles - these complement Tailwind classes */
.context-menu {
    z-index: 99999;
    min-width: 160px;
}

/* Modal styles - these complement Tailwind classes */
.modal {
    z-index: 1001;
}

/* Styles for editable elements */
.editable-container {
    position: relative;
    display: inline-block;
    padding-right: 25px; /* Increase padding to include icon in hover area */
}

.edit-icon {
    display: none;
    position: absolute;
    right: 0px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: #808080;
    font-size: 20px;
}

.editable-container:hover .edit-icon {
    display: inline-block;
}

/* Print-specific styles */
@media print {
    body * {
        visibility: hidden;
    }
    
    .radius-map-container, .radius-map-container * {
        visibility: visible;
    }
    
    .radius-map-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: auto;
    }
    
    /* Hide elements not needed for printing */
    .controls,
    .export-buttons,
    .context-menu,
    .modal,
    button[title="Reset Map"],
    button[title="Print Map"],
    div[title="Toggle fullscreen"],
    div[aria-label="Toggle fullscreen"],
    .gm-control-active,
    .gm-svpc,
    .gmnoprint {
        display: none !important;
    }
    
    #map {
        height: 60vh !important;
        width: 100% !important;
        margin-bottom: 20px;
    }
    
    .selected-areas {
        font-size: 12pt;
        page-break-inside: avoid;
    }
    
    h1 {
        font-size: 16pt;
        text-align: center;
        page-break-after: avoid;
    }
    
    @page {
        size: letter;
        margin: 0.5in;
    }
}

/* Admin styles */
.radius-map-admin-container {
    max-width: 1200px;
    margin: 0.75rem 0;
}

.radius-map-shortcode-usage {
    background-color: #f9f9f9;
    padding: 0.75rem;
    border-radius: 5px;
    margin: 0.75rem 0;
}

.radius-map-shortcode-usage code {
    display: inline-block;
    background-color: #f1f1f1;
    padding: 5px 10px;
    border-radius: 3px;
    margin: 5px 0;
}

.radius-map-saved-territories {
    margin: 0.75rem 0;
}

/* Responsive styles */
@media (max-width: 768px) {
    .control-split {
        flex-direction: column;
    }
    
    .left-controls, .right-controls {
        width: 100%;
        margin-bottom: 15px;
    }
    
    .control-row {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .control-row > div {
        margin-bottom: 10px;
    }
    
    .export-buttons {
        flex-direction: column;
    }
    
    .export-buttons button {
        margin-bottom: 10px;
    }
    
    .flex.flex-row {
        flex-direction: column;
    }
    
    .controls {
        height: auto; /* Reset height for mobile view */
    }
}

/* Override for theme or external layout classes to reduce vertical spacing */
.nv-single-page-wrap col {
    padding: 0.5rem !important;
    margin: 0.5rem 0 !important;
}

/* Adjust flex proportions for map and controls layout */
.flex-1 {
    flex: 0 0 250px; /* Fixed width for controls to match reduced width */
}

.flex-2 {
    flex: 1; /* Map and details take remaining space */
}

/* PDF Export Loading States */
.export-buttons button:disabled {
    background-color: #a0aec0 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

.export-buttons button:disabled:hover {
    background-color: #a0aec0 !important;
    transform: none !important;
}

/* Loading spinner for PDF generation */
.export-buttons button.loading {
    position: relative;
    color: transparent !important;
}

.export-buttons button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Enhanced export button styles */
.export-buttons {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.export-buttons button {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease-in-out;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.export-buttons button:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.export-buttons button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Specific button colors */
#exportPDF {
    background-color: #dc2626;
}

#exportPDF:hover {
    background-color: #b91c1c;
}

#exportImage {
    background-color: #059669;
}

#exportImage:hover {
    background-color: #047857;
}

#saveTerritory {
    background-color: #7c3aed;
}

#saveTerritory:hover {
    background-color: #6d28d9;
}

/* Success/Error message styles */
.export-message {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 6px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    animation: slideIn 0.3s ease-out;
}

.export-message.success {
    background-color: #059669;
}

.export-message.error {
    background-color: #dc2626;
}

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