/* Base styles for the addon */
.custom-marker-addon {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    color: #0f172a;
    line-height: 1.5;
}

/* Container for the entire addon */
.custom-marker-addon-container {
    max-width: 100%;
    margin: 0;
    position: relative;
    z-index: 1000; /* Ensure it stays above the map */
}

/* Card wrapping the UI */
.custom-marker-card {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* Header section (always visible) */
.custom-marker-card-header {
    padding: 15px 20px;
    background: #2f2f2f; /* Updated to requested color */
    color: #0f172a; /* Changed text color to dark gray for contrast */
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    transition: background 0.3s ease;
}

.custom-marker-card-header:hover {
    background: #9aa7b2; /* Slightly darker shade of #abb8c3 for hover effect */
}

.custom-marker-card-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: white; /* Dark gray for contrast */
}

.custom-marker-card-header p {
    margin: 0;
    font-size: 0.875rem;
    color: white; /* Slightly lighter gray for description */
}

/* Toggle icon (chevron) */
.toggle-ui-icon {
    font-size: 1.2rem;
    color: gold; /* Match header text color */
    transition: transform 0.3s ease;
}

/* Rotate chevron when UI is expanded */
.custom-marker-addon[data-collapsed="false"] .toggle-ui-icon {
    transform: rotate(180deg);
}

/* Collapsible content (hidden by default) */
.custom-marker-content {
    display: none;
}

/* Show content when not collapsed */
.custom-marker-addon[data-collapsed="false"] .custom-marker-content {
    display: block;
}

/* Alert section */
.custom-marker-alert {
    display: flex;
    align-items: flex-start;
    background-color: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 12px 16px;
    margin: 0 20px 20px;
}

.custom-marker-alert i {
    color: #d97706;
    font-size: 1rem;
    margin-right: 12px;
    margin-top: 3px;
}

.custom-marker-alert h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #0f172a;
}

.custom-marker-alert p {
    font-size: 0.8125rem;
    margin: 0;
    color: #0f172a;
}

/* Tabs section */
.custom-marker-tabs {
    padding: 0 20px 20px;
}

.custom-marker-tabs-list {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 20px;
    background-color: #f8fafc;
}

.custom-marker-tab {
    padding: 10px 16px;
    border: none;
    background: none;
    font-weight: 500;
    font-size: 0.9375rem;
    color: #475569 !important;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-right: 8px;
    transition: all 0.15s ease;
}

.custom-marker-tab.active {
    color: #1d4ed8 !important;
    border-bottom-color: #1d4ed8;
}

.custom-marker-tab:hover:not(.active) {
    color: #0f172a !important;
    border-bottom-color: #cbd5e1;
}

.custom-marker-tab i {
    margin-right: 6px;
    color: inherit;
}

.custom-marker-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #dbeafe;
    color: #1d4ed8;
    border-radius: 9999px;
    font-size: 0.75rem;
    padding: 2px 8px;
    margin-left: 6px;
}

.custom-marker-tab-pane {
    display: none;
}

.custom-marker-tab-pane.active {
    display: block;
}

/* Form styles */
.custom-marker-form {
    width: 100%;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.form-row .form-group {
    flex: 1;
    padding: 0 10px;
    min-width: 200px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: #0f172a; /* Restore original label color */
}

.field-hint {
    font-size: 0.75rem;
    color: #475569; /* Restore original hint color */
    margin-top: 4px;
    margin-bottom: 0;
}

input[type="text"],
textarea,
select {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.875rem;
    border: 1px solid #d1d5db; /* Restore original border color */
    border-radius: 6px;
    background-color: #ffffff; /* Restore original background */
    color: #0f172a; /* Restore original text color */
    transition: border-color 0.15s ease;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    border-color: #1d4ed8; /* Restore original focus border */
    outline: none;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1); /* Restore original focus shadow */
}

input[type="text"]:read-only {
    background-color: #f8fafc; /* Restore original read-only background */
    color: #475569; /* Restore original read-only text color */
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%230f172a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Dropdown icon styles */
.icon-select {
    padding-left: 30px;
}

.icon-select option {
    position: relative;
    padding-left: 30px;
}

.icon-select option[data-icon]::before {
    content: '';
    font-family: 'FontAwesome';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    color: #475569;
}

.icon-select option[data-icon="fa-map-marker"]::before { content: "\f041"; }
.icon-select option[data-icon="fa-star"]::before { content: "\f005"; }
.icon-select option[data-icon="fa-gift"]::before { content: "\f06b"; }
.icon-select option[data-icon="fa-bolt"]::before { content: "\f0e7"; }
.icon-select option[data-icon="fa-leaf"]::before { content: "\f06c"; }
.icon-select option[data-icon="fa-home"]::before { content: "\f015"; }
.icon-select option[data-icon="fa-flag"]::before { content: "\f024"; }

/* Map position card */
.map-position-card {
    background-color: #f8fafc; /* Restore original background */
    border: 1px solid #e2e8f0; /* Restore original border */
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 20px;
}

.map-position-card h4 {
    font-size: 0.875rem;
    font-weight: 500;
    color: #0f172a; /* Restore original text color */
    margin: 0 0 12px 0;
}

.position-inputs {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.position-inputs .form-group {
    flex: 1;
    margin-bottom: 0;
}

.position-inputs label {
    font-size: 0.75rem;
}

.map-position-button {
    background: none;
    border: none;
    color: #1d4ed8 !important; /* Restore original color with !important to ensure visibility */
    padding: 0;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    font-size: 1rem !important; /* Increased from 0.875rem */
    padding: 6px 12px !important; /* Added padding for button-like appearance */
}

.map-position-button:hover {
    text-decoration: underline;
}

.map-position-button i {
    margin-right: 6px;
    color: inherit !important; /* Ensure icon color matches text */
}

/* Form actions (buttons) */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button,
.text-button {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.primary-button {
    background-color: #1d4ed8; /* Restore original primary button color */
    color: #ffffff;
    border: none;
}

.primary-button:hover {
    background-color: #1e40af;
}

.secondary-button {
    background-color: #64748b; /* Restore original secondary button color */
    color: #ffffff;
    border: none;
}

.secondary-button:hover {
    background-color: #475569;
}

.danger-button {
    background-color: #dc2626; /* Restore original danger button color */
    color: #ffffff;
    border: none;
}

.danger-button:hover {
    background-color: #b91c1c;
}

.danger-button:disabled,
.primary-button:disabled,
.secondary-button:disabled {
    background-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

.icon-button {
    background: none;
    border: none;
    padding: 6px;
    color: #0f172a;
}

.icon-button:hover {
    color: #1d4ed8;
    background-color: #dbeafe;
}

.text-button {
    background: none;
    border: none;
    padding: 0;
    color: #1d4ed8;
    font-size: 0.75rem;
}

.text-button:hover {
    text-decoration: underline;
}

.primary-button i,
.secondary-button i,
.danger-button i {
    margin-right: 6px;
}

/* Markers header (Manage Markers tab) */
.markers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #f8fafc;
    padding: 16px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.markers-header h3 {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #0f172a;
    margin: 0 0 4px 0;
}

.markers-header p {
    font-size: 0.75rem;
    color: #475569;
    margin: 0;
}

.markers-actions {
    display: flex;
    gap: 8px;
}

/* Markers list */
.markers-list {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 4px;
}

.markers-list::-webkit-scrollbar {
    width: 6px;
}

.markers-list::-webkit-scrollbar-track {
    background: #f8fafc;
    border-radius: 3px;
}

.markers-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.markers-list::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.marker-item {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.marker-item-content {
    padding: 16px;
    display: flex;
    align-items: flex-start;
}

.marker-icon-container {
    margin-right: 12px;
}

.marker-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 0 0 2px #ffffff;
}

.marker-details {
    flex: 1;
}

.marker-title {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #0f172a;
    margin: 0 0 4px 0;
}

.marker-description {
    font-size: 0.8125rem;
    color: #475569;
    margin: 0 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.marker-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 0.75rem;
    color: #475569;
}

.marker-meta i {
    margin-right: 4px;
}

.marker-actions {
    display: flex;
    gap: 4px;
}

.marker-item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background-color: #f8fafc;
    font-size: 0.75rem;
}

.marker-visibility {
    display: flex;
    align-items: center;
    color: #0f172a;
}

.marker-visibility input {
    margin-right: 6px;
}

/* Empty state */
.empty-markers {
    text-align: center;
    padding: 48px 0;
}

.empty-markers i {
    font-size: 2.5rem;
    color: #9ca3af;
    margin-bottom: 16px;
}

.empty-markers h3 {
    font-size: 0.9375rem;
    font-weight: 500;
    color: #0f172a;
    margin: 0 0 4px 0;
}

.empty-markers p {
    font-size: 0.8125rem;
    color: #475569;
    margin: 0 0 16px 0;
}

/* Error messages */
.form-error {
    background-color: #fef2f2;
    border: 1px solid #fee2e2;
    color: #991b1b;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
}

.form-error i {
    margin-right: 12px;
    margin-top: 3px;
    color: #dc2626;
}

.form-error-content h4 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #991b1b;
}

.form-error-content p {
    font-size: 0.8125rem;
    margin: 0;
    color: #991b1b;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    padding: 20px;
    overflow-y: auto;
}

.modal.open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: #ffffff;
    border-radius: 8px;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
    color: #0f172a;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #475569;
    cursor: pointer;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.delete-warning {
    display: flex;
    align-items: flex-start;
    color: #991b1b;
}

.delete-warning i {
    font-size: 1.25rem;
    margin-right: 12px;
    margin-top: 2px;
    color: #dc2626;
}

.delete-warning p {
    margin: 0;
    color: #0f172a;
}

input[type="checkbox"] {
    margin: 0;
}

input[type="file"] {
    display: none;
}

/* Toasts */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    z-index: 2000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toast-success {
    background-color: #10b981;
    color: #ffffff;
}

.toast-error {
    background-color: #ef4444;
    color: #ffffff;
}

.toast i {
    margin-right: 8px;
}

/* Tooltips for markers */
.leaflet-tooltip {
    background-color: #ffffff !important;
    color: #0f172a !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.875rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Popups for markers */
.marker-popup {
    padding: 8px;
}

.marker-popup h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: #0f172a;
}

.marker-popup p {
    font-size: 0.875rem;
    margin: 0 0 4px 0;
    color: #475569;
}

.marker-popup small {
    font-size: 0.75rem;
    color: #475569;
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
    }
    
    .markers-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .markers-actions {
        margin-top: 12px;
        width: 100%;
        flex-wrap: wrap;
    }
    
    .markers-actions button {
        flex: 1;
    }
    
    .modal-content {
        max-width: 100%;
    }
}

/* Marker icon colors (UI list) */
.marker-icon.quest { background-color: #f97316; }
.marker-icon.treasure { background-color: #854d0e; }
.marker-icon.enemy { background-color: #0891b2; }
.marker-icon.resource { background-color: #059669; }
.marker-icon.base { background-color: #d97706; }
.marker-icon.event { background-color: #7c3aed; }
.marker-icon.default { background-color: #3b82f6; }
.marker-icon.temp { background-color: #ff0000; }

.marker-icon {
    box-shadow: 0 0 0 2px #ffffff;
}

/* Marker icon styles (on the map) */
.custom-marker-icon {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    background: none !important;
    border: none !important;
    overflow: visible !important;
}

.custom-marker-icon i {
    font-size: 25px;
    line-height: 25px;
}

.custom-marker-icon.marker-quest i { color: #f97316 !important; }
.custom-marker-icon.marker-treasure i { color: #854d0e !important; }
.custom-marker-icon.marker-enemy i { color: #0891b2 !important; }
.custom-marker-icon.marker-resource i { color: #059669 !important; }
.custom-marker-icon.marker-base i { color: #d97706 !important; }
.custom-marker-icon.marker-event i { color: #7c3aed !important; }
.custom-marker-icon.marker-default i { 
    color: #3b82f6 !important;
    filter: drop-shadow(0 0 4px rgba(0, 0, 0, 0.3));
    text-shadow: 1px 1px 0 #ffffff, -1px -1px 0 #ffffff, 1px -1px 0 #ffffff, -1px 1px 0 #ffffff;
}
.custom-marker-icon.marker-temp i { 
    color: #ff0000 !important; 
    filter: drop-shadow(0 0 4px rgba(255, 0, 0, 0.5)); 
}

.leaflet-marker-icon.custom-marker-icon {
    background: none !important;
    border: none !important;
}

/* Ensure form elements have proper spacing */
.custom-marker-addon input,
.custom-marker-addon select,
.custom-marker-addon textarea,
.custom-marker-addon button {
    min-height: auto;
    line-height: normal;
}

/* Larger buttons in the form-actions of the Add Marker form */
.custom-marker-form .form-actions .primary-button,
.custom-marker-form .form-actions .secondary-button {
    padding: 10px 20px; /* Increased from 8px 16px */
    font-size: 0.9375rem; /* Increased from 0.875rem */
}


/* Center and position buttons in the Add Marker form's second column */
.custom-marker-form .form-columns .form-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* Ensure larger buttons in the form-actions of the Add Marker form */
.custom-marker-form .form-actions .primary-button,
.custom-marker-form .form-actions .secondary-button {
    padding: 10px 20px;
    font-size: 0.9375rem;
}