/* עיצוב כללי לדף */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f4f7f6;
}

header {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    padding: 8px 20px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    text-align: center;
    white-space: nowrap;
}

header h1 {
    margin: 0;
    font-size: 1rem;
    color: #333;
}

header p {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: #666;
}

/* עיצוב המפה */
#map {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

/* עיצוב התוויות של השמות על המפה */
.polygon-label {
    background: white;
    border: 2px solid #333;
    border-radius: 5px;
    padding: 3px 8px;
    font-weight: bold;
    font-size: 13px;
    color: #333;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    white-space: nowrap;
}

/* ביטול הקו המחבר של ה-Tooltip */
.leaflet-tooltip-top:before, 
.leaflet-tooltip-bottom:before, 
.leaflet-tooltip-left:before, 
.leaflet-tooltip-right:before {
    border: none !important;
}

/*******************************************************************/
/* ביטול הרקע, המסגרת והצל של ה-Tooltip */
.poi-tooltip-wrap {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0;
    
    /* עיצוב הטקסט - צבע שחור מודגש */
    color: #222; 
    font-weight: 700;
    font-size: 14px; /* אפשר לשחק עם הגודל */
    
    /* יצירת הילה לבנה מסביב לאותיות לקריאות מקסימלית על המפה */
    text-shadow:
        -1.5px -1.5px 0 #fff,
         1.5px -1.5px 0 #fff,
        -1.5px  1.5px 0 #fff,
         1.5px  1.5px 0 #fff,
         0px 0px 4px #fff;
}

/* העלמת החץ (המשולש) הקטן ש-Leaflet מוסיף אוטומטית */
.leaflet-tooltip-right.poi-tooltip-wrap::before,
.leaflet-tooltip-left.poi-tooltip-wrap::before,
.leaflet-tooltip-top.poi-tooltip-wrap::before,
.leaflet-tooltip-bottom.poi-tooltip-wrap::before {
    display: none !important;
}

/* מבנה התיבה הפנימית - מסדר את התמונה והטקסט בשורה */
.poi-tooltip-content {
    display: flex;
    align-items: center; /* יישור התמונה והטקסט לאמצע הגובה */
    gap: 12px; /* רווח בין התמונה לטקסט */
    overflow: hidden; /* מונע סרגלי גלילה לחלוטין */
    max-width: 300px; /* רוחב מקסימלי לתיבה - אפשר לשנות לפי הצורך */
}

/* עיצוב התמונה - גודל קבוע ופרופורציות נכונות */
.poi-tooltip-img {
    width: 60px; /* רוחב התמונה - אפשר לשנות */
    height: 60px; /* גובה התמונה - זהה לרוחב ליצירת ריבוע */
    object-fit: cover; /* חותך את התמונה יפה בלי למעוך או למתוח אותה */
    border-radius: 6px; /* עיגול פינות עדין לתמונה */
    flex-shrink: 0; /* מונע מהתמונה להתכווץ אם יש הרבה טקסט */
}

/* עיצוב הטקסט */
.poi-tooltip-text {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    white-space: normal; /* מאפשר לטקסט לרדת שורה אם הוא ארוך מדי */
    word-wrap: break-word;
}

/* דורס את הגדרות ברירת המחדל של ליפלט כדי לוודא שאין גלילה */
.leaflet-tooltip.poi-tooltip-wrap {
    padding: 8px !important;
    overflow: hidden !important; 
}

/* Extracted styles from map-logic.js - move large injected blocks here */

/* MLS control */
.mls-wrap { position: relative; font-family: 'Segoe UI', sans-serif; }
.mls-toggle-btn { width: 40px; height: 40px; border-radius: 8px; border: 1px solid rgba(0,0,0,0.2); background: rgba(255,255,255,0.95); backdrop-filter: blur(6px); box-shadow: 0 2px 8px rgba(0,0,0,0.18); cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; transition: background 0.15s, box-shadow 0.15s; }
.mls-toggle-btn:hover { background: white; box-shadow: 0 3px 12px rgba(0,0,0,0.25); }
.mls-toggle-btn svg { width: 20px; height: 20px; color: #444; }
.mls-panel { position: absolute; top: 0; right: 46px; background: rgba(255,255,255,0.97); backdrop-filter: blur(8px); border: 1px solid rgba(0,0,0,0.15); border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.18); padding: 10px 12px; min-width: 130px; direction: rtl; opacity: 0; pointer-events: none; transform: translateX(6px); transition: opacity 0.18s ease, transform 0.18s ease; white-space: nowrap; }
.mls-panel::after { content: ''; position: absolute; top: 0; right: -10px; width: 10px; height: 100%; }
.mls-wrap:hover .mls-panel { opacity: 1; pointer-events: auto; transform: translateX(0); }
.mls-section-title { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #999; margin-bottom: 6px; }
.mls-layers { display: flex; flex-direction: column; gap: 5px; }
.mls-radio-label { display: flex; align-items: center; gap: 7px; font-size: 0.88rem; color: #222; cursor: pointer; padding: 3px 4px; border-radius: 5px; transition: background 0.12s; }
.mls-radio-label:hover { background: #f0f6ff; }
.mls-radio-label input { cursor: pointer; margin: 0; accent-color: #3498db; }
.mls-divider { height: 1px; background: rgba(0,0,0,0.1); margin: 8px 0; }
.mls-search-wrap { position: relative; }
#mls-search-input { width: 100%; box-sizing: border-box; padding: 5px 24px 5px 8px; border: 1px solid rgba(0,0,0,0.18); border-radius: 6px; font-size: 0.85rem; font-family: 'Segoe UI', sans-serif; background: rgba(255,255,255,0.85); outline: none; direction: rtl; }
#mls-search-input:focus { border-color: #3498db; }
#mls-search-clear { display: none; position: absolute; left: 5px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; border: none; background: #bbb; border-radius: 50%; color: white; font-size: 9px; font-weight: 700; cursor: pointer; align-items: center; justify-content: center; padding: 0; line-height: 1; transition: background 0.15s; }
#mls-search-clear:hover { background: #999; }
#mls-search-results { position: absolute; top: calc(100% + 3px); right: 0; min-width: 220px; background: white; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); max-height: 320px; overflow-y: auto; display: none; z-index: 3000; }
.mls-result-section-header { padding: 5px 10px 3px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #888; background: #f5f5f5; border-bottom: 1px solid #eee; direction: rtl; }
.mls-result-item { padding: 7px 10px; font-size: 0.83rem; cursor: pointer; border-bottom: 1px solid #f0f0f0; direction: rtl; text-align: right; }
.mls-result-item:hover { background: #f0f6ff; }
.mls-result-item:last-child { border-bottom: none; }
.mls-result-item small { color: #888; display: block; font-size: 0.75rem; }
.mls-result-loading { color: #999; font-style: italic; }

/* Zoom indicator */
#zoom-indicator { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 2000; background: rgba(255,255,255,0.88); backdrop-filter: blur(4px); border: 1px solid rgba(0,0,0,0.18); border-radius: 20px; padding: 4px 14px; font-size: 0.82rem; font-family: 'Segoe UI', sans-serif; color: #333; pointer-events: none; white-space: nowrap; box-shadow: 0 1px 6px rgba(0,0,0,0.15); }
#zoom-indicator.out-of-bounds { background: rgba(255,220,220,0.95); color: #c00; border-color: rgba(200,0,0,0.3); }

/* InjectAllStyles - dialogs, presets, labels etc. */
.leaflet-draw-tooltip { margin-left: -120px; margin-top: 20px; }
.leaflet-draw-tooltip-subtext { display: none !important; }
.dialog-overlay { position: fixed; inset: 0; background: rgba(10, 20, 40, 0.55); backdrop-filter: blur(3px); z-index: 9998; display: none; }
.dialog-box { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 9999; background: #1a2332; border: 1px solid rgba(255,255,255,0.1); border-radius: 16px; padding: 28px 32px; min-width: 340px; box-shadow: 0 24px 64px rgba(0,0,0,0.5); color: #e8edf3; font-family: 'Segoe UI', Tahoma, sans-serif; display: none; animation: dialogIn 0.22s ease; }
.dialog-box h2 { margin: 0 0 20px; font-size: 1.2rem; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 12px; }
.dialog-box label { display: block; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: #8fa3be; margin: 16px 0 6px; }
.dialog-text-input { width: 100%; box-sizing: border-box; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 8px; padding: 10px 12px; color: #fff; font-size: 0.95rem; outline: none; transition: border-color 0.2s; }
.dialog-text-input:focus { border-color: #4a90d9; }
.color-row { display: flex; align-items: center; gap: 12px; }
.dialog-color-input { width: 44px; height: 44px; border: none; border-radius: 8px; cursor: pointer; padding: 2px; background: transparent; flex-shrink: 0; }
.color-presets { display: flex; gap: 7px; flex-wrap: wrap; }
.preset { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform 0.15s, border-color 0.15s; }
.preset:hover { transform: scale(1.2); border-color: rgba(255,255,255,0.5); }
.preset.active { border-color: #fff; transform: scale(1.15); }
.dialog-range { width: 100%; accent-color: #4a90d9; cursor: pointer; }
.opacity-val { color: #fff; font-weight: 600; }
.dialog-preview { margin-top: 16px; height: 36px; border-radius: 8px; border: 2px solid rgba(255,255,255,0.15); transition: background 0.2s; }
.label-zoom-group { display: flex; gap: 8px; margin-top: 4px; }
.label-zoom-option { display: flex; align-items: center; gap: 0; cursor: pointer; flex: 1; }
.label-zoom-option input[type="radio"] { display: none; }
.label-zoom-option span { display: block; text-align: center; width: 100%; padding: 7px 0; border-radius: 8px; font-size: 0.88rem; font-weight: 600; background: rgba(255,255,255,0.07); color: #8fa3be; border: 2px solid transparent; transition: background 0.15s, color 0.15s, border-color 0.15s; cursor: pointer; }
.label-zoom-option input[type="radio"]:checked + span { background: #3498db; color: #fff; border-color: #4aa8ef; }
.label-zoom-option span:hover { background: rgba(255,255,255,0.13); color: #cde; }
.dialog-buttons { display: flex; gap: 10px; margin-top: 22px; }
.dialog-buttons button { flex: 1; padding: 10px; border: none; border-radius: 8px; font-size: 0.95rem; font-weight: 600; cursor: pointer; transition: opacity 0.15s, transform 0.1s; }
.dialog-buttons button:active { transform: scale(0.97); }
.btn-cancel  { background: rgba(255,255,255,0.08); color: #aac; }
.btn-confirm { background: #3498db; color: #fff; }
.btn-confirm:hover { opacity: 0.88; }
.line-numbers-row { display: flex; gap: 12px; }
.line-numbers-row > div { flex: 1; }
#line-dialog-box { min-width: 360px; }
.line-name-hidden { display: none !important; }
.polygon-label-hidden { display: none !important; }
.leaflet-editing-icon { width: 7px !important; height: 7px !important; margin-left: -4px !important; margin-top: -4px !important; border-radius: 2px; border-width: 1px !important; }
.leaflet-draw-guide-dash { width: 4px !important; height: 4px !important; }
.line-label { background: white; border: 1px solid #555; border-radius: 3px; padding: 1px 1px; font-weight: bold; font-size: 10px; color: #333; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,0.15); white-space: nowrap; display: inline-block; transform: translate(-50%, -50%); }

/* Zoom indicator */
#zoom-indicator { position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%); z-index: 2000; background: rgba(255,255,255,0.88); backdrop-filter: blur(4px); border: 1px solid rgba(0,0,0,0.18); border-radius: 20px; padding: 4px 14px; font-size: 0.82rem; font-family: 'Segoe UI', sans-serif; color: #333; pointer-events: none; white-space: nowrap; box-shadow: 0 1px 6px rgba(0,0,0,0.15); }
#zoom-indicator.out-of-bounds { background: rgba(255,220,220,0.95); color: #c00; border-color: rgba(200,0,0,0.3); }

/* Opacity control */
#opacity-ctrl { position: fixed; bottom: 32px; left: 12px; z-index: 2000; background: white; border: 2px solid rgba(0,0,0,0.2); border-radius: 8px; padding: 8px 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.25); display: flex; flex-direction: column; align-items: center; gap: 6px; font-family: 'Segoe UI', Tahoma, sans-serif; width: 52px; }
#opacity-ctrl-labels-row { display: flex; flex-direction: column; align-items: center; gap: 3px; }
#opacity-ctrl-labels-label { font-size: 10px; font-weight: 700; color: #444; }
#opacity-ctrl-labels-check { width: 16px; height: 16px; cursor: pointer; }
#opacity-ctrl-lines-row { display: flex; flex-direction: column; align-items: center; gap: 3px; }
#opacity-ctrl-lines-label { font-size: 10px; font-weight: 700; color: #444; }
#opacity-ctrl-lines-check { width: 16px; height: 16px; cursor: pointer; }
.opacity-ctrl-divider { width: 100%; height: 1px; background: #ddd; }
#opacity-ctrl-label { font-size: 10px; font-weight: 700; color: #444; }
#opacity-ctrl-range { -webkit-appearance: slider-vertical; width: 4px; height: 90px; cursor: pointer; accent-color: #3498db; padding: 0; }
#opacity-ctrl-minus, #opacity-ctrl-plus { width: 22px; height: 22px; border: 1px solid #ccc; border-radius: 4px; background: #fdfdfd; font-size: 14px; font-weight: 700; color: #333; cursor: pointer; line-height: 1; display: flex; align-items: center; justify-content: center; transition: background 0.12s; }
#opacity-ctrl-minus:hover, #opacity-ctrl-plus:hover { background: #f0f0f0; }
#opacity-ctrl-val { font-size: 10px; font-weight: 700; color: #333; }

/* POI styles */
.leaflet-tooltip.poi-tooltip-wrap { background: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; max-width: none !important; }
.leaflet-tooltip.poi-tooltip-wrap::before { display: none !important; }
.poi-custom-card { background: white; border-radius: 10px; box-shadow: 0 4px 16px rgba(0,0,0,0.22); padding: 10px; width: 300px; box-sizing: border-box; direction: rtl; pointer-events: none; font-family: 'Segoe UI', Tahoma, sans-serif; overflow: hidden; }
.poi-card-img-main { float: left; width: 90px; height: 90px; object-fit: cover; border-radius: 6px; margin-right: 10px; margin-bottom: 6px; }
.poi-card-text-wrapper { direction: rtl; }
.poi-card-title { font-size: 0.95rem; font-weight: 700; color: #111; margin-bottom: 5px; white-space: normal; overflow-wrap: break-word; line-height: 1.3; }
.poi-card-desc { font-size: 0.78rem; color: #444; line-height: 1.4; white-space: normal; overflow-wrap: break-word; }
.poi-meta { font-size: 0.72rem; color: #666; margin-bottom: 3px; direction: ltr; text-align: right; unicode-bidi: plaintext; }
.poi-type { font-weight: 600; color: #1a6fc4; font-size: 0.78rem; direction: rtl; }
.poi-date { margin-top: 6px; color: #888; font-style: italic; direction: rtl; }
.poi-card-extra-imgs { clear: both; display: flex; flex-direction: row; direction: ltr; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.poi-card-img-extra { width: 70px; height: 70px; object-fit: cover; border-radius: 5px; flex-shrink: 0; }
.poi-lb-trigger { cursor: pointer; transition: opacity 0.15s, transform 0.15s; pointer-events: all !important; }
.poi-lb-trigger:hover { opacity: 0.85; transform: scale(1.04); }
.poi-hover-card { position: fixed; z-index: 9500; pointer-events: auto; }

/* Lightbox */
#poi-lightbox { display: none; position: fixed; inset: 0; z-index: 99999; background: rgba(0,0,0,0.82); backdrop-filter: blur(4px); align-items: center; justify-content: center; }
#poi-lightbox.open { display: flex; }
#poi-lb-inner { position: relative; max-width: 92vw; max-height: 92vh; display: flex; align-items: center; justify-content: center; }
#poi-lb-img { max-width: 88vw; max-height: 88vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,0.6); object-fit: contain; display: block; }
#poi-lb-close { position: absolute; top: -16px; right: -16px; width: 36px; height: 36px; border-radius: 50%; border: none; background: white; color: #333; font-size: 1.1rem; font-weight: 700; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 2; }
#poi-lb-prev, #poi-lb-next { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(255,255,255,0.9); color: #333; font-size: 1.8rem; line-height: 1; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,0.35); display: flex; align-items: center; justify-content: center; z-index: 2; transition: background 0.15s; }
#poi-lb-prev.hidden, #poi-lb-next.hidden { display: none; }
#poi-lb-counter { position: absolute; bottom: -28px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.85); font-size: 0.85rem; font-family: 'Segoe UI', sans-serif; white-space: nowrap; }

/* Context menu styles */
#map-context-menu { position: fixed; z-index: 9000; background: white; border: 1px solid rgba(0,0,0,0.18); border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.2); padding: 6px 0; font-family: 'Segoe UI', sans-serif; font-size: 0.85rem; min-width: 190px; display: none; user-select: none; }
#map-ctx-coords { padding: 6px 14px 4px; color: #555; font-size: 0.78rem; border-bottom: 1px solid #eee; margin-bottom: 4px; direction: ltr; text-align: left; }
.map-ctx-item { padding: 6px 14px; cursor: pointer; color: #222; transition: background 0.12s; }
.map-ctx-item:hover { background: #f0f6ff; }
#map-ctx-copy.copied { color: #27ae60; }
/* Back button */
.map-back-btn {
    width: 34px; height: 34px;
    background: white;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 5px rgba(0,0,0,0.3);
    transition: opacity 0.2s, background 0.15s;
    color: #333;
}
.map-back-btn:hover { background: #f4f4f4; }
