/* =====================================================
   GIS MAP — MAIN STYLES
   e-museum.kz/gis
   ===================================================== */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-primary:   #2c6e49;
    --color-accent:    #52b788;
    --color-dark:      #1a2e22;
    --color-darker:    #111e17;
    --color-light:     #f4f9f6;
    --color-white:     #ffffff;
    --color-text:      #2d3a32;
    --color-muted:     #7a8e80;
    --color-border:    #d4e6da;
    --color-marker:    #c1440e;
    --color-user:      #1565c0;
    --shadow-sm:       0 2px 8px rgba(0,0,0,.12);
    --shadow-md:       0 4px 20px rgba(0,0,0,.18);
    --radius-sm:       6px;
    --radius-md:       12px;
    --radius-lg:       20px;
    --font:            'Segoe UI', 'Arial', sans-serif;
    --tr:              .2s ease;
    --panel-w:         360px;
    --header-h:        58px;
}

html, body { height: 100%; font-family: var(--font); color: var(--color-text); background: var(--color-darker); overflow: hidden; }

/* ---- Layout ---- */
#gis-app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ---- Header ---- */
#gis-header {
    height: var(--header-h);
    background: var(--color-darker);
    display: flex; align-items: center;
    padding: 0 16px; gap: 12px; flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,.06);
    z-index: 1000;
}

.gis-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; flex-shrink: 0; }
.gis-logo-mark { width: 34px; height: 34px; background: var(--color-primary); border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.gis-logo-mark svg { width: 20px; height: 20px; }
.gis-logo-text { font-size: 14px; font-weight: 700; color: #fff; line-height: 1.2; }
.gis-logo-sub { font-size: 11px; color: var(--color-accent); font-weight: 400; }
.gis-header-sep { flex: 1; }

/* Language */
.gis-lang { display: flex; background: rgba(255,255,255,.07); border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0; }
.gis-lang-btn { padding: 5px 10px; font-size: 11px; font-weight: 700; color: rgba(255,255,255,.45); background: transparent; border: none; cursor: pointer; transition: var(--tr); letter-spacing: .6px; line-height: 1; }
.gis-lang-btn.active { background: var(--color-accent); color: #fff; }
.gis-lang-btn:hover:not(.active) { color: #fff; }

/* ---- Toolbar ---- */
.gis-toolbar { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.gis-tool-btn {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; width: 52px; min-height: 44px; height: 44px;
    border-radius: var(--radius-sm); border: 1px solid rgba(255,255,255,.1);
    background: rgba(255,255,255,.06); color: rgba(255,255,255,.6);
    cursor: pointer; transition: background var(--tr), color var(--tr), border-color var(--tr);
    padding: 4px; outline: none; -webkit-tap-highlight-color: transparent; flex-shrink: 0;
}
.gis-tool-btn:hover { background: rgba(255,255,255,.12); color: #fff; border-color: rgba(255,255,255,.2); }
.gis-tool-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-accent); }
.gis-tool-btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.gis-tool-label { font-size: 9px; font-weight: 600; letter-spacing: .3px; line-height: 1; white-space: nowrap; text-transform: uppercase; opacity: .85; }

/* ---- Main ---- */
#gis-main { flex: 1; display: flex; position: relative; overflow: hidden; }
#gis-map { flex: 1; z-index: 1; }

/* ---- Search ---- */
#gis-search-wrap { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); z-index: 500; width: 300px; max-width: calc(100vw - 120px); }
.gis-search-inner { display: flex; align-items: center; background: #fff; border-radius: 24px; box-shadow: var(--shadow-md); overflow: hidden; }
.gis-search-icon-wrap { width: 38px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--color-muted); }
.gis-search-icon-wrap svg { width: 16px; height: 16px; }
#gis-search { flex: 1; padding: 10px 14px 10px 0; border: none; outline: none; font-size: 13px; font-family: var(--font); color: var(--color-text); background: transparent; }
#gis-search::placeholder { color: #aaa; }
#gis-search-results { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-md); margin-top: 4px; overflow: hidden; display: none; }
.gis-search-item { padding: 10px 16px; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--color-border); transition: background var(--tr); line-height: 1.35; }
.gis-search-item:last-child { border-bottom: none; }
.gis-search-item:hover { background: var(--color-light); }

/* ---- Side Panel ---- */
#gis-panel { width: var(--panel-w); background: var(--color-white); display: flex; flex-direction: column; z-index: 10; box-shadow: -4px 0 24px rgba(0,0,0,.18); transition: transform var(--tr), width var(--tr); overflow: hidden; flex-shrink: 0; }
#gis-panel.hidden { transform: translateX(100%); width: 0; }
.gis-panel-head { padding: 14px 16px 12px; border-bottom: 1px solid var(--color-border); display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; background: var(--color-light); }
.gis-panel-title { font-size: 12px; font-weight: 700; color: var(--color-dark); text-transform: uppercase; letter-spacing: .8px; }
.gis-panel-count { font-size: 11px; color: var(--color-muted); margin-top: 1px; }
.gis-panel-close-btn { width: 28px; height: 28px; border: none; background: none; cursor: pointer; color: var(--color-muted); border-radius: 50%; display: flex; align-items: center; justify-content: center; transition: var(--tr); flex-shrink: 0; }
.gis-panel-close-btn:hover { background: var(--color-border); color: var(--color-dark); }
.gis-panel-close-btn svg { width: 16px; height: 16px; }
.gis-panel-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; }

.gis-mcard { padding: 12px 16px; border-bottom: 1px solid var(--color-border); cursor: pointer; transition: background var(--tr); display: flex; gap: 12px; align-items: flex-start; }
.gis-mcard:hover { background: var(--color-light); }
.gis-mcard.active { background: #e7f3ec; border-left: 3px solid var(--color-accent); padding-left: 13px; }
.gis-mcard-thumb { width: 50px; height: 50px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; background: var(--color-border); }
.gis-mcard-ph { width: 50px; height: 50px; border-radius: var(--radius-sm); background: #e0ede5; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.gis-mcard-ph svg { width: 22px; height: 22px; color: #9ab8a4; }
.gis-mcard-info { flex: 1; min-width: 0; }
.gis-mcard-name { font-size: 12px; font-weight: 600; color: var(--color-dark); line-height: 1.35; margin-bottom: 3px; }
.gis-mcard-addr { font-size: 11px; color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Detail Panel ---- */
#gis-detail {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: #fff; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -4px 30px rgba(0,0,0,.18);
    z-index: 20; max-height: 76vh; overflow-y: auto;
    transform: translateY(100%); transition: transform .28s ease;
    overscroll-behavior: contain;      /* скролл не выходит за панель */
    -webkit-overflow-scrolling: touch; /* плавный скролл на мобильном */
}
#gis-detail.visible { transform: translateY(0); }
.gis-detail-handle { width: 40px; height: 4px; background: #ddd; border-radius: 2px; margin: 12px auto 0; }
.gis-detail-photo-wrap { position: relative; }
.gis-detail-photo { width: 100%; height: 190px; object-fit: cover; display: block; }
.gis-detail-ph { width: 100%; height: 130px; background: linear-gradient(135deg, #2c6e49, #52b788); display: flex; align-items: center; justify-content: center; }
.gis-detail-ph svg { width: 52px; height: 52px; color: rgba(255,255,255,.5); }
.gis-detail-close { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; border: none; background: rgba(0,0,0,.25); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: var(--tr); z-index: 2; }
.gis-detail-close:hover { background: rgba(0,0,0,.45); }
.gis-detail-close svg { width: 16px; height: 16px; }
.gis-detail-body { padding: 16px 18px 20px; }
.gis-detail-name { font-size: 15px; font-weight: 700; color: var(--color-dark); line-height: 1.3; margin-bottom: 6px; }
.gis-detail-addr { font-size: 12px; color: var(--color-muted); margin-bottom: 12px; display: flex; align-items: flex-start; gap: 5px; line-height: 1.4; }
.gis-detail-addr svg { width: 13px; height: 13px; flex-shrink: 0; margin-top: 1px; }
.gis-detail-desc { font-size: 13px; color: var(--color-text); line-height: 1.65; margin-bottom: 16px; }
.gis-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gis-btn { flex: 1; min-width: 120px; padding: 9px 12px; border-radius: var(--radius-sm); border: none; font-size: 12px; font-weight: 600; cursor: pointer; transition: var(--tr); display: flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; text-align: center; line-height: 1; white-space: nowrap; }
.gis-btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.gis-btn-primary { background: var(--color-primary); color: #fff; }
.gis-btn-primary:hover { background: #245a3b; }
.gis-btn-secondary { background: var(--color-light); color: var(--color-primary); border: 1px solid var(--color-border); }
.gis-btn-secondary:hover { background: var(--color-border); }
.gis-btn-google { background: #1a73e8; color: #fff; }
.gis-btn-google:hover { background: #1558b0; }
.gis-btn-route { background: #e65100; color: #fff; }
.gis-btn-route:hover { background: #bf360c; }

/* ---- Compass widget ---- */
#gis-compass { position: absolute; top: 76px; right: 14px; z-index: 500; background: #fff; border-radius: 50%; width: 68px; height: 68px; box-shadow: var(--shadow-md); display: none; align-items: center; justify-content: center; border: 2px solid var(--color-border); transition: border-color var(--tr), box-shadow var(--tr); pointer-events: none; }
#gis-compass.visible { display: flex; pointer-events: auto; }
#gis-compass.active { border-color: var(--color-primary); }

/* ---- Nearest museums panel ---- */
#gis-near { position: absolute; top: 154px; right: 14px; width: 230px; background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-md); z-index: 500; overflow: hidden; display: none; flex-direction: column; max-height: 300px; }
#gis-near.visible { display: flex; }
.gis-near-head { padding: 9px 12px; background: var(--color-primary); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.gis-near-head svg { width: 13px; height: 13px; }
.gis-near-body { overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.gis-near-item { padding: 8px 12px; border-bottom: 1px solid #eef4f0; cursor: pointer; transition: background var(--tr); display: flex; align-items: center; gap: 8px; }
.gis-near-item:last-child { border-bottom: none; }
.gis-near-item:hover { background: var(--color-light); }
.gis-near-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-marker); flex-shrink: 0; }
.gis-near-name { font-size: 11px; font-weight: 600; color: var(--color-dark); line-height: 1.3; flex: 1; }
.gis-near-dist { font-size: 10px; color: var(--color-muted); white-space: nowrap; }

/* ---- Status ---- */
#gis-status { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); background: rgba(20,40,26,.88); color: #fff; font-size: 12px; padding: 7px 16px; border-radius: 20px; z-index: 500; backdrop-filter: blur(6px); pointer-events: none; opacity: 0; transition: opacity .3s; white-space: nowrap; }
#gis-status.visible { opacity: 1; }

/* ---- Leaflet overrides ---- */
.leaflet-popup-content-wrapper { border-radius: var(--radius-md) !important; box-shadow: var(--shadow-md) !important; padding: 0 !important; overflow: hidden; }
.leaflet-popup-content { margin: 0 !important; width: auto !important; }
.leaflet-popup-tip-container { display: none; }

/* User pulse */
.gis-user-dot { width: 14px; height: 14px; background: var(--color-user); border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 0 rgba(21,101,192,.5); animation: gpulse 2s infinite; }
@keyframes gpulse {
    0%   { box-shadow: 0 0 0 0 rgba(21,101,192,.5); }
    70%  { box-shadow: 0 0 0 10px rgba(21,101,192,0); }
    100% { box-shadow: 0 0 0 0 rgba(21,101,192,0); }
}

/* ================================================================
   RESPONSIVE — MOBILE
   ================================================================ */
@media (max-width: 768px) {
    :root { --panel-w: 100vw; --header-h: auto; }
    #gis-header { flex-direction: column; align-items: stretch; padding: 8px 10px; gap: 6px; height: auto; }
    .gis-header-row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
    .gis-toolbar { display: flex; width: 100%; gap: 4px; }
    .gis-tool-btn { flex: 1; width: auto; min-height: 42px; height: 42px; gap: 2px; }
    .gis-tool-label { font-size: 8px; display: block; }
    .gis-tool-btn svg { width: 17px; height: 17px; }
    .gis-header-sep { display: none; }
    .gis-logo-sub { display: none; }
    #gis-panel { position: absolute; top: 0; right: 0; bottom: 0; transform: translateX(100%); transition: transform .25s ease; }
    #gis-panel.mob-open { transform: translateX(0); }
    #gis-compass { top: 14px; right: 14px; width: 56px; height: 56px; }
    #compass-svg { width: 56px; height: 56px; }
    #gis-search-wrap { left: 8px; right: 8px; width: auto; transform: none; top: 10px; }
    #gis-near { width: 200px; right: 10px; top: 80px; }
    #gis-detail { max-height: 70dvh; }
}
