/* --- Fonts --- */
@font-face {
    font-family: 'Rubik';
    src: url('rubik.ttf') format('truetype');
    font-weight: normal; font-style: normal;
}
@font-face {
    font-family: 'Amiri';
    src: url('amiri.ttf') format('truetype');
    font-weight: normal; font-style: normal;
}
@font-face {
    font-family: 'NotoSerif';
    src: url('notoserif.ttf') format('truetype');
    font-weight: normal; font-style: normal;
}

/* --- Global Variables --- */
:root {
    --bg-color: #0f0f0f;
    --card-bg: #181818;
    --text-primary: #f0f0f0;
    --text-muted: #888;
    --accent-red: #8b0000;
    --accent-red-bright: #e53935;
    --border-color: #2a2a2a;
    
    /* Default Fonts (Persian) */
    --font-ui: 'Rubik', sans-serif;
    --font-styled: 'Amiri', serif;
    
    --radius-lg: 16px;
    --radius-md: 12px;
}

/* English Override */
html[lang="en"] :root {
    --font-ui: 'NotoSerif', sans-serif;
    --font-styled: 'NotoSerif', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent;}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-ui);
    overflow: hidden; 
    height: 100vh; width: 100vw;
}

/* --- INTRO OVERLAY (Atlas style) --- */
#intro-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #050505; z-index: 9999;
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    transition: opacity 1s ease-out;
    pointer-events: none;
}
#intro-title {
    font-family: 'Amiri', serif;
    font-size: 3rem;
    color: var(--accent-red-bright);
    margin: 0 0 20px 0;
    font-weight: 300;
}
#loading-container { width: 200px; }
.progress-track { width: 100%; height: 2px; background: #222; overflow: hidden; }
.progress-bar { width: 0%; height: 100%; background: var(--accent-red-bright); transition: width 0.1s; }
#loading-text { color: #666; font-size: 0.8rem; margin-top: 10px; text-align: center; }

/* --- UI Header --- */
/* --- Updated Compact Header --- */
#ui-header {
    position: fixed; top: 0; left: 0; width: 100%; z-index: 500;
    padding: 15px; pointer-events: none;
    display: flex; justify-content: space-between; align-items: flex-start;
    background: linear-gradient(180deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
}

.search-wrapper { 
    pointer-events: auto; 
    flex-grow: 1; 
    max-width: 400px;
    margin-left: 10px; /* Adjust based on RTL/LTR in JS if needed, or use logical props */
}

/* Nav Container */
.nav-container {
    pointer-events: auto;
    position: relative;
    display: flex;
    gap: 8px;
}

/* Nav Pills (Buttons) */
.nav-pill {
    background: rgba(20, 20, 20, 0.95);
    color: #ccc;
    border: 1px solid #333;
    padding: 10px 16px;
    border-radius: 50px;
    font-family: var(--font-ui);
    backdrop-filter: blur(10px);
    cursor: pointer;
    font-size: 0.9rem;
    display: flex; align-items: center; gap: 6px;
    transition: 0.2s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}
.nav-pill:hover, .nav-pill.active {
    background: #333;
    color: white;
    border-color: #555;
}

/* --- Views --- */
#map { height: 100vh; width: 100vw; z-index: 1; background: #0a0a0a; }
.hidden { display: none !important; }

/* --- GRID VIEW --- */
.grid-view {
    height: 100vh; width: 100vw; background: var(--bg-color);
    overflow-y: auto; z-index: 5;
    padding: 160px 20px 100px 20px;
    display: grid;
    /* Adjusted grid for images */
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    align-content: start;
}
.grid-view::-webkit-scrollbar { width: 6px; }
.grid-view::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* New Class for Grid Images */
.grid-card-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    background-color: #111;
    border-bottom: 1px solid #222;
}

/* --- Floating Button --- */
.floating-btn {
    position: fixed; z-index: 200; bottom: 30px; right: 30px;
    width: 60px; height: 60px; border-radius: 50%;
    font-size: 32px; background: var(--accent-red); color: white;
    border: none; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 15px rgba(139, 0, 0, 0.4); 
    transition: transform 0.2s; cursor: pointer;
}
.floating-btn:hover { background: var(--accent-red-bright); transform: scale(1.1); }

/* --- MODALS --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9); z-index: 1000;
    backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center; 
    padding: 20px;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content {
    background: #181818;
    border: 1px solid #333;
    border-radius: var(--radius-lg);
    width: 100%; max-width: 420px;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.7);
    transform: translateY(20px); transition: transform 0.3s;
    overflow: hidden;
}
.modal-overlay.active .modal-content { transform: translateY(0); }

.close-modal {
    position: absolute; top: 15px; left: 15px; 
    font-size: 28px; color: #fff; cursor: pointer; z-index: 10;
    background: rgba(0,0,0,0.5); width: 32px; height: 32px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
}

/* --- PROFILE DETAIL --- */
.profile-header { width: 100%; height: 300px; background: #111; position: relative; }
.profile-header img { width: 100%; height: 100%; object-fit: cover; }
.profile-body { padding: 25px; text-align: center; }

.profile-name { font-family: var(--font-styled); font-size: 1.5rem; font-weight: 800; color: white; margin-bottom: 8px; }
.profile-meta { 
    display: flex; justify-content: center; gap: 15px; 
    margin-bottom: 20px; color: var(--text-muted); font-size: 0.95rem; font-family: var(--font-ui);
}
.profile-meta span { display: flex; align-items: center; gap: 5px; }
.profile-date { 
    background: rgba(139, 0, 0, 0.2); color: #ffcccc; 
    padding: 8px 16px; border-radius: 50px; font-size: 0.9rem; display: inline-block;
    font-family: var(--font-ui);
}

/* --- TRIBUTE (CANDLE) BUTTON --- */
.profile-actions {
    display: flex; justify-content: center; margin-top: 25px;
}
.tribute-btn {
    background: rgba(30, 30, 30, 0.6);
    border: 1px solid #444;
    border-radius: 30px;
    padding: 8px 15px;
    display: flex; align-items: center; gap: 10px;
    color: #ccc; cursor: pointer;
    font-family: var(--font-ui); font-size: 1rem;
    transition: all 0.3s ease;
}
.tribute-btn:hover { background: rgba(50, 50, 50, 0.8); }

/* Text Label */
.tribute-label {
    font-size: 0.9rem;
    padding-top: 2px;
}

/* Count Wrapper */
.tribute-count-box {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    min-width: 25px;
    text-align: center;
}

/* Active (Lit) state */
.tribute-btn.active {
    border-color: #ff9800;
    background: rgba(255, 152, 0, 0.15);
    color: #ffb74d;
    box-shadow: 0 0 15px rgba(255, 152, 0, 0.3);
}
.tribute-btn.active svg {
    color: #ff9800;
    filter: drop-shadow(0 0 5px #ff9800);
}

/* --- FORMS --- */
.form-scroll-area { padding: 30px; max-height: 80vh; overflow-y: auto; scrollbar-width: none;}
.form-title { font-size: 1.2rem; margin-bottom: 5px; color: white; text-align: center; font-family: var(--font-styled); }
.form-subtitle { text-align: center; color: #777; font-size: 0.8rem; margin-bottom: 25px; font-family: var(--font-ui); }

.form-group { margin-bottom: 18px; }
label { display: block; margin-bottom: 8px; color: #aaa; font-size: 0.85rem; font-family: var(--font-ui); }
input[type="text"], input[type="number"] {
    width: 100%; padding: 12px; background: #222; border: 1px solid #333;
    color: white; border-radius: 8px; outline: none; transition: 0.3s;
    font-family: var(--font-ui);
}
input:focus { border-color: var(--accent-red); background: #2a2a2a; }

/* Custom Select Style */
.dark-select {
    width: 100%; padding: 12px;
    background: #222; border: 1px solid #333;
    color: white; border-radius: 8px; outline: none;
    font-family: var(--font-ui); cursor: pointer;
}
.dark-select:focus { border-color: var(--accent-red); }

.checkbox-row {
    display: flex; align-items: center; gap: 10px;
    background: #222; padding: 12px; border-radius: 8px; cursor: pointer; margin-top: 5px;
}
.checkbox-row input { accent-color: var(--accent-red); width: 18px; height: 18px; }
.checkbox-row label { margin: 0; cursor: pointer; color: #ddd; font-family: var(--font-ui); }

/* Specific Style for Privacy Row */
.privacy-row {
    background: rgba(255, 165, 0, 0.15) !important;
    border: 1px solid #ff9800 !important;
    margin-bottom: 20px !important;
}
.privacy-row label {
    color: #ffb74d !important;
    font-weight: bold;
    line-height: 1.5;
}

#submit-btn {
    width: 100%; padding: 14px; margin-top: 10px;
    background: white; color: black; font-weight: 800;
    border: none; border-radius: 8px; cursor: pointer;
    font-family: var(--font-ui);
}
#submit-btn:hover { background: #ddd; }
.warning { color: #e53935; font-size: 0.8rem; margin-top: 5px; font-family: var(--font-ui); }

/* Filter for Map */
.dark-tiles-filter { filter: invert(100%) hue-rotate(180deg) brightness(80%) contrast(90%) grayscale(80%) !important; }

/* --- POPUPS --- */
.leaflet-popup-content-wrapper {
    background: #181818 !important; border: 1px solid var(--accent-red);
    border-radius: 8px !important; color: white !important; padding: 0 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.8) !important;
}
.leaflet-popup-tip { background: #181818 !important; border: 1px solid var(--accent-red); box-shadow: none !important; }
.leaflet-popup-content { margin: 0 !important; width: 200px !important; cursor: pointer; }

.map-popup-card { display: flex; align-items: center; gap: 10px; padding: 10px; }
.map-popup-img {
    width: 45px; height: 45px; border-radius: 50%; object-fit: cover;
    border: 2px solid #333; background: #222; flex-shrink: 0;
}
.map-popup-info { display: flex; flex-direction: column; overflow: hidden; }
.map-popup-name {
    font-family: var(--font-styled); font-weight: bold; font-size: 0.9rem;
    color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-popup-city { font-family: var(--font-ui); font-size: 0.75rem; color: var(--text-muted); }

[src="unknown.png"] {
    scale: 0.5;
}

/* Ensure heatmap is visible but not overpowering */
.leaflet-heatmap-layer {
    opacity: 0.85;
}

#p-img {
    object-fit: contain;
}


/* Update this block to include textarea */
input[type="text"], input[type="number"], textarea {
    width: 100%; 
    padding: 12px; 
    background: #222; 
    border: 1px solid #333;
    color: white; 
    border-radius: 8px; 
    outline: none; 
    transition: 0.3s;
    font-family: var(--font-ui);
}

/* Add specific styles for textarea */
textarea {
    resize: none;
    min-height: 80px;
    line-height: 1.5;
    scrollbar-width: none;
}

input:focus, textarea:focus { 
    border-color: var(--accent-red); 
    background: #2a2a2a; 
}