/* main.css */
/* Meriono Web 2.0 Master Stylesheet */
/* FINAL REVISION: UI Swap (Timer Right / Controls Left) */
/* UPDATED: Connected Controls (Wrapper Architecture) */

/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --bg-body: #000;
    --stage-radius: 32px;
    --white: #ffffff;
    --text-dark: #1a1b26;
    --accent-orange: #ff914d;
    --accent-yellow: #f39c12;
    --bar-bg: rgba(255, 255, 255, 0.3);
    --border-width: 1.5px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --font-main: 'Lato', sans-serif;
    --font-display: 'Nunito', sans-serif;
}

* {
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
    padding: 0;
}

input, textarea { user-select: text; }

html, body {
    width: 100%;
    min-height: 100vh;
    background-color: var(--bg-body);
    font-family: var(--font-main);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* =========================================
   2. STAGE & VIDEO LAYERS
   ========================================= */
#meriono-stage {
    position: relative;
    width: 95%;
    max-width: 1280px;
    height: 56.25vw; 
    max-height: 90vh;
    aspect-ratio: 16 / 9;
    border-radius: var(--stage-radius);
    overflow: hidden;
    isolation: isolate;
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
    background: #111;
    margin: 20px auto;
    cursor: default;
}

#meriono-stage.user-idle { cursor: none; }

/* KRİTİK GÜNCELLEME (IDLE STATE FIX):
   Kullanıcı boşta kaldığında (idle), Overlay içindeki tüm öğeleri gizle,
   ANCAK .timer-widget-container sınıfına sahip öğeyi (Sayaç) HARİÇ TUT.
   
   Böylece sayaç ekranda kalırken diğerleri kaybolur.
*/
#meriono-stage.user-idle .overlay > *:not(.timer-widget-container) { 
    opacity: 0;
    pointer-events: none; /* Görünmez butonlara yanlışlıkla tıklanmasını önler */
    transition: opacity 0.5s ease;
}

#atmVideo, .overlay, .loader {
    position: absolute !important;
    top: 0; left: 0; width: 100%; height: 100%;
}

#atmVideo {
    object-fit: cover;
    border-radius: var(--stage-radius);
    z-index: 0;
}

.loader {
    display: none;
    align-items: center; justify-content: center;
    z-index: 5; background: rgba(0,0,0,0.4);
}
.loader::after {
    content: ""; width: 50px; height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* =========================================
   3. UI OVERLAY STRUCTURE
   ========================================= */
.overlay {
    padding: 30px;
    z-index: 10;
    pointer-events: none; /* Konteyner tıklanamaz, içerik tıklanabilir */
    transition: opacity 0.5s ease;
}
.overlay > * { pointer-events: auto; }

/* 3.1 Top Right Controls (ARTIK SOLDA) */
.top-right {
    position: absolute; top: 30px; left: 30px; /* Right -> Left */
    display: flex; flex-direction: column; gap: 16px;
    align-items: flex-start; /* flex-end -> flex-start */
}
.control-row { 
    display: flex; align-items: center; gap: 14px; 
    flex-direction: row-reverse; /* [Label][Btn] -> [Btn][Label] görünümü için */
}
.control-label {
    color: var(--white); font-size: 15px; font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.control-btn {
    width: 44px; height: 44px;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: var(--transition);
}
.control-btn:hover { transform: scale(1.1); background: #fff; }
.icon { width: 18px; height: 18px; fill: #000; }

/* 3.2 Bottom Controls Wrapper (YENİ YAPISAL GRUPLAMA) */
.bottom-controls-group {
    position: absolute;
    left: 30px;
    bottom: 30px;
    display: flex;
    align-items: flex-end; /* Slider ve butonları alttan hizalar */
    gap: 50px;
    z-index: 20;
}

/* 3.3 Volume Sliders */
.volume-group {
    /* Position removed here, handled by wrapper */
    display: flex; gap: 20px;
}
.vol-slider-wrapper {
    display: flex; flex-direction: column; align-items: center; gap: 8px; height: 140px;
}
.vol-label {
    color: var(--white); font-size: 12px; font-weight: 900;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}
.custom-slider {
    position: relative; width: 6px; flex: 1;
    background: var(--bar-bg); border-radius: 4px;
    cursor: pointer; display: flex; align-items: flex-end;
}
.slider-fill {
    width: 100%; background: var(--white);
    border-radius: 4px; pointer-events: none;
}
.slider-knob {
    position: absolute; left: 50%;
    transform: translateX(-50%) translateY(50%);
    width: 18px; height: 18px; background: transparent;
    border: 3px solid var(--white); border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0,0,0,0.5);
    pointer-events: none; transition: bottom 0.1s linear;
}

/* 3.4 Atmosphere Selector */
.atmosphere-list-wrapper {
    /* Position removed here, handled by wrapper */
    display: flex; flex-direction: column;
    align-items: flex-start; /* Butonları sola yaslar */
    gap: 12px; 
    /* z-index ebeveyn tarafından yönetilir */
}
.atm-row { display: flex; gap: 8px; }
.atm-pill {
    background: var(--white); color: var(--text-dark);
    padding: 8px 20px; border-radius: 999px;
    font-size: 13px; font-weight: 700;
    border: 2px solid transparent; cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    white-space: nowrap;
}
.atm-pill:hover, .atm-pill.active {
    background: #000; color: #fff; border-color: #fff;
}

/* =========================================
   4. LEFT SIDE MUSIC PANEL
   ========================================= */
.panel-toggle {
    position: absolute; left: 20px; top: 50%;
    transform: translateY(-50%);
    width: 40px; height: 60px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 30;
    color: #fff; font-size: 32px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.7);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.5s ease;
}
.panel-toggle.open {
    transform: translateY(-50%) translateX(330px) rotate(180deg);
}

.music-panel {
    position: absolute; top: 20px; bottom: 20px; left: 20px;
    width: 320px; background: var(--white);
    border-radius: 24px;
    box-shadow: 10px 0 40px rgba(0,0,0,0.6);
    transform: translateX(-120%);
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 25; display: flex; flex-direction: column;
    padding: 20px; gap: 10px; color: var(--text-dark);
}
.music-panel.open { transform: translateX(0); }

.mp-header {
    display: flex; justify-content: space-between;
    border-bottom: 1px solid #e0e0e0; padding-bottom: 12px; margin-bottom: 5px;
}
.mp-mode-btn {
    width: 80px; height: 40px; border-radius: 10px; border: 2px solid #000;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s;
}
.mp-mode-btn:hover { background: #f0f0f0; }
.mp-mode-btn.active { background: #000; color: #fff; }
.mp-mode-btn svg { width: 22px; height: 22px; fill: currentColor; }

.mp-list {
    flex: 1; overflow-y: auto; display: flex; flex-direction: column;
    gap: 6px; padding-right: 5px;
}
.mp-list::-webkit-scrollbar { width: 4px; }
.mp-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.mp-row {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 4px; font-size: 14px; font-weight: 600;
}
.mp-row.active-track span { color: var(--accent-orange) !important; }
.mp-play-icon { width: 32px; height: 32px; flex-shrink: 0; cursor: pointer; color: #000; }
.mp-row.active-track .mp-play-icon { color: var(--accent-orange); }
.mp-add-icon {
    width: 24px; height: 24px; border: 2px solid currentColor; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; cursor: pointer; flex-shrink: 0; color: #000;
}
.mp-add-icon svg { width: 12px; height: 12px; fill: currentColor; }

.mp-footer {
    border-top: 1px solid #e0e0e0; padding-top: 12px;
    display: flex; flex-direction: column; gap: 8px;
}
.mp-mode-label { font-size: 11px; font-weight: 700; text-align: center; color: #666; margin-bottom: 4px;}
.mp-controls-box {
    border: 2px solid #000; border-radius: 20px; padding: 10px 16px;
    display: flex; align-items: center; justify-content: space-between; height: 90px;
}
.mp-nav-btn { cursor: pointer; font-size: 24px; color: #000; font-weight: 300; }
.mp-info { display: flex; flex-direction: column; align-items: center; flex: 1; text-align: center; }
.mp-now-playing { font-size: 14px; font-weight: 500; color: #000; margin-bottom: 6px; margin-top: 8px; }
.mp-next-playing { font-size: 10px; font-weight: 600; color: #666; margin-bottom: 8px; }
.warning-text { color: var(--accent-yellow) !important; font-weight: 700 !important; }
.mp-bottom-actions { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; width: 100%; margin-top: 4px; }
.dots-side { display: flex; gap: 12px; align-items: center; }
.dots-side.left { justify-content: flex-end; padding-right: 6px; }
.dots-side.right { justify-content: flex-start; padding-left: 6px; }
.mp-dot { width: 6px; height: 6px; border-radius: 50%; border: 1px solid #000; }
.mp-dot.filled { background: #000; }
.mp-dot.viewing { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #000; }
.mp-action-x {
    width: 16px; height: 16px; background: #000; border-radius: 50%; color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 900; cursor: pointer;
}

/* =========================================
   5. TIMER WIDGET (ARTIK SAĞ ÜST)
   ========================================= */
.timer-widget-container {
    position: absolute;
    top: 30px; right: 30px; /* Left -> Right */
    display: flex; align-items: center; gap: 12px;
    cursor: pointer; 
    z-index: 40; /* Overlay(50) altındadır. Overlay açılınca tıklanamaz. */
    transition: transform 0.2s;
    flex-direction: row-reverse; /* [Ring][Time] -> [Time][Ring] görünümü için */
}
.timer-widget-container:hover { transform: scale(1.05); }

.timer-widget-ring {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s;
}
.timer-widget-ring svg { width: 24px; height: 24px; stroke: white; }

/* Halka Animasyonu (Sadece Hover) */
.timer-widget-container:hover .timer-widget-ring {
    border-color: #fff;
    background: rgba(0, 0, 0, 0.5);
    animation: rotateRing 8s linear infinite;
}
@keyframes rotateRing { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Timer Metni */
.timer-widget-time {
    font-family: var(--font-display);
    font-weight: 900; font-size: 32px;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
    opacity: 1; transition: opacity 0.3s;
    pointer-events: auto;
}

/* UX KURALI: .hidden class
   Bu class UI.js tarafından isTextVisible state'ine göre kontrol edilir.
   Asla kendi kendine oluşmaz.
*/
.timer-widget-time.hidden { 
    opacity: 0; 
    pointer-events: none; 
}

/* =========================================
   6. TIMER MENU OVERLAY (MODAL)
   ========================================= */
.mt-overlay-wrapper {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    display: flex; align-items: center; justify-content: center;
    
    z-index: 50; /* Widget(40)'dan üstündür */
    opacity: 0;
    pointer-events: none; /* Varsayılan: Pasif (Alttakiler tıklanabilir) */
    
    transition: opacity 0.3s ease;
}

/* UX KURALI: .open class
   Bu class UI.js tarafından isMenuOpen state'ine göre kontrol edilir.
   Açıldığında pointer-events: auto olur ve Widget'ı bloklar.
*/
.mt-overlay-wrapper.open { 
    opacity: 1; 
    pointer-events: auto; 
}

.mt-card {
    background: var(--white);
    border-radius: 24px;
    border: var(--border-width) solid #000;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    padding: 18px;
    width: 90%; max-width: 420px;
    transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.mt-overlay-wrapper.open .mt-card { transform: translateY(0); }

.mt-header-actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-bottom: 10px;
}
.mt-icon-btn {
    width: 32px; height: 32px; border-radius: 8px;
    border: 1.5px solid #ddd; background: transparent;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    color: #666; transition: all 0.2s; font-size: 16px;
}
.mt-icon-btn:hover { border-color: #000; color: #000; background: #f5f5f5; }

/* --- GÖSTER/GİZLE BUTONU ACTIVE STATE (SİYAH) --- */
.mt-icon-btn.active-black {
    background: #000;
    border-color: #000;
    color: #fff;
}

/* Göz dış hatları */
.mt-icon-btn.active-black svg path {
    fill: #fff;
    stroke: #fff;
}

/* Gözün iç yuvarlağı */
.mt-icon-btn.active-black svg circle {
    fill: #000;
    stroke: #fff;
}
/* ----------------------------------------------- */

/* =========================================
   7. TIMER CARD INTERNALS
   ========================================= */
.mt-top { display: flex; justify-content: center; margin-bottom: 14px; }
.mt-tabs { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.mt-tab {
    height: 36px; padding: 0 16px; border-radius: 50px;
    border: var(--border-width) solid #000; background: #fff;
    font-weight: 900; font-size: 12px; cursor: pointer; transition: var(--transition);
}
.mt-tab:hover { transform: translateY(-1px); }
.mt-tab.active { background: #000; color: #fff; }

.mt-main { display: flex; flex-direction: column; gap: 14px; }

.mt-clock {
    background: #000; color: #fff; border-radius: 28px;
    padding: 30px 20px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    position: relative; overflow: hidden; min-height: 160px;
}
.mt-phase {
    position: absolute; top: 20px; left: 20px;
    font-weight: 800; font-size: 13px; letter-spacing: 2px;
    text-transform: uppercase; padding: 4px 12px; border-radius: 99px;
    border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.1);
    backdrop-filter: blur(4px);
}
.mt-phase.focus { border-color: rgba(255,255,255,0.3); color: #fff; }
.mt-phase.break { border-color: var(--accent-orange); color: var(--accent-orange); background: rgba(255, 145, 77, 0.1); }

.mt-time {
    font-family: var(--font-display); font-weight: 900; font-size: 76px;
    letter-spacing: -3px; line-height: 1; font-variant-numeric: tabular-nums;
    margin-top: 0;
}

.mt-progress {
    height: 10px; border-radius: 999px; background: rgba(0,0,0,.12);
    overflow: hidden; border: 1px solid rgba(0,0,0,.18);
}
.mt-progress-fill {
    height: 100%; width: 0%; background: #000; transition: width 1s linear;
}

.mt-row { display: flex; gap: 10px; flex-wrap: wrap; }
.mt-btn {
    flex: 1; min-width: 80px; height: 44px; border-radius: 14px;
    border: var(--border-width) solid #000; background: #fff;
    font-weight: 900; cursor: pointer; transition: var(--transition);
    display: flex; align-items: center; justify-content: center;
    padding: 0; overflow: hidden;
}
.mt-btn:hover { transform: translateY(-1px); }
.mt-btn.primary { background: #000; color: #fff; }
.mt-btn.warn { border-color: var(--accent-yellow); color: var(--accent-yellow); }
.mt-btn:disabled { opacity: 0.4; cursor: not-allowed; filter: grayscale(100%); }

.mt-confirm-row { display: flex; width: 100%; height: 100%; }
.mt-confirm-btn {
    flex: 1; display: flex; align-items: center; justify-content: center;
    height: 100%; color: #000; background: transparent;
    border: none; cursor: pointer; padding: 0; margin: 0; transition: all 0.2s;
}
.mt-confirm-btn.no { border-right: var(--border-width) solid #000; }
.mt-confirm-btn:hover { background: #000; color: #fff; }

.mt-status {
    text-align: center; font-weight: 700; font-size: 13px; color: #666;
    margin-top: 4px; min-height: 16px;
}
.mt-info-bar {
    display: flex; justify-content: space-between; align-items: center;
    font-size: 11px; font-weight: 800; color: #666;
    padding: 0 4px 8px 4px; margin-bottom: -6px; border-bottom: 1px solid #e0e0e0;
}
.mt-info-bar b { color: #000; }

.mt-builder-row { display: none; gap: 8px; margin-bottom: 6px; padding: 0 2px; }
.mt-builder-row.show { display: flex; }
.mt-cb-input, .mt-cb-select {
    flex: 1; height: 36px; border-radius: 10px;
    border: var(--border-width) solid #000; padding: 0 10px;
    font-weight: 800; font-size: 13px; outline: none;
}
.mt-cb-add {
    width: 36px; height: 36px; border-radius: 10px;
    border: var(--border-width) solid #000;
    background: #000; color: #fff; font-weight: 900; font-size: 18px;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
}

.mt-playlist {
    display: flex; flex-direction: column; gap: 6px;
    margin-top: 4px; padding-top: 10px;
    max-height: 160px; overflow-y: auto;
}
.mt-playlist::-webkit-scrollbar { width: 4px; }
.mt-playlist::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }

.mt-play-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px; border: var(--border-width) solid #e0e0e0;
    border-radius: 10px; cursor: pointer; transition: var(--transition);
    background: #fafafa; flex-shrink: 0;
}
.mt-play-item:hover { border-color: #000; background: #fff; }
.mt-play-item.active { background: #000; border-color: #000; color: #fff; }
.mt-play-item.drag-over { border: 2px dashed #000; background: #f0f0f0; opacity: 0.7; }
.mt-play-text {
    font-size: 12px; font-weight: 700; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; margin-right: 8px;
}
.mt-play-dur { font-size: 11px; font-weight: 900; opacity: 0.7; white-space: nowrap; }
.mt-play-item.active .mt-play-dur { opacity: 1; }
.mt-play-del {
    width: 20px; height: 20px; border-radius: 50%;
    background: #eee; color: #000;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 900; margin-left: 8px;
    cursor: pointer; transition: var(--transition);
}
.mt-play-del:hover { background: #ff4d4d; color: #fff; }

/* Responsive */
@media (max-width: 900px) {
    .top-right {
        /* Mobil ortalama: Sağ yerine sol referans alınıp ortalandı */
        top: 20px; left: 50%; transform: translateX(-50%); align-items: center;
    }

    /* MOBİL İÇİN YENİ KAPSAYICI AYARLARI */
    .bottom-controls-group {
        left: 50%; 
        transform: translateX(-50%);
        bottom: 20px;
        flex-direction: column-reverse; /* Butonlar Üstte, Sliderlar Altta */
        align-items: center;
        gap: 24px;
    }

    .music-panel { width: 100%; max-width: 300px; }
    
    .timer-widget-time { font-size: 24px; }
    .timer-widget-ring { width: 36px; height: 36px; }
}