<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Akkurtcast - Ayarlar</title>
    <link rel="icon" type="image/png" href="/static/img/icon.png">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <style>
        :root { --sidebar-bg: #1a1d21; --sidebar-hover: #2a2e35; --sidebar-text: #a8b2c0; --accent: #0d6efd; --page-bg: #f0f2f5; --card-bg: #fff; --card-border: #e2e8f0; }
        * { box-sizing: border-box; }
        body { background: var(--page-bg); margin: 0; font-family: system-ui, -apple-system, sans-serif; }
        .sidebar { min-height: 100vh; background: var(--sidebar-bg); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
        .brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 16px; color: #fff; font-weight: 800; font-size: 1.05rem; border-bottom: 1px solid #2a2e35; flex-shrink: 0; }
        .brand img { width: 46px; height: 46px; object-fit: contain; border-radius: 8px; }
        .brand-mark { display: flex; flex-direction: column; min-width: 0; line-height: 1.05; }
        .brand-name { color: #f8fafc; font-size: 1.18rem; font-weight: 850; letter-spacing: .2px; text-shadow: 0 1px 0 rgba(0,0,0,.25); }
        .brand-subtitle { margin-top: 4px; color: #7dd3fc; font-size: .63rem; font-weight: 700; letter-spacing: 1.25px; text-transform: uppercase; }
        .nav-section-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #4a5568; padding: 14px 18px 4px; }
        .sidebar a { color: var(--sidebar-text); display: flex; align-items: center; gap: 8px; padding: 9px 18px; text-decoration: none; font-size: 0.875rem; font-weight: 500; border-left: 3px solid transparent; transition: all 0.15s; }
        .sidebar a:hover { background: var(--sidebar-hover); color: #fff; }
        .sidebar a.active { background: rgba(13,110,253,0.12); color: #4d9fff; border-left-color: var(--accent); }
        .sidebar a .nav-icon { width: 22px; height: 22px; min-width: 22px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-size: .78rem; line-height: 1; box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 6px 14px rgba(0,0,0,.18); }
.nav-icon-panel { background: linear-gradient(135deg,#2563eb,#38bdf8); }
.nav-icon-music { background: linear-gradient(135deg,#7c3aed,#ec4899); }
.nav-icon-jingle { background: linear-gradient(135deg,#f59e0b,#f97316); }
.nav-icon-library { background: linear-gradient(135deg,#0f766e,#22c55e); }
.nav-icon-calendar { background: linear-gradient(135deg,#dc2626,#fb7185); }
.nav-icon-automation { background: linear-gradient(135deg,#475569,#94a3b8); }
.nav-icon-news { background: linear-gradient(135deg,#0891b2,#06b6d4); }
.nav-icon-broadcast { background: linear-gradient(135deg,#4338ca,#818cf8); }
.nav-icon-dj { background: linear-gradient(135deg,#111827,#64748b); }
.nav-icon-mobile { background: linear-gradient(135deg,#0e7490,#14b8a6); }
.nav-icon-reports { background: linear-gradient(135deg,#16a34a,#84cc16); }
.nav-icon-widget { background: linear-gradient(135deg,#9333ea,#22d3ee); }
.nav-icon-backup { background: linear-gradient(135deg,#6b7280,#d97706); }
.nav-icon-settings { background: linear-gradient(135deg,#334155,#0ea5e9); }
.nav-icon-logout { background: linear-gradient(135deg,#7f1d1d,#ef4444); }
.sidebar a:hover .nav-icon, .sidebar a.active .nav-icon { transform: translateY(-1px); box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 8px 18px rgba(13,110,253,.25); }
        .sidebar-footer { margin-top: auto; border-top: 1px solid #2a2e35; padding: 8px 0; }
        .topbar { background: #fff; border-bottom: 1px solid var(--card-border); padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 100; }
        .topbar-title { font-weight: 700; font-size: 0.95rem; color: #1a202c; }
        .card-panel { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; overflow: hidden; }
        .card-panel-header { padding: 14px 20px; border-bottom: 1px solid var(--card-border); display: flex; align-items: center; gap: 12px; }
        .card-panel-header .title { font-weight: 700; font-size: 0.9rem; color: #1a202c; flex: 1; }
        .card-panel-header .subtitle { font-size: 0.78rem; color: #64748b; margin-top: 2px; }
        .card-panel-body { padding: 20px; }
        .action-btn { border-radius: 8px; font-weight: 600; font-size: 0.875rem; }
        .section-icon { width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1rem; flex-shrink: 0; }
        .ftp-box { background: var(--page-bg); border: 1px solid var(--card-border); border-radius: 8px; padding: 16px; }
        .ftp-box .ftp-title { font-weight: 700; font-size: 0.85rem; margin-bottom: 8px; }
        .ftp-box .ftp-row { font-size: 0.82rem; color: #374151; margin-bottom: 3px; }
        .ftp-box .ftp-row span { color: #64748b; }
        .disk-bar { height: 8px; border-radius: 4px; background: #e2e8f0; overflow: hidden; margin-bottom: 6px; }
        .disk-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, #0d6efd, #60a5fa); }
        @media (max-width: 767px) {
            .sidebar { min-height: auto; height: auto; position: static; flex-direction: row; overflow-x: auto; overflow-y: hidden; white-space: nowrap; }
            .brand { border-bottom: none; border-right: 1px solid #2a2e35; padding: 12px 14px; }
            .nav-section-label { display: none; }
            .sidebar a { padding: 12px 14px; border-left: none; border-bottom: 3px solid transparent; }
            .sidebar a.active { border-left-color: transparent; border-bottom-color: var(--accent); }
            .sidebar-footer { margin-top: 0; border-top: none; }
            .topbar { padding: 10px 16px; }
            .card-panel-body { padding: 14px; }
        }
    
        /* Mobile shell fix: keep the sidebar from squeezing content on phones. */
        @media (max-width: 767px) {
            html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
            .container-fluid > .row.g-0 { display: block; width: 100%; margin: 0; }
            aside.sidebar,
            .sidebar {
                width: 100% !important;
                min-width: 0 !important;
                max-width: 100% !important;
                min-height: auto !important;
                height: auto !important;
                position: relative !important;
                top: auto !important;
                flex-direction: row !important;
                align-items: stretch;
                overflow-x: auto;
                overflow-y: hidden;
                white-space: nowrap;
                -webkit-overflow-scrolling: touch;
            }
            .brand { min-width: 188px; padding: 10px 12px !important; }
            .brand img { width: 40px !important; height: 40px !important; }
            .brand-name { font-size: 1rem !important; }
            .brand-subtitle { font-size: .55rem !important; letter-spacing: .9px !important; }
            .sidebar a { flex: 0 0 auto; padding: 12px 10px !important; }
            .sidebar a .nav-icon { width: 28px; height: 28px; min-width: 28px; }
            .sidebar-footer { display: flex; flex: 0 0 auto; }
            main.col,
            main[class*="col"] {
                display: block;
                width: 100% !important;
                max-width: 100% !important;
                flex: 0 0 100% !important;
                min-width: 0 !important;
            }
            .topbar { position: sticky; top: 0; z-index: 50; padding: 10px 14px !important; }
            .topbar-title { font-size: 1rem; }
            .topbar-status { font-size: .75rem; padding: 4px 9px; }
            main > .p-4 { padding: 14px !important; }
            .card-panel { border-radius: 10px; }
            .card-panel-header { align-items: flex-start; flex-direction: column; padding: 14px !important; }
            .card-panel-header > .d-flex,
            .card-panel-header .d-flex { flex-wrap: wrap; }
            .card-panel-body { padding: 14px !important; }
            .broadcast-controls { display: grid !important; grid-template-columns: 1fr; gap: 10px; }
            .broadcast-controls .action-btn { width: 100%; min-height: 44px; }
            .stream-row,
            .stream-actions { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; }
            .stream-url,
            .stream-row a { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
            .history-item { align-items: flex-start; }
            .history-time { margin-left: 0; white-space: normal; }
            .now-playing-card { padding: 16px !important; }
            .next-track-box .next-path { white-space: normal; overflow-wrap: anywhere; }
        }
    </style>
</head>
<body>
<div class="container-fluid p-0">
    <div class="row g-0">
        <aside class="col-12 col-md-auto sidebar p-0" style="width: 220px; min-width: 220px;">
            <div class="brand">
                <img src="/static/img/akkurtcast-badge.png" alt="Akkurtcast">
                <span class="brand-mark"><span class="brand-name">Akkurtcast</span><span class="brand-subtitle">Broadcast Panel</span></span>
            </div>
            <div class="nav-section-label">Yayın</div>
            <a href="/"><span class="nav-icon nav-icon-panel"><i class="bi bi-house-door-fill"></i></span> Panel</a>
            <a href="/muzik"><span class="nav-icon nav-icon-music"><i class="bi bi-music-note-beamed"></i></span> Müzik listesi</a>
            <a href="/jingle"><span class="nav-icon nav-icon-jingle"><i class="bi bi-bell-fill"></i></span> Jingle listesi</a>
            <a href="/kutuphane"><span class="nav-icon nav-icon-library"><i class="bi bi-folder-fill"></i></span> Kütüphane</a>
            <div class="nav-section-label">Planlama</div>
            <a href="/takvim"><span class="nav-icon nav-icon-calendar"><i class="bi bi-calendar-week-fill"></i></span> Takvim</a>
            <a href="/otomasyon"><span class="nav-icon nav-icon-automation"><i class="bi bi-sliders"></i></span> Otomasyon</a>
            <a href="/haber-bulteni"><span class="nav-icon nav-icon-news"><i class="bi bi-newspaper"></i></span> Haber Bülteni</a>
            <div class="nav-section-label">Yayın Araçları</div>
            <a href="/naklen-yayin"><span class="nav-icon nav-icon-broadcast"><i class="bi bi-broadcast-pin"></i></span> Naklen Yayın</a>
            <a href="/dj"><span class="nav-icon nav-icon-dj"><i class="bi bi-headphones"></i></span> DJ</a>
            <a href="/mobil"><span class="nav-icon nav-icon-mobile"><i class="bi bi-phone-fill"></i></span> Mobil</a>
            <div class="nav-section-label">Sistem</div>
            <a href="/raporlar"><span class="nav-icon nav-icon-reports"><i class="bi bi-bar-chart-fill"></i></span> Raporlar</a>
            <a href="/widgetler"><span class="nav-icon nav-icon-widget"><i class="bi bi-puzzle-fill"></i></span> Widget</a>
            <a href="/yedek"><span class="nav-icon nav-icon-backup"><i class="bi bi-device-hdd-fill"></i></span> Yedek</a>
            <a class="active" href="/ayarlar"><span class="nav-icon nav-icon-settings"><i class="bi bi-gear-fill"></i></span> Ayarlar</a>
            <div class="sidebar-footer">
                <a href="/logout"><span class="nav-icon nav-icon-logout"><i class="bi bi-box-arrow-right"></i></span> Çıkış</a>
            </div>
        </aside>
        <main class="col p-0" style="min-width: 0;">
            <div class="topbar">
                <div class="topbar-title">Ayarlar</div>
                <span class="text-muted small">Europe/Istanbul</span>
            </div>
            <div class="p-4">
                <form method="post" action="/ayarlar-kaydet" class="vstack gap-4">

                    <!-- Yayın Bilgileri -->
                    <div class="card-panel">
                        <div class="card-panel-header">
                            <div class="section-icon" style="background:#eff6ff;">📻</div>
                            <div>
                                <div class="title">Yayın Bilgileri</div>
                                <div class="subtitle">İstasyon adı, tür ve açıklama</div>
                            </div>
                        </div>
                        <div class="card-panel-body">
                            <div class="row g-3">
                                <div class="col-md-4">
                                    <label class="form-label small fw-semibold">Radyo adı</label>
                                    <input class="form-control form-control-sm" name="station_name" value="{{ ayarlar.station_name }}">
                                </div>
                                <div class="col-md-4">
                                    <label class="form-label small fw-semibold">Müzik tarzı</label>
                                    <input class="form-control form-control-sm" name="station_genre" value="{{ ayarlar.station_genre }}">
                                </div>
                                <div class="col-md-4">
                                    <label class="form-label small fw-semibold">URL adresi</label>
                                    <input class="form-control form-control-sm" name="station_url" value="{{ ayarlar.station_url }}">
                                </div>
                                <div class="col-md-8">
                                    <label class="form-label small fw-semibold">Tanım</label>
                                    <textarea class="form-control form-control-sm" name="station_description" rows="2">{{ ayarlar.station_description }}</textarea>
                                </div>
                                <div class="col-md-4">
                                    <label class="form-label small fw-semibold">Boş playlist metası</label>
                                    <input class="form-control form-control-sm" name="empty_playlist_metadata" value="{{ ayarlar.empty_playlist_metadata }}">
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Geçiş & Ses -->
                    <div class="card-panel">
                        <div class="card-panel-header">
                            <div class="section-icon" style="background:#f0fdf4;">🎚️</div>
                            <div>
                                <div class="title">Geçiş ve Ses</div>
                                <div class="subtitle">Crossfade, fade in/out, jingle geçiş süresi</div>
                            </div>
                        </div>
                        <div class="card-panel-body">
                            <div class="row g-3 align-items-center">
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="crossfade_enabled" id="crossfadeEnabled" {% if ayarlar.crossfade_enabled %}checked{% endif %}>
                                        <label class="form-check-label small" for="crossfadeEnabled">Çapraz geçiş aktif</label>
                                    </div>
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Crossfade (sn)</label>
                                    <input class="form-control form-control-sm" type="number" step="0.1" min="0" max="20" name="crossfade_duration" value="{{ ayarlar.crossfade_duration }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Fade in (sn)</label>
                                    <input class="form-control form-control-sm" type="number" step="0.1" min="0" max="20" name="fade_in" value="{{ ayarlar.fade_in }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Fade out (sn)</label>
                                    <input class="form-control form-control-sm" type="number" step="0.1" min="0" max="20" name="fade_out" value="{{ ayarlar.fade_out }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="smart_crossfade" id="smartCrossfade" {% if ayarlar.smart_crossfade %}checked{% endif %}>
                                        <label class="form-check-label small" for="smartCrossfade">DJ tarzı akıllı geçiş</label>
                                    </div>
                                </div>
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="normalize_audio" id="normalizeAudio" {% if ayarlar.normalize_audio %}checked{% endif %}>
                                        <label class="form-check-label small" for="normalizeAudio">Ses dengele</label>
                                    </div>
                                </div>
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="auto_restart" id="autoRestartSettings" {% if ayarlar.auto_restart %}checked{% endif %}>
                                        <label class="form-check-label small" for="autoRestartSettings">Yayın düşerse toparla</label>
                                    </div>
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Jingle geçiş fade (sn)</label>
                                    <input class="form-control form-control-sm" type="number" step="0.1" min="0" max="7" name="jingle_transition" value="{{ ayarlar.jingle_transition }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Jingle→Müzik giriş (sn)</label>
                                    <input class="form-control form-control-sm" type="number" step="0.1" min="0" max="7" name="jingle_music_overlap" value="{{ ayarlar.jingle_music_overlap }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Üste binince müzik (%)</label>
                                    <input class="form-control form-control-sm" type="number" min="0" max="100" name="jingle_duck_volume" value="{{ ayarlar.jingle_duck_volume }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Şarkı bitişinde kaç sn önce (sn)</label>
                                    <input class="form-control form-control-sm" type="number" step="0.1" min="0" max="60" name="song_end_before" value="{{ ayarlar.song_end_before }}">
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Ses İşleme -->
                    <div class="card-panel">
                        <div class="card-panel-header">
                            <div class="section-icon" style="background:#fdf4ff;">🎛️</div>
                            <div>
                                <div class="title">Ses İşleme</div>
                                <div class="subtitle">EQ, kompresör, limiter — radyo yayın sesi için</div>
                            </div>
                        </div>
                        <div class="card-panel-body">
                            <div class="row g-3 align-items-center">
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="audio_processing_enabled" id="audioProcessing" {% if ayarlar.audio_processing_enabled %}checked{% endif %}>
                                        <label class="form-check-label small" for="audioProcessing">İşlemci aktif</label>
                                    </div>
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Preset</label>
                                    <select name="audio_preset" class="form-select form-select-sm" id="audioPreset">
                                        {% for key, label in presets.items() %}
                                        <option value="{{ key }}" {% if ayarlar.audio_preset == key %}selected{% endif %}>{{ label }}</option>
                                        {% endfor %}
                                    </select>
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Bass kazancı</label>
                                    <input class="form-control form-control-sm" type="number" min="0" max="10" step="0.5" name="bass_gain" value="{{ ayarlar.bass_gain }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Boğukluk kontrolü</label>
                                    <input class="form-control form-control-sm" type="number" min="-6" max="6" step="0.5" name="low_mid_gain" value="{{ ayarlar.low_mid_gain }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Vokal parlaklığı</label>
                                    <input class="form-control form-control-sm" type="number" min="-6" max="6" step="0.5" name="presence_gain" value="{{ ayarlar.presence_gain }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Hava / tiz</label>
                                    <input class="form-control form-control-sm" type="number" min="-6" max="6" step="0.5" name="air_gain" value="{{ ayarlar.air_gain }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Çok bant sıkılık</label>
                                    <input class="form-control form-control-sm" type="number" min="0" max="10" step="0.5" name="multiband_strength" value="{{ ayarlar.multiband_strength }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Kompresör</label>
                                    <input class="form-control form-control-sm" type="number" min="0" max="10" step="0.5" name="compressor_strength" value="{{ ayarlar.compressor_strength }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Çıkış kazancı (dB)</label>
                                    <input class="form-control form-control-sm" type="number" min="-6" max="6" step="0.5" name="output_gain" value="{{ ayarlar.output_gain }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="limiter_enabled" id="limiterEnabled" {% if ayarlar.limiter_enabled %}checked{% endif %}>
                                        <label class="form-check-label small" for="limiterEnabled">Limiter açık</label>
                                    </div>
                                </div>
                            </div>
                            <div class="small text-muted mt-3">Normalize → bass boost → çok bant EQ → kompresör → limiter zinciri ile tok ve dengeli yayın sesi.</div>
                        </div>
                    </div>

                    <!-- FTP / SFTP -->
                    <div class="card-panel">
                        <div class="card-panel-header">
                            <div class="section-icon" style="background:#fff7ed;">📂</div>
                            <div>
                                <div class="title">FTP / SFTP Erişimi</div>
                                <div class="subtitle">Müzik ve jingle dosyası yüklemek için</div>
                            </div>
                        </div>
                        <div class="card-panel-body">
                            <div class="row g-3">
                                <div class="col-md-4">
                                    <div class="ftp-box">
                                        <div class="ftp-title">📁 FTP</div>
                                        <div class="ftp-row">Host: <span>{{ ftp_host }}</span></div>
                                        <div class="ftp-row">Port: <span>21</span></div>
                                        <div class="ftp-row">Kullanıcı: <span>radyo</span></div>
                                        <div class="ftp-row">Şifre: <span>{{ ayarlar.ftp_password }}</span></div>
                                        <div class="small text-muted mt-2">WinSCP ile FTP seçersen media ve jingle klasörleri görünür.</div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <div class="ftp-box">
                                        <div class="ftp-title">🔒 SFTP (Önerilen)</div>
                                        <div class="ftp-row">Host: <span>{{ ftp_host }}</span></div>
                                        <div class="ftp-row">Port: <span>2222</span></div>
                                        <div class="ftp-row">Kullanıcı: <span>radyo</span></div>
                                        <div class="ftp-row">Şifre: <span>{{ ayarlar.ftp_password }}</span></div>
                                        <div class="small text-muted mt-2">Daha güvenli; aynı klasörleri gösterir.</div>
                                    </div>
                                </div>
                                <div class="col-md-4">
                                    <label class="form-label small fw-semibold">Yeni şifre belirle</label>
                                    <input class="form-control form-control-sm" name="ftp_password" value="{{ ayarlar.ftp_password }}" autocomplete="new-password">
                                    <div class="form-text small">Kaydedince FTP ve SFTP yeniden açılır.</div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- Kayıt & Koruma -->
                    <div class="card-panel">
                        <div class="card-panel-header">
                            <div class="section-icon" style="background:#fef2f2;">🛡️</div>
                            <div>
                                <div class="title">Kayıt ve Koruma</div>
                                <div class="subtitle">Yayın kaydı, sessizlik algılama, baş/son kırpma</div>
                            </div>
                        </div>
                        <div class="card-panel-body">
                            <div class="row g-3 align-items-center">
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="recording_enabled" id="recordingEnabled" {% if ayarlar.recording_enabled %}checked{% endif %}>
                                        <label class="form-check-label small" for="recordingEnabled">Yayını kaydet</label>
                                    </div>
                                </div>
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="silence_detection_enabled" id="silenceDetection" {% if ayarlar.silence_detection_enabled %}checked{% endif %}>
                                        <label class="form-check-label small" for="silenceDetection">Sessizlik algıla</label>
                                    </div>
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Sessizlik süresi (sn)</label>
                                    <input class="form-control form-control-sm" type="number" min="5" max="120" name="silence_seconds" value="{{ ayarlar.silence_seconds }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Sessizlik eşiği (dB)</label>
                                    <input class="form-control form-control-sm" type="number" min="-80" max="-10" name="silence_threshold" value="{{ ayarlar.silence_threshold }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="trim_silence_enabled" id="trimSilence" {% if ayarlar.trim_silence_enabled %}checked{% endif %}>
                                        <label class="form-check-label small" for="trimSilence">Baş/son boşluğu atla</label>
                                    </div>
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Boşluk atlama (sn)</label>
                                    <input class="form-control form-control-sm" type="number" min="1" max="8" step="0.5" name="trim_silence_seconds" value="{{ ayarlar.trim_silence_seconds }}">
                                </div>
                                <div class="col-md-3 col-6">
                                    <label class="form-label small fw-semibold">Boşluk eşiği (dB)</label>
                                    <input class="form-control form-control-sm" type="number" min="-80" max="-10" name="trim_silence_threshold" value="{{ ayarlar.trim_silence_threshold }}">
                                </div>
                            </div>
                            <div class="small text-muted mt-3">Kayıtlar recordings klasörüne tarih/saat şeklinde düşer.</div>
                        </div>
                    </div>

                    <!-- Disk -->
                    <div class="card-panel">
                        <div class="card-panel-header">
                            <div class="section-icon" style="background:#f0fdf4;">💽</div>
                            <div class="title">Disk Kullanımı</div>
                        </div>
                        <div class="card-panel-body py-3">
                            <div class="d-flex justify-content-between align-items-center mb-2">
                                <span class="small text-muted">{{ disk.used_gb }} GB kullanıldı</span>
                                <span class="small text-muted">{{ disk.free_gb }} GB boş · toplam {{ disk.total_gb }} GB</span>
                            </div>
                            <div class="disk-bar"><div class="disk-bar-fill" style="width: {{ disk.percent }}%"></div></div>
                        </div>
                    </div>

                    <div class="d-flex justify-content-end pb-2">
                        <button class="btn btn-primary action-btn px-4">Kaydet ve yayını yenile</button>
                    </div>
                </form>
            </div>
        </main>
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
const presetValues = {
    natural: { bass_gain: 0, low_mid_gain: 0, presence_gain: 0, air_gain: 0, multiband_strength: 0, compressor_strength: 1, output_gain: 0 },
    pop_radio: { bass_gain: 3, low_mid_gain: -1, presence_gain: 2, air_gain: 1.5, multiband_strength: 2, compressor_strength: 4, output_gain: 1 },
    bass_strong: { bass_gain: 6, low_mid_gain: -0.5, presence_gain: 1.5, air_gain: 1, multiband_strength: 2, compressor_strength: 4, output_gain: 0 },
    bright: { bass_gain: 2, low_mid_gain: -1.5, presence_gain: 3, air_gain: 2.5, multiband_strength: 3, compressor_strength: 5, output_gain: 1 },
    night_soft: { bass_gain: 1, low_mid_gain: -0.5, presence_gain: 0.5, air_gain: 0, multiband_strength: 1, compressor_strength: 2, output_gain: -1 }
};
document.getElementById('audioPreset').addEventListener('change', (e) => {
    const preset = presetValues[e.target.value];
    if (!preset) return;
    Object.entries(preset).forEach(([name, value]) => {
        const input = document.querySelector(`[name="${name}"]`);
        if (input) input.value = value;
    });
});
</script>
<script src="/static/js/mobile-nav.js"></script>
</body>
</html>









