/* ============================================================
   STYLES-DMSCREEN.CSS - Akıllı Grid ve Tam Ekran Tasarım
   ============================================================ */

html, body {
    width: 100vw;
    height: 100vh; /* Eski tarayıcılar için yedek */
    height: 100dvh; /* YENİ: Adres çubuğuna göre anlık esneyen Dinamik Yükseklik */
    margin: 0;
    padding: 0;
    overflow: hidden !important; 
    overscroll-behavior: none; 
    box-sizing: border-box;
    -webkit-user-select: none;
    user-select: none; 
}

/* Not: Panellerin içindeki inputlara (HP, Zar yazma vs.) yazı yazabilmek için 
   gerekli olan yerlerde user-select'i açmayı unutmamalısın. */

/* Mobil cihazlarda seri tıklamada yakınlaştırmayı (Zoom) engeller */
button, input, select, textarea, .ct-hp-btn, .ct-rollable {
    touch-action: manipulation;
}

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

body {
    background-color: #1a1a1a;
    color: #eee;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100vh; /* Yedek */
    height: 100dvh; /* YENİ: Dinamik Yükseklik */
    overflow: hidden; 
    display: flex;
    flex-direction: column;
}

/* --- HEADER VE NAV BUTONU --- */
.main-header { flex-shrink: 0; background-color: #222; border-bottom: 2px solid #b52b2b; padding: 10px 0; z-index: 1000; }
.header-container { max-width: 100%; margin: 0 auto; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; }
.logo-img { width: 50px; height: 50px; filter: drop-shadow(0 0 5px rgba(181, 43, 43, 0.5)); }
.titles {text-decoration: none; color: inherit; }
.main-title { font-size: 1.4em; font-weight: bold; color: #fff; margin-bottom: -5px; }
.sub-title { font-size: 0.8em; color: #b52b2b; text-transform: uppercase; letter-spacing: 2px; }
.desktop-nav { display: flex; gap: 20px; align-items: center; color: #444; }
.nav-link { text-decoration: none; color: #ccc; font-weight: 500; transition: color 0.2s; font-size: 0.95em; }
.nav-link:hover { color: #b52b2b; }
.menu-icon { display: none; font-size: 1.8em; cursor: pointer; color: #ccc; }

.mobile-nav { display: none; position: absolute; top: 70px; left: 0; width: 100%; background-color: #222; border-bottom: 2px solid #b52b2b; margin-top: 20px; padding: 20px; z-index: 2000; box-shadow: 0 5px 10px rgba(0,0,0,0.5); }
.mobile-nav.open { display: block; }
.mobile-nav ul { list-style: none; }
.mobile-nav li { margin-bottom: 15px; text-align: center; }
.mobile-nav a { text-decoration: none; color: #eee; font-size: 1.2em; display: block; }

.nav-grid-btn { background: rgba(255, 255, 255, 0.05); border: 1px solid #444; color: #ccc; padding: 6px 15px; border-radius: 20px; cursor: pointer; font-size: 0.9em; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.nav-grid-btn:hover { background: #333; color: #fff; border-color: #b52b2b; }

.dmscreen-container { flex-grow: 1; display: flex; flex-direction: column; padding: 15px; gap: 15px; overflow: hidden; }

.control-group { display: flex; align-items: center; gap: 8px; }
.control-group label { color: #aaa; font-size: 0.9em; }
.control-group input[type="number"] { background-color: #333; color: #eee; border: 1px solid #444; padding: 8px; border-radius: 4px; width: 70px; font-size: 1em; text-align: center; outline: none; }
.control-group input[type="number"]:focus { border-color: #b52b2b; }
.main-btn { background-color: #b52b2b; color: white; border: none; padding: 10px 15px; border-radius: 4px; cursor: pointer; font-weight: bold; transition: 0.2s; }
.main-btn:hover { background-color: #d13d3d; }
.secondary-btn { background-color: #333; color: white; border: none; padding: 10px 15px; border-radius: 4px; cursor: pointer; transition: 0.2s; }
.secondary-btn:hover { background-color: #444; }

/* --- GRID SİSTEMİ --- */
.dm-grid { flex-grow: 1; display: grid; gap: 10px; min-height: 0; }

.grid-cell.empty-panel { background-color: rgba(30, 30, 30, 0.5); border: 2px dashed #444; border-radius: 8px; display: flex; justify-content: center; align-items: center; min-height: 0; min-width: 0; transition: 0.2s; }
.grid-cell.empty-panel.drag-over { background-color: rgba(181, 43, 43, 0.2); border-color: #b52b2b; }
.add-content-btn { background: none; border: none; color: #666; font-size: 3em; cursor: pointer; transition: 0.2s; width: 100%; height: 100%; }
.add-content-btn:hover { color: #b52b2b; transform: scale(1.1); }

.dm-panel { background-color: #222; border: 1px solid #444; border-radius: 8px; display: flex; flex-direction: column; overflow: hidden; position: relative; min-height: 0; min-width: 0; box-shadow: 0 4px 6px rgba(0,0,0,0.3); }
.panel-header { background-color: #111; border-bottom: 1px solid #333; padding: 8px 12px; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.panel-title { font-weight: bold; font-size: 0.95em; color: #ddd; }
.panel-controls { display: flex; gap: 8px; }
.panel-control-btn { background: none; border: none; color: #888; cursor: pointer; font-size: 1.1em; transition: 0.2s; }
.panel-control-btn:hover { color: #fff; }
.panel-control-btn.edit-panel-btn:hover { color: #b52b2b; }
.panel-control-btn.remove-panel-btn:hover { color: #ff4444; }

/* ============================================================
   EVRENSEL HAYALET SCROLLBAR (Tüm Tarayıcılar İçin)
   ============================================================ */
/* Firefox Uyumluluğu */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 100, 100, 0.5) transparent;
}

/* Chrome, Brave, Safari, Edge Uyumluluğu */
::-webkit-scrollbar {
    width: 5px;  /* Çok ince, zarif bir genişlik */
    height: 5px; /* Yatay scroll için ince genişlik */
}

/* O sinir bozucu beyaz/gri arkaplanı tamamen yok ediyoruz */
::-webkit-scrollbar-track {
    background: transparent !important; 
}

/* Scrollbar'ın kendisi (Normalde Görünmez) */
::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 100, 0); /* Sıfır opaklık = Gizli */
    border-radius: 10px;
    transition: background-color 0.3s ease; /* Yumuşak geçiş */
}

/* Sadece kaydırılabilir kutunun üzerine gelindiğinde beliren silik gri renk */
*:hover::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 100, 0.4); 
}

/* Scrollbar'ın bizzat üstüne gelip tuttuğunda parlayan D&D kırmızısı */
*:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(181, 43, 43, 0.8); 
}

.panel-content { flex-grow: 1; overflow-y: auto; font-size: 0.9em; }

/* YENİ EKLENEN KISIM: Iframe ve widget'lar için akıllı Zoom ve sıfır boşluk */
.panel-content.no-padding { 
    padding: 0; 
    overflow: hidden; 
    position: relative; 
    display: block; 
}
.panel-content.no-padding iframe { 
    position: absolute;
    top: 0;
    left: 0;
    /* İframe boyutunu CSS değişkenindeki zooma göre tersine hesaplar */
    width: calc(100% / var(--zoom, 1)); 
    height: calc(100% / var(--zoom, 1)); 
    /* Hesaplanan boyutu görsel olarak gerçek kutuya fitler */
    transform: scale(var(--zoom, 1)); 
    transform-origin: top left;
    border: none; 
    display: block; 
    border-radius: 0 0 8px 8px; 
}
/* --- EDİT MODU ARAYÜZÜ --- */
.edit-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.75); z-index: 10; display: flex; justify-content: center; align-items: center; border-radius: 8px; }
.drag-handle-center { width: 60px; height: 60px; background-color: rgba(255, 255, 255, 0.15); border: 2px solid rgba(255, 255, 255, 0.5); border-radius: 50%; color: white; font-size: 28px; display: flex; justify-content: center; align-items: center; cursor: grab; transition: 0.2s; }
.drag-handle-center:active { cursor: grabbing; background-color: rgba(181, 43, 43, 0.5); border-color: #b52b2b; }

.finish-edit-btn { position: absolute; top: 20px; right: 20px; width: 30px; height: 30px; background-color: #4caf50; color: white; border: none; border-radius: 50%; font-size: 1em; cursor: pointer; z-index: 20; box-shadow: 0 2px 8px rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; transition: 0.2s; }
.finish-edit-btn:hover { background-color: #45a049; transform: scale(1.1); }

.resize-handle { position: absolute; background-color: rgba(255, 255, 255, 0.15); transition: 0.2s; }
.resize-handle:hover { background-color: rgba(181, 43, 43, 0.8); }

.resize-handle.top { top: 0; left: 50%; transform: translateX(-50%); width: 40%; height: 10px; cursor: ns-resize; border-radius: 0 0 6px 6px; }
.resize-handle.bottom { bottom: 0; left: 50%; transform: translateX(-50%); width: 40%; height: 10px; cursor: ns-resize; border-radius: 6px 6px 0 0; }
.resize-handle.left { top: 50%; transform: translateY(-50%); left: 0; width: 10px; height: 40%; cursor: ew-resize; border-radius: 0 6px 6px 0; }
.resize-handle.right { top: 50%; transform: translateY(-50%); right: 0; width: 10px; height: 40%; cursor: ew-resize; border-radius: 6px 0 0 6px; }

.resize-handle.top-left { top: 0; left: 0; width: 18px; height: 18px; cursor: nwse-resize; border-radius: 8px 0 6px 0; }
.resize-handle.top-right { top: 0; right: 0; width: 18px; height: 18px; cursor: nesw-resize; border-radius: 0 8px 0 6px; }
.resize-handle.bottom-left { bottom: 0; left: 0; width: 18px; height: 18px; cursor: nesw-resize; border-radius: 0 6px 0 8px; }
.resize-handle.bottom-right { bottom: 0; right: 0; width: 18px; height: 18px; cursor: nwse-resize; border-radius: 6px 0 8px 0; }

/* Mobilde sürükleme yaparken ekranın kaymaya çalışmasını veya titremesini engeller */
.resize-handle, 
.drag-handle-center, 
.edit-overlay {
    touch-action: none !important; /* Tarayıcıya: "Burada standart kaydırma yapma, sadece benim JS koduma izin ver" der */
}

#dmscreen-container, .dmscreen-container {
    width: 100%;
    flex-grow: 1; /* YENİ: Üstte ne kadar bar açılırsa açılsın, kalan YERİN TAMAMINI otomatik kaplar */
    min-height: 0; /* YENİ: Flexbox'ın sınırları aşıp dışarı taşmasını KESİN olarak engeller */
    overflow: hidden; 
    padding: 15px;
    display: flex; 
    flex-direction: column;
    gap: 15px; 
}

.panel-content-diceroller { display: flex; flex-direction: column; gap: 10px; height: 100%; }
.dice-buttons { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }
.dice-btn { background-color: #333; border: 1px solid #555; color: #eee; padding: 8px 12px; border-radius: 4px; cursor: pointer; flex: 1 1 30%; font-weight: bold; transition: 0.2s; }
.dice-btn:hover { background-color: #b52b2b; border-color: #b52b2b; }

/* --- MODAL STİLLERİ --- */
.modal-overlay { 
    position: fixed; top: 0; left: 0; width: 100vw; height: 100dvh; 
    background: rgba(0,0,0,0.8); z-index: 20000; 
    display: none; justify-content: center; align-items: center; 
    /* YENİ: Modalın ekranın kenarlarına sıfıra sıfır yapışmasını kesin olarak engeller */
    padding: 20px; 
    box-sizing: border-box;
}
.modal-overlay.open { display: flex; }

.modal-window { 
    background: #1e1e1e; border-radius: 8px; border: 1px solid #444; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    
    /* YENİ: Akıllı boyutlandırma ve esnek yükseklik motoru */
    max-width: 100%; /* HTML'deki inline 500px'i dar ekranlarda ezer, yatay taşmayı önler */
    max-height: 100%; /* Dışarıdaki 20px padding'e saygı duyar, ekranı dikeyde ASLA aşmaz */
    display: flex; 
    flex-direction: column; /* İçeriğin kendi içinde scroll olması için Flex Sütunu yapıyoruz */
    overflow: hidden;
}

.modal-header { 
    background: #252525; padding: 15px 20px; border-bottom: 1px solid #333; 
    display: flex; justify-content: space-between; align-items: center; 
    flex-shrink: 0; /* İçerik ne kadar uzarsa uzasın, üst başlığın ezilmesini yasaklar */
}

.modal-content { 
    /* Eski sabit 70vh kısıtlamasını sildik, yerine dinamik Flex-Grow ekledik */
    overflow-y: auto; 
    flex-grow: 1; /* Modal büyüdükçe alanı doldurur, sığmazsa sadece BU alan kaydırılabilir olur */
}

/* Modalların içindeki düğme gridi */
.panel-type-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 15px 0; }
.type-opt-btn { width: 100%; background-color: #2a2a2a; border: 1px solid #444; color: #eee; padding: 10px; border-radius: 6px; cursor: pointer; text-align: left; font-size: 0.95em; transition: 0.2s; }
.type-opt-btn:hover { background-color: #333; border-color: #b52b2b; }

.close-modal-btn { background: none; border: none; color: #888; font-size: 1.2em; font-weight: bold; cursor: pointer; transition: 0.2s; }
.close-modal-btn:hover { color: #fff; }


/* ============================================================
   TAM EKRAN (FULLSCREEN) SİSTEMİ
   ============================================================ */

/* Butonun panele değil, ekrana göre yerleşmesi için relative tanımladık */
.dmscreen-container {
    position: relative; 
}

/* Transparan, Silik, Sol Üst Köşe Butonu */
.fullscreen-toggle-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.2); /* Çok silik */
    width: 30px;
    height: 30px;
    font-size: 1.4em;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
}

/* Üzerine gelince belirginleşir */
.fullscreen-toggle-btn:hover {
    color: #b52b2b;
    transform: scale(1.1);
}

/* TAM EKRAN MODU AKTİF OLDUĞUNDA ÇALIŞACAK KODLAR */
body.fullscreen-mode .main-header {
    display: none !important; /* Header'ı tamamen yok et */
}

/* ============================================================
   ÇOKLU EKRAN (MULTI-MONITOR) VE ANİMASYON STİLLERİ
   ============================================================ */

/* Sağ-Sol Geçiş Okları */
.screen-nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    color: #eee;
    border: 2px solid #444;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5em;
    cursor: pointer;
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(3px);
}

.screen-nav-arrow:hover {
    background: rgba(181, 43, 43, 0.9);
    border-color: #b52b2b;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 0 15px rgba(181, 43, 43, 0.6);
}

#nav-screen-left { left: 15px; }
#nav-screen-right { right: 15px; }

/* Ayarlar Modalı İçindeki Ekran Sekmeleri */
.screen-tab {
    background: #333;
    color: #aaa;
    border: 1px solid #444;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: 0.2s;
    white-space: nowrap;
}
.screen-tab:hover { background: #444; }
.screen-tab.active {
    background: #b52b2b;
    color: #fff;
    border-color: #b52b2b;
    font-weight: bold;
    box-shadow: 0 0 8px rgba(181, 43, 43, 0.5);
}

/* Animasyonların Pürüzsüz Çalışması İçin */
#dm-grid {
    will-change: transform, opacity;
}

@media (max-width: 900px) {
    .desktop-nav { display: none; }
    .menu-icon { display: block; }
    .nav-grid-btn { margin-right: 15px; } 
}
@media (max-width: 600px) {
    .panel-type-options { grid-template-columns: 1fr; }
}

/* ============================================================
   MOBİL (TELEFON) GÖRÜNÜMÜ UYARLAMALARI
   ============================================================ */
@media screen and (max-width: 768px) {
    /* Izgarayı mobilde 1 Sütun, 2 Satır olacak şekilde zorla */
    .screen {
        grid-template-columns: 1fr !important;
        grid-template-rows: 1fr 1fr !important;
        overflow-y: auto; /* Taşan içerikler için kaydırma çubuğu */
    }
    
    /* İnisiyatif tablosundaki arama çubuğu ve butonların boyutlarını dar ekrana uydur */
    .ct-controls { flex-wrap: wrap; justify-content: flex-end; }
    .ct-smart-input { font-size: 16px; } /* Mobilde inputa tıklayınca zoom yapmasını da engeller */
}

/* ============================================================
   DM SCREEN ÖZEL UYARI PENCERELERİ (CUSTOM ALERTS)
   ============================================================ */
.dm-custom-modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); z-index: 100000;
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(3px);
}
.dm-custom-modal-box {
    background: #1a1a1a; border: 1px solid #b52b2b; border-radius: 8px;
    padding: 20px; width: 350px; text-align: center; color: #eee;
    box-shadow: 0 10px 40px rgba(0,0,0,0.9);
    animation: popIn 0.2s ease-out;
}
@keyframes popIn { 0% { transform: scale(0.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
.dm-custom-modal-msg { font-size: 1.1em; margin-bottom: 20px; line-height: 1.4; }
.dm-custom-modal-input {
    width: 100%; padding: 10px; margin-bottom: 15px; background: #111;
    border: 1px solid #444; color: #fff; border-radius: 4px; text-align: center;
    font-size: 1.1em; outline: none; transition: 0.2s; box-sizing: border-box;
}
.dm-custom-modal-input:focus { border-color: #b52b2b; }
.dm-custom-modal-btns { display: flex; gap: 10px; justify-content: center; }
.dm-custom-modal-btn {
    padding: 10px 15px; border: none; border-radius: 4px; cursor: pointer;
    font-weight: bold; flex: 1; transition: 0.2s; font-size: 1em;
}
.dm-custom-modal-btn.confirm { background: #b52b2b; color: white; }
.dm-custom-modal-btn.confirm:hover { background: #d13d3d; }
.dm-custom-modal-btn.cancel { background: #444; color: white; }
.dm-custom-modal-btn.cancel:hover { background: #555; }

/* TAM EKRAN MODU AKTİF OLDUĞUNDA ÇALIŞACAK KODLAR (Güncellendi) */
body.fullscreen-mode .main-header {
    display: none !important; /* Desktop'ta requestedFullscreen sonrası, Mobilde Pseudo Fullscreen */
}

/* Header gittiğinde Grid çok tepeye yapışmasın diye ekstra boşluk */
body.fullscreen-mode .dmscreen-container {
    padding-top: 5px; 
}

/* YENİ: Mobilde simgeyi "Header'ı Kapat" veya "Aç" yapacak stiller */
@media (max-width: 1366px) {
    .fullscreen-toggle-btn {
        color: rgba(255, 255, 255, 0.4); /* Mobilde biraz daha belirgin */
    }
    .fullscreen-toggle-btn.active::before {
        content: '✕'; /* Header gizliyken simgeyi X yap */
    }
}