/* style.css */

/* --- Base --- */
@font-face {
  font-family: 'YekanBakh';
  src: url('fonts/YekanBakh-Regular.woff2') format('woff2'); 
  font-weight: normal;
}

:root {
  --primary: #2E7D32;
  --secondary: #1565C0;
  --accent: #FF9800;
  --bg: #f5f5f5;
  --text: #333;
  --border: #ddd;
}

* { box-sizing: border-box; outline: none; -webkit-tap-highlight-color: transparent; }
body { margin: 0; padding: 0; font-family: 'YekanBakh', sans-serif; height: 100vh; overflow: hidden; background: var(--bg); }
.container { display: flex; height: 100%; position: relative; }

/* --- Loading --- */
.loading-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.98); z-index: 9999; display: flex; justify-content: center; align-items: center; }
.loading-box { width: 320px; text-align: center; }
.loading-spinner { width: 40px; height: 40px; border: 4px solid #eee; border-top-color: var(--primary); border-radius: 50%; margin: 0 auto 15px; animation: spin 0.8s infinite linear; }
.loading-text { font-size: 0.9rem; color: #555; margin-bottom: 8px; }
.progress-track { height: 6px; background: #e0e0e0; border-radius: 3px; overflow: hidden; margin-bottom: 5px; }
.progress-fill { height: 100%; background: var(--primary); width: 0%; transition: width 0.2s; }
.progress-percent { font-weight: bold; color: var(--primary); font-size: 0.9rem; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Sidebar --- */
.mobile-menu-btn { display: none; position: absolute; top: 15px; right: 15px; z-index: 1100; background: white; border: none; padding: 8px 12px; border-radius: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); align-items: center; gap: 5px; cursor: pointer; color: #444; }

.sidebar { width: 340px; background: white; border-left: 1px solid var(--border); display: flex; flex-direction: column; z-index: 2000; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 2px 0 15px rgba(0,0,0,0.05); }
.sidebar-header { padding: 15px; border-bottom: 2px solid var(--primary); display: flex; justify-content: space-between; align-items: center; }
.sidebar-header h2 { margin: 0; font-size: 1.1rem; color: var(--primary); }
.close-sidebar-btn { display: none; background: none; border: none; font-size: 20px; cursor: pointer; }
.sidebar-content { flex: 1; overflow-y: auto; padding: 15px; }

.filter-section, .dropdown-section, .radius-control { background: #f9f9f9; padding: 10px; border-radius: 8px; border: 1px solid #eee; margin-bottom: 12px; }
h3 { margin: 0 0 8px; font-size: 0.9rem; color: #444; }

.brand-list { display: grid; gap: 6px; }
.brand-checkbox { display: flex; background: white; padding: 6px 8px; border-radius: 4px; border: 1px solid #eee; align-items: center; }
.brand-checkbox label { flex: 1; display: flex; justify-content: space-between; cursor: pointer; font-size: 0.9rem; margin-right: 8px; }

.custom-select { position: relative; }
.select-search { width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; }
.select-dropdown { position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #ccc; z-index: 3000; max-height: 220px; overflow-y: auto; display: none; box-shadow: 0 5px 15px rgba(0,0,0,0.1); }
.select-option { padding: 8px; cursor: pointer; border-bottom: 1px solid #f0f0f0; font-size: 0.9rem; }
.select-option:hover { background: #e3f2fd; }

.toggle-switch { display: flex; background: #e0e0e0; padding: 2px; border-radius: 4px; }
.toggle-switch input { display: none; }
.toggle-switch label { flex: 1; text-align: center; padding: 6px; font-size: 0.8rem; cursor: pointer; border-radius: 4px; transition: 0.2s; }
.toggle-switch input:checked + label { background: white; font-weight: bold; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.radius-slider-container { text-align: center; }
.radius-slider { width: 100%; cursor: pointer; }
#radius-value { color: var(--secondary); font-weight: bold; font-size: 0.85rem; display: block; margin-bottom: 5px; }

.controls { display: grid; gap: 8px; margin-top: 10px; }
.control-btn { padding: 10px; border: none; border-radius: 6px; color: white; cursor: pointer; font-family: inherit; transition: 0.2s; }
.control-btn.success { background: var(--primary); }
.control-btn.warning { background: var(--accent); }
.control-btn.reset { background: #d32f2f; }
.control-btn.primary { background: #512DA8; }

/* --- Map & Info --- */
#map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

.info-panel { position: absolute; bottom: 20px; left: 20px; width: 360px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.info-panel > * { pointer-events: auto; background: rgba(255,255,255,0.96); border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); backdrop-filter: blur(4px); }

.visible-stats {padding: 12px;max-height: 35vh;overflow-y: auto;}
.visible-stats h4 { margin: 0 0 10px; font-size: 0.85rem; border-bottom: 1px solid #eee; padding-bottom: 5px; color: #666; }
.stat-row { display: flex; justify-content: space-between; font-size: 0.85rem; margin-bottom: 4px; }
.stat-name { display: flex; align-items: center; gap: 6px; }
.stat-total { text-align: center; font-weight: bold; border-top: 1px dashed #ccc; padding-top: 8px; margin-top: 8px; font-size: 0.9rem; }

/* --- Details Card (RENT FIXED) --- */
#daily-details-box { display: none; border-top: 4px solid var(--primary); }
.dd-header { background: var(--primary); color: white; padding: 10px 15px; display: flex; justify-content: space-between; align-items: center; }
.dd-title { margin: 0; font-size: 1rem; }
.dd-badge { background: rgba(255,255,255,0.25); padding: 2px 8px; border-radius: 4px; font-size: 0.85rem; font-family: monospace; margin-left: 40px; }

.dd-body { padding: 12px; }
.dd-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.dd-meta-item { background: #f5f5f5; padding: 8px; border-radius: 6px; display: flex; flex-direction: column; font-size: 0.8rem; border: 1px solid #eee; }
.dd-meta-val { font-weight: bold; color: #333; margin-top: 2px; }

.details-table { width: 100%; font-size: 0.8rem; border-collapse: collapse; margin-bottom: 12px; }
.details-table th { background: #E8F5E9; padding: 6px; text-align: center; color: var(--primary); }
.details-table td { border-bottom: 1px solid #eee; padding: 6px; text-align: center; }
.row-head { text-align: right; background: #fafafa; font-weight: 500; color: #555; padding-right: 8px; }
.text-online { color: var(--secondary); }

/* RENT SECTION (FIXED LAYOUT) */
.rent-container { background: #FFF8E1; border: 1px solid #FFE0B2; border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.rent-header { color: #F57C00; font-size: 0.8rem; font-weight: bold; border-bottom: 1px dashed #FFCC80; padding-bottom: 4px; }
.rent-main { text-align: center; color: #D84315; }
.rent-amount { font-size: 1.2rem; font-weight: 800; }
.rent-unit { font-size: 0.75rem; color: #8D6E63; }
.rent-details-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rent-box { background: rgba(255,255,255,0.6); padding: 6px; border-radius: 4px; text-align: center; border: 1px solid #FFE0B2; }
.rent-val { display: block; font-weight: bold; color: #BF360C; font-size: 0.95rem; }
.rent-lbl { font-size: 0.7rem; color: #795548; }

/* Tooltips & Clusters */
.daily-tooltip-container { background: transparent; border: none; box-shadow: none; }
.dt-tooltip {     font-family: 'YekanBakh' !important; background: white; border: 1px solid var(--primary); padding: 5px; border-radius: 6px; text-align: center; min-width: 90px; box-shadow: 0 3px 6px rgba(0,0,0,0.1); }
.dt-row { display: block; font-size: 11px; font-weight: bold; }
.dt-row.sales { color: #c62828; border-bottom: 1px solid #eee; padding-bottom: 2px; margin-bottom: 2px; }
.dt-row.trans { color: #1565c0; }

.marker-cluster div { width: 30px; height: 30px; margin-left: 5px; margin-top: 5px; text-align: center; border-radius: 50%; color: #fff; line-height: 30px; font-family: arial; font-weight: bold; }
.marker-cluster-canbo div { background: rgba(0,0,0,0.8); } .marker-cluster-canbo { background: rgba(0,0,0,0.3); }
.marker-cluster-okcs div { background: rgba(198,40,40,0.8); } .marker-cluster-okcs { background: rgba(198,40,40,0.3); }
.marker-cluster-seven div { background: rgba(13,71,161,0.8); } .marker-cluster-seven { background: rgba(13,71,161,0.3); }
.marker-cluster-dailymarket div { background: rgba(46,125,50,0.8); } .marker-cluster-dailymarket { background: rgba(46,125,50,0.3); }
.marker-cluster-minoo div { background: rgba(229,57,53,0.8); } .marker-cluster-minoo { background: rgba(229,57,53,0.3); }
.marker-cluster-amiran div { background: rgba(183,216,43,0.8); } .marker-cluster-amiran div { background: rgba(183,216,43,0.8); color: #333; }
.marker-cluster-beheshti div { background: rgba(255,89,0,0.8); } .marker-cluster-beheshti { background: rgba(255,89,0,0.3); }
.marker-cluster-gandoom div { background: rgba(112,36,123,0.8); } .marker-cluster-gandoom { background: rgba(112,36,123,0.3); }



/* --- Mobile --- */
@media (max-width: 768px) {
  .mobile-menu-btn {display: flex;font-family: 'YekanBakh';}
  .sidebar { position: fixed; inset: 0; width: 100%; transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .close-sidebar-btn { display: block; }
  .info-panel { left: 0; right: 0; bottom: 0; width: 100%; gap: 0; }
  .info-panel > * { border-radius: 12px 12px 0 0; }
  .visible-stats { max-height: 25vh; }
  .details-card { max-height: 60vh; overflow-y: auto; }
}


.leaflet-tooltip-top:before {
    margin-bottom: -4px !important;
}

.brand-checkbox label {
    display: flex;
    align-items: center; 
    justify-content: space-between; 
    gap: 8px; 
    cursor: pointer;
}

.brand-checkbox label img {
    width: 24px; 
    height: 24px; 
    object-fit: contain; 
    display: block; 
}

.popup-content {
    font-family: 'YekanBakh' !important;
    text-align: right !important;
}

/* ===== User Info Bar ===== */
.user-info-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    border-bottom: 1px solid #cbd5e1;
    padding: 12px 16px;
}

.user-info-content {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.user-icon {
    font-size: 18px;
}

.user-display-name {
    font-weight: 600;
    color: #1e293b;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.user-role-badge.admin-badge {
    background: #dbeafe;
    color: #1d4ed8;
}

.user-role-badge.area-sup {
    background: #dcfce7;
    color: #15803d;
}

.logout-link {
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    color: red;
    opacity: 0.6;
    transition: opacity 0.2s;
    cursor: pointer;
}

.logout-link:hover {
    opacity: 1;
}

/* Access Info in Stats */
.access-info {
    margin-top: 8px;
    padding: 6px 10px;
    background: #fef3c7;
    border-radius: 6px;
    color: #92400e;
    text-align: center;
    font-size: 12px;
    border: 1px solid #fde68a;
}

/* ───── ردیف‌های Popup ───── */
.popup-row {
    border-bottom: 1px solid #e9e9e9;
    padding: 5px 0;
    margin-bottom: 2px;
}

.popup-row:last-of-type {
    border-bottom: none;
}

/* ───── دکمه مسیریابی نشان ───── */
.popup-nav-btn {
    margin-top: 10px;
}

.neshan-nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 14px;
    background-color: #42B983;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    transition: background-color 0.2s ease, transform 0.15s ease;
    direction: ltr;
}

.neshan-nav-link:hover {
    background-color: #369b6f;
    transform: translateY(-1px);
}

.neshan-nav-link:active {
    transform: translateY(0);
}

.neshan-nav-link img {
    flex-shrink: 0;
    border-radius: 4px;
}

a.neshan-nav-link {
    color: #ffffff !important;
}
.leaflet-container a {
    color: #000000 !important;
}

a.leaflet-popup-close-button {
    background: #ff7676 !important;
    border-radius: 0px 7px 0px 7px;
}

/* Style for Store Search Box & Autocomplete */
#store-search-wrapper {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    width: 220px;
}

#store-search-container {
    background-color: white;
    padding: 5px;
    border-radius: 5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
}

#store-code-input {
    border: 1px solid #ccc;
    padding: 9px;
    font-family: inherit;
    font-size: 13px;
    flex-grow: 1;
    border-right: none;
    width: 100%;
}

#store-code-input:focus {
    outline: none;
    border-color: #2E7D32;
}

#store-search-btn {
    padding: 8px 12px;
    border: 1px solid #2E7D32;
    background-color: #2E7D32;
    color: white;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.2s;
}

#store-search-btn:hover {
    background-color: #1b5e20;
}

/* Autocomplete Dropdown Styles */
#search-results-dropdown {
    display: none;
    background: white;
    margin: 5px 0 0 0;
    padding: 0;
    list-style: none;
    border-radius: 5px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #ddd;
}

#search-results-dropdown li {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    flex-direction: column;
    transition: background 0.2s;
}

#search-results-dropdown li:last-child {
    border-bottom: none;
}

#search-results-dropdown li:hover {
    background-color: #f1f8e9;
}

.sr-code {
    font-weight: bold;
    color: #2E7D32;
    font-size: 12px;
}

.sr-name {
    color: #333;
    margin-top: 3px;
}

.sr-empty {
    padding: 10px;
    text-align: center;
    color: #888;
    font-size: 13px;
    cursor: default !important;
}
