<?php
session_start();
if (!isset($_SESSION['kul_id'])) {
    header('Location: index.php');
    exit;
}

require_once 'database/connect.php';

$kul_id = $_SESSION['kul_id'];
$k_rol = $_SESSION['k_rol'] ?? ($_SESSION['rol'] ?? ($_SESSION['yetki'] ?? 'user'));
$is_admin = in_array(strtolower(trim((string)$k_rol)), ['admin', 'yonetici', 'yönetici', '1', 'true'], true);

// Panel ayarları
$panelQ = $db->query("SELECT * FROM panel WHERE id = 1");
$panel = $panelQ->fetch(PDO::FETCH_ASSOC) ?? [];
$whatsapp = $panel['whatsapp'] ?? '+90 553 242 3230';
$whatsapp_link = preg_replace('/\D+/', '', $whatsapp);
$whatsapp_baslik = $panel['whatsapp_baslik'] ?? 'DALTON PANEL HİZMETLERİ';
$iban = $panel['iban'] ?? '';
$ibanad = $panel['ibanad'] ?? '';
$banka = $panel['banka'] ?? '';
$duyuru = $panel['duyuru'] ?? '';
$dom_panel = $panel["dom_panel"] ?? "";
$dom_sahibinden = $panel["dom_sahibinden"] ?? "";
$dom_dolap = $panel["dom_dolap"] ?? "";
$dom_trendyol = $panel["dom_trendyol"] ?? "";
$dom_letgo = $panel["dom_letgo"] ?? "";
$dom_pttavm = $panel["dom_pttavm"] ?? "";
$dom_turkcell = $panel["dom_turkcell"] ?? "";
$dom_shopier = $panel["dom_shopier"] ?? "";
$dom_hepsiburada = $panel["dom_hepsiburada"] ?? "";
$dom_pazarama = $panel["dom_pazarama"] ?? "";
$dom_a101 = $panel["dom_a101"] ?? "";

// İstatistikler - Benzersiz ürün sayısı (grup_id'ye göre)
$tables = ['ilan_sahibinden', 'ilan_dolap', 'ilan_trendyol', 'ilan_letgo', 'ilan_pttavm', 'ilan_turkcell', 'ilan_shopier'];
$toplam_ilan = 0;
$aktif_ilan = 0;
$grupIdler = [];

foreach ($tables as $table) {
    try {
        $q = $db->prepare("SELECT grup_id, ilandurum FROM $table WHERE ekleyen = ?");
        $q->execute([$kul_id]);
        $rows = $q->fetchAll(PDO::FETCH_ASSOC);
        foreach ($rows as $row) {
            $gid = $row['grup_id'] ?? null;
            if ($gid && !in_array($gid, $grupIdler)) {
                $grupIdler[] = $gid;
                $toplam_ilan++;
                if (($row['ilandurum'] ?? '0') == '1') {
                    $aktif_ilan++;
                }
            }
        }
    } catch (Exception $e) {}
}

// Dekont sayısı (dekontlar tablosundan)
try {
    $dekontQ = $db->prepare("SELECT COUNT(*) as total FROM dekontlar WHERE ekleyen = ?");
    $dekontQ->execute([$kul_id]);
    $toplam_dekont = $dekontQ->fetch()['total'] ?? 0;
} catch (Exception $e) { $toplam_dekont = 0; }

// Veri sayısı
try {
    $veriQ = $db->prepare("SELECT COUNT(*) as total FROM hesaplar WHERE ekleyen = ?");
    $veriQ->execute([$kul_id]);
    $toplam_veri = $veriQ->fetch()['total'] ?? 0;
} catch (Exception $e) { $toplam_veri = 0; }
?>
<!DOCTYPE html>
<html lang="tr" style="background:#0a0a0f !important;">
<head>
<style>
html, body { background: #0a0a0f !important; }
.modal-backdrop { background: #0a0a0f !important; opacity: 0.9 !important; }
</style>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="HandheldFriendly" content="true">
    <title>• ✦ • T  Panel © 2026- PLATINIUM | ULTRA</title>
    <link rel="icon" href="assets/media/kerto.png">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Black+Ops+One&family=Poppins:wght@300;400;500;600;700;800&display=swap" rel="stylesheet">
    <link href="assets/css/dalton-premium.css?v=draven-clean-final-1" rel="stylesheet">
    
<style id="draven-clean-final-css">
html,body{background:#000!important;color:#fff!important;overflow-x:hidden!important;}body{padding-bottom:70px!important;}
body::before,body::after,.main-content::before,.main-content::after{display:none!important;content:none!important;animation:none!important;}
.draven-reference-mode .main-content{position:relative!important;z-index:1!important;background:transparent!important;padding-bottom:80px!important;}
.draven-matrix-bg{position:fixed!important;inset:52px 0 0 0!important;background:#020202!important;overflow:hidden!important;pointer-events:none!important;z-index:0!important;}
.draven-matrix-bg::before{content:''!important;position:absolute!important;inset:0!important;background:radial-gradient(circle at 50% 24%,rgba(0,255,119,.16),transparent 25%),linear-gradient(180deg,rgba(0,255,120,.06),transparent 42%,rgba(0,255,120,.05))!important;}
.draven-matrix-bg span{position:absolute!important;top:-180px!important;width:22px!important;color:rgba(0,255,110,.48)!important;font:700 12px/18px monospace!important;text-align:center!important;white-space:pre-line!important;text-shadow:0 0 7px rgba(0,255,110,.55)!important;animation:dravenMatrixFall linear infinite!important;opacity:.65!important;}
@keyframes dravenMatrixFall{0%{transform:translateY(-20vh)}100%{transform:translateY(130vh)}}
.header-section,.stats-row,.ego-banner,.search-section,.tabs-container,.tab-content,.bottom-right-float,.draven-bottom-nav,.bottom-calc-float{position:relative!important;z-index:2!important;}
.header-section{height:52px!important;min-height:52px!important;padding:0 8px!important;background:radial-gradient(circle at 18% 20%,rgba(255,255,255,.18),transparent 8%),radial-gradient(circle at 80% 15%,rgba(255,255,255,.12),transparent 9%),linear-gradient(90deg,#8c008f 0%,#bc00b5 45%,#670071 100%)!important;border:0!important;border-bottom:2px solid #00b8ff!important;box-shadow:0 0 16px rgba(145,0,255,.8)!important;overflow:hidden!important;}
.header-section::before{content:''!important;position:absolute!important;inset:0!important;background-image:radial-gradient(1px 1px at 8% 22%,#fff,transparent),radial-gradient(1px 1px at 25% 62%,#fff,transparent),radial-gradient(1.5px 1.5px at 58% 28%,#fff,transparent),radial-gradient(1px 1px at 76% 70%,#fff,transparent),radial-gradient(1px 1px at 92% 35%,#fff,transparent)!important;background-size:120px 52px!important;opacity:.8!important;animation:dravenStars 14s linear infinite!important;}
@keyframes dravenStars{from{background-position:0 0}to{background-position:120px 0}}
.header-flex{height:52px!important;min-height:52px!important;align-items:center!important;position:relative!important;z-index:2!important;}
.header-logo-left,.header-logo-right{width:38px!important;height:38px!important;max-width:38px!important;flex:0 0 38px!important;border-radius:50%!important;overflow:hidden!important;background:#fff!important;border:2px solid #00c8ff!important;box-shadow:0 0 10px rgba(0,210,255,.9)!important;}
.panel-logo,.rotating-logo{width:100%!important;height:100%!important;object-fit:cover!important;border:0!important;border-radius:50%!important;animation:none!important;filter:none!important;}
.brand-center-only{height:52px!important;display:flex!important;align-items:center!important;justify-content:center!important;overflow:hidden!important;}
.brand-title{font-family:'Black Ops One','Poppins',sans-serif!important;font-size:11px!important;line-height:1.05!important;font-weight:900!important;letter-spacing:.5px!important;color:#ff8a12!important;text-align:center!important;text-shadow:0 0 5px #ff4d00,0 0 12px rgba(255,145,0,.9),0 1px 0 #fff!important;animation:dravenTitleGlow 2.6s ease-in-out infinite alternate!important;white-space:normal!important;}
.brand-title small{font-size:9px!important;color:#ff6514!important;text-shadow:0 0 7px rgba(255,100,20,.95)!important;}
@keyframes dravenTitleGlow{from{filter:brightness(1)}to{filter:brightness(1.32)}}
.stats-row{display:grid!important;grid-template-columns:repeat(3,1fr)!important;gap:14px!important;padding:15px 0 12px!important;margin:0!important;justify-items:center!important;background:transparent!important;}
.stat-box{width:120px!important;height:78px!important;min-width:0!important;padding:14px 8px 8px!important;border:0!important;border-radius:4px!important;background:linear-gradient(90deg,#a0009b 0%,#7b006e 55%,#0a030d 100%)!important;box-shadow:0 0 18px rgba(187,0,255,.35)!important;display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important;overflow:hidden!important;transform:none!important;}
.stat-box.green{order:2!important}.stat-box.cyan{order:1!important}.stat-box.orange{order:3!important}.stat-box::before{display:none!important}.stat-box:hover{transform:none!important}
.stat-box i{font-size:15px!important;margin:0 0 7px!important;color:#fff!important;text-shadow:0 0 8px rgba(255,255,255,.9)!important;animation:none!important;}.stat-title{font-size:10px!important;line-height:1.15!important;color:#fff!important;font-weight:900!important;letter-spacing:0!important;text-transform:uppercase!important;margin:0 0 4px!important;text-align:center!important;}.stat-value{font-size:20px!important;color:#fff!important;font-weight:900!important;line-height:1!important;text-shadow:0 0 8px rgba(255,255,255,.9)!important;}
.ego-banner,.ego-banner.dekont-style-banner{width:calc(100% - 8px)!important;max-width:none!important;min-height:98px!important;margin:0 4px 9px!important;padding:13px 8px 12px!important;border:2px solid #00ff84!important;border-radius:8px!important;background:linear-gradient(180deg,rgba(0,25,10,.98),rgba(0,0,0,.98))!important;box-shadow:0 0 14px rgba(0,255,132,.95),inset 0 0 18px rgba(0,255,132,.18)!important;text-align:center!important;overflow:hidden!important;position:relative!important;color:#00ff84!important;}
.ego-banner::before,.ego-banner::after{display:none!important;content:none!important}.ego-banner span{position:relative!important;z-index:2!important;display:block!important;color:#00ff84!important;font-size:18px!important;line-height:1.2!important;font-weight:900!important;text-shadow:0 0 8px rgba(0,255,132,1),0 0 14px rgba(0,255,132,.7)!important;letter-spacing:.4px!important;white-space:normal!important;}.ego-banner .ref-small{display:block!important;margin-top:7px!important;color:#caffdf!important;font-size:11px!important;font-weight:800!important;text-shadow:0 0 7px rgba(0,255,132,.8)!important;}.ego-banner .ref-phone{display:block!important;margin-top:9px!important;color:#32ff92!important;font-size:18px!important;font-weight:900!important;text-shadow:0 0 8px rgba(0,255,132,1)!important;}.ego-banner .crown{color:#ffd15a!important;font-size:18px!important;margin:0 5px!important;text-shadow:0 0 8px rgba(255,210,60,.9)!important;}
.ego-banner .ego-banner-sweep,#ego-banner-sweep-final{display:block!important;position:absolute!important;top:0!important;bottom:0!important;left:-42%!important;width:34%!important;height:100%!important;background:linear-gradient(100deg,transparent 0%,rgba(255,255,255,.1) 18%,rgba(255,255,255,.9) 48%,rgba(0,255,132,.55) 60%,transparent 100%)!important;box-shadow:0 0 18px rgba(255,255,255,.9),0 0 28px rgba(0,255,132,.8)!important;transform:skewX(-22deg)!important;animation:dravenBannerSweep 4.2s ease-in-out infinite alternate!important;z-index:1!important;opacity:.9!important;}@keyframes dravenBannerSweep{0%{left:-42%}100%{left:110%}}
.search-section{padding:0 22px 10px!important;background:transparent!important}.search-box{max-width:none!important;width:100%!important;display:grid!important;grid-template-columns:1fr 48px!important;gap:6px!important;margin:0!important}.search-input{height:51px!important;background:#070707!important;border:2px solid #a200ff!important;border-radius:5px!important;color:#fff!important;font-size:12px!important;padding:0 13px!important;box-shadow:0 0 13px rgba(162,0,255,.95)!important}.search-input::placeholder{color:#a9a9a9!important}.btn-search{height:51px!important;width:48px!important;padding:0!important;border-radius:6px!important;background:#9600ff!important;border:0!important;color:#fff!important;box-shadow:0 0 13px rgba(162,0,255,.95)!important;font-size:0!important}.btn-search i{font-size:18px!important;margin:0!important;color:#fff!important}
.tabs-container{padding:0 2px!important;margin:0!important;background:transparent!important;border:0!important;box-shadow:none!important;overflow:hidden!important}.tabs-container::after{display:none!important}.nav-tabs-custom{display:grid!important;grid-template-columns:repeat(5,1fr)!important;gap:2px!important;overflow:visible!important;padding:0!important;margin:0!important;border:0!important}.nav-tabs-custom .nav-item{min-width:0!important;margin:0!important}.nav-tabs-custom .nav-link{height:36px!important;padding:5px 2px!important;border:2px solid rgba(255,255,255,.78)!important;border-bottom:0!important;border-radius:4px 4px 0 0!important;background:linear-gradient(180deg,#8d008b,#470047)!important;color:#fff!important;font-size:8px!important;font-weight:900!important;display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important;gap:2px!important;text-shadow:0 1px 2px #000!important;box-shadow:inset 0 0 8px rgba(255,255,255,.08)!important;white-space:nowrap!important}.nav-tabs-custom .nav-link.active{background:linear-gradient(180deg,#a600a2,#560056)!important;color:#fff!important;border-color:#fff!important}.nav-tabs-custom .nav-link i{display:block!important;font-size:12px!important;margin:0!important;color:#fff!important}
.table-section,.tab-content{background:transparent!important;margin:0!important;padding:0!important;border:0!important;box-shadow:none!important;min-height:0!important}.tab-pane{background:transparent!important;min-height:0!important}.table-container,.table-responsive{background:transparent!important;border:0!important;border-radius:0!important;padding:0!important;margin:0!important;box-shadow:none!important;overflow-x:auto!important;min-height:0!important}.table{margin-bottom:0!important}table{border-collapse:separate!important;border-spacing:0!important}.table thead{background:#001eff!important}.table thead th{background:#001eff!important;color:#fff!important;font-size:11px!important;font-weight:900!important;text-align:center!important;padding:13px 8px!important;border:0!important;white-space:nowrap!important}.table tbody{background:transparent!important}.table tbody tr{background:#fff!important;border:0!important;box-shadow:none!important}.table tbody tr:nth-child(even){background:#f2f2f2!important}.table tbody td{background:inherit!important;color:#666!important;border:0!important;padding:10px 7px!important;font-size:12px!important;font-weight:500!important;text-align:center!important;vertical-align:middle!important;line-height:1.35!important;height:auto!important}.table tbody td::before{display:none!important;content:none!important}#tab-ilanlar table{width:100%!important;min-width:720px!important;background:transparent!important;color:#555!important;border:0!important;display:table!important}#tab-ilanlar thead{display:table-header-group!important}#ilanlarBody{display:table-row-group!important;width:auto!important;padding:0!important;background:transparent!important}#ilanlarBody tr{display:table-row!important;border:0!important;border-radius:0!important;min-height:0!important;padding:0!important}#ilanlarBody td{display:table-cell!important;min-width:0!important}#ilanlarBody td:nth-child(4),#ilanlarBody td:nth-child(5){text-align:left!important;white-space:normal!important;min-width:88px!important}#ilanlarBody td:nth-child(6){width:70px!important;min-width:70px!important;height:auto!important;border-radius:0!important;overflow:visible!important}#ilanlarBody td:nth-child(6) img{width:52px!important;height:52px!important;max-width:52px!important;max-height:52px!important;object-fit:cover!important;border-radius:2px!important;display:block!important;margin:0 auto!important}#ilanlarBody .btn-link-copy,#ilanlarBody .btn-link-go,#ilanlarBody .btn-copy,#ilanlarBody .btn-edit,#ilanlarBody .btn-islem,#ilanlarBody button,#ilanlarBody a.btn{min-height:38px!important;padding:6px 8px!important;border-radius:2px!important;color:#fff!important;font-size:10px!important;font-weight:900!important;line-height:1.05!important;box-shadow:none!important;transform:none!important;text-decoration:none!important}#ilanlarBody .btn-link-copy,#ilanlarBody .btn-copy{background:#f1584b!important;background-image:none!important}#ilanlarBody .btn-link-go{background:#8d168b!important;background-image:none!important}#ilanlarBody .aktif,#ilanlarBody .toggle-status.aktif,#ilanlarBody .ilan-status-btn.aktif{display:inline-block!important;background:#008d17!important;color:#fff!important;border-radius:2px!important;padding:6px 7px!important;font-size:10px!important;font-weight:900!important}#ilanlarBody .pasif,#ilanlarBody .toggle-status.pasif{display:inline-block!important;background:#d71920!important;color:#fff!important;border-radius:2px!important;padding:6px 7px!important;font-size:10px!important;font-weight:900!important}.ilan-card-render{display:none!important}#tab-ilanlar.ilan-card-mode .table-container{display:block!important}
.bottom-menu.bottom-simple-nav-exact{display:none!important}.bottom-calc-float{display:none!important}.bottom-right-float{position:fixed!important;right:0!important;bottom:74px!important;z-index:2147483002!important;display:block!important;background:transparent!important;pointer-events:none!important}.bottom-right-float .float-ilan,.bottom-right-float .float-kargo{display:none!important}.bottom-right-float .float-admin{display:flex!important;pointer-events:auto!important;height:43px!important;min-width:118px!important;border-radius:8px 0 0 8px!important;background:rgba(0,0,0,.92)!important;border:1px solid rgba(0,255,180,.45)!important;color:#00ffb5!important;box-shadow:0 0 14px rgba(0,255,180,.4)!important;font-size:11px!important;font-weight:900!important;align-items:center!important;justify-content:center!important;gap:7px!important;padding:0 10px!important}.bottom-right-float .float-admin i{color:#00ffb5!important;font-size:16px!important}
.draven-bottom-nav{position:fixed!important;left:0!important;right:0!important;bottom:0!important;height:64px!important;z-index:2147483644!important;background:linear-gradient(180deg,#8d008b,#520052)!important;border-top:2px solid #d166d1!important;display:grid!important;grid-template-columns:repeat(4,1fr)!important;box-shadow:0 -4px 16px rgba(0,0,0,.65)!important}.draven-bottom-nav a{display:flex!important;flex-direction:column!important;align-items:center!important;justify-content:center!important;gap:4px!important;color:#fff!important;text-decoration:none!important;font-size:8px!important;font-weight:900!important;line-height:1.1!important;text-align:center!important;border-left:1px solid rgba(255,255,255,.12)!important}.draven-bottom-nav a:first-child{border-left:0!important}.draven-bottom-nav i{font-size:14px!important;color:#fff!important}.draven-bottom-badge{position:absolute!important;right:4px!important;top:3px!important;background:#ffd51a!important;color:#000!important;border-radius:50%!important;width:15px!important;height:15px!important;font-size:9px!important;line-height:15px!important;font-weight:900!important}
@media(max-width:576px){.brand-title{font-size:10px!important}.brand-title small{font-size:8px!important}.header-logo-left,.header-logo-right{width:34px!important;height:34px!important;flex-basis:34px!important}.stats-row{gap:10px!important;padding-top:14px!important}.stat-box{width:120px!important;max-width:31vw!important;height:78px!important}.stat-title{font-size:9px!important}.stat-value{font-size:18px!important}.ego-banner,.ego-banner.dekont-style-banner{min-height:98px!important}.ego-banner span{font-size:17px!important}.ego-banner .ref-small{font-size:10px!important}.ego-banner .ref-phone{font-size:18px!important}.search-section{padding-left:22px!important;padding-right:22px!important}.nav-tabs-custom .nav-link{font-size:7.5px!important}.nav-tabs-custom .nav-link i{font-size:11px!important}}
</style>

    <style>
        /* Override ve ek stiller (ana stiller dalton-premium.css'te) */
        .user-section {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        /* Ek stiller - platform dropdown ve özel durumlar */
        
        .btn-green { background: #28a745; color: #fff; }
        .btn-cyan { background: #17a2b8; color: #fff; }
        .btn-orange { background: #ff6600; color: #fff; }
        .btn-purple { background: #6f42c1; color: #fff; }
        .btn-red { background: #dc3545; color: #fff; }
        
        .btn-sm-custom {
            padding: 4px 10px;
            font-size: 11px;
            border-radius: 4px;
            border: none;
            margin: 1px;
            cursor: pointer;
        }
        .alert-popup p { margin: 0; font-size: 14px; }
        
        /* Vergi Bilgileri Card Tasarımı */
        .vergi-cards-container {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
            gap: 15px;
            padding: 15px;
        }
        
        .vergi-card {
            background: linear-gradient(145deg, #1e1e2e, #151520);
            border-radius: 12px;
            border: 1px solid #333;
            overflow: hidden;
            transition: transform 0.2s, box-shadow 0.2s;
        }
        
        .vergi-card:hover {
            transform: translateY(-3px);
            box-shadow: 0 8px 25px rgba(0,0,0,0.4);
            border-color: #ff6600;
        }
        
        .vergi-card-header {
            padding: 12px 15px;
            background: linear-gradient(135deg, #ff6600, #ff8533);
            color: #fff;
        }
        
        .vergi-header-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;
        }
        
        .vergi-header-bottom {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding-top: 8px;
            border-top: 1px solid rgba(255,255,255,0.3);
        }
        
        .vergi-urun {
            font-weight: bold;
            font-size: 14px;
            max-width: 70%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        
        .vergi-platform {
            background: rgba(0,0,0,0.2);
            padding: 2px 8px;
            border-radius: 10px;
            font-size: 11px;
        }
        
        .vergi-miktar {
            color: #00ff00;
            font-weight: bold;
        }
        
        .vergi-id {
            font-weight: bold;
            font-size: 14px;
        }
        
        .vergi-tarih {
            font-size: 12px;
            opacity: 0.9;
        }
        
        .vergi-card-body {
            padding: 15px;
        }
        
        .vergi-row {
            display: flex;
            align-items: flex-start;
            gap: 10px;
            padding: 8px 0;
            border-bottom: 1px solid #2a2a3a;
            color: #ccc;
            font-size: 13px;
        }
        
        .vergi-row:last-child {
            border-bottom: none;
        }
        
        .vergi-row i {
            color: #ff6600;
            width: 18px;
            text-align: center;
            margin-top: 2px;
        }
        
        .vergi-row span {
            flex: 1;
            word-break: break-word;
        }
        
        .vergi-adres {
            font-size: 12px;
            color: #999;
        }
        
        /* İlan İşlem Butonları */
        .btn-duzenle {
            background: #17a2b8;
            color: #fff;
            border: none;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 11px;
            cursor: pointer;
            margin: 1px;
        }
        
        .btn-cogalt {
            background: #6f42c1;
            color: #fff;
            border: none;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 11px;
            cursor: pointer;
            margin: 1px;
        }
        
        .btn-sil {
            background: #dc3545;
            color: #fff;
            border: none;
            padding: 4px 8px;
            border-radius: 4px;
            font-size: 11px;
            cursor: pointer;
            margin: 1px;
        }
        
        .btn-duzenle:hover { background: #138496; }
        .btn-cogalt:hover { background: #5a32a3; }
        .btn-sil:hover { background: #c82333; }
        
        /* Edit Section Stilleri */
        .edit-section {
            background: #1a1a25;
            border-radius: 8px;
            padding: 15px;
            margin-bottom: 15px;
            border: 1px solid #333;
        }
        
        .edit-section-title {
            color: #ff6600;
            font-size: 14px;
            margin-bottom: 12px;
            padding-bottom: 8px;
            border-bottom: 1px solid #333;
        }
        
        .edit-section-title i {
            margin-right: 8px;
        }
        
        .edit-images-container {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }
        
        .edit-image-item {
            position: relative;
            width: 80px;
            height: 80px;
            border-radius: 8px;
            overflow: hidden;
            border: 2px solid #333;
        }
        
        .edit-image-item img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .edit-image-item .remove-img {
            position: absolute;
            top: 2px;
            right: 2px;
            background: #dc3545;
            color: #fff;
            border: none;
            border-radius: 50%;
            width: 20px;
            height: 20px;
            font-size: 10px;
            cursor: pointer;
        }
        
        /* İşlem Butonları - Güzel Tasarım */
        .islem-butonlari {
            display: flex;
            gap: 5px;
            flex-wrap: wrap;
            justify-content: center;
        }
        
        .btn-islem {
            display: inline-flex;
            align-items: center;
            gap: 4px;
            padding: 6px 12px;
            border-radius: 6px;
            font-size: 11px;
            font-weight: 500;
            border: none;
            cursor: pointer;
            transition: all 0.2s;
        }
        
        .btn-islem i {
            font-size: 10px;
        }
        
        .btn-islem-duzenle {
            background: linear-gradient(135deg, #17a2b8, #138496);
            color: #fff;
        }
        
        .btn-islem-duzenle:hover {
            background: linear-gradient(135deg, #138496, #117a8b);
            transform: translateY(-1px);
        }
        
        .btn-islem-cogalt {
            background: linear-gradient(135deg, #6f42c1, #5a32a3);
            color: #fff;
        }
        
        .btn-islem-cogalt:hover {
            background: linear-gradient(135deg, #5a32a3, #4a2887);
            transform: translateY(-1px);
        }
        
        .btn-islem-sil {
            background: linear-gradient(135deg, #dc3545, #c82333);
            color: #fff;
        }
        
        .btn-islem-sil:hover {
            background: linear-gradient(135deg, #c82333, #bd2130);
            transform: translateY(-1px);
        }
        
        .platform-count {
            display: inline-block;
            background: #333;
            color: #ff6600;
            padding: 3px 8px;
            border-radius: 10px;
            font-size: 10px;
            margin-bottom: 5px;
        }
        
        /* Global Toggles */
        .global-toggles {
            display: flex;
            justify-content: center;
            gap: 40px;
            padding: 15px 20px;
            background: linear-gradient(135deg, #1a1a25 0%, #0d0d12 100%);
            border-bottom: 1px solid #333;
            margin-bottom: 10px;
        }
        
        .toggle-item {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .toggle-label {
            color: #fff;
            font-weight: bold;
            font-size: 13px;
        }
        
        .toggle-switch {
            position: relative;
            display: inline-block;
            width: 50px;
            height: 26px;
        }
        
        .toggle-switch input {
            opacity: 0;
            width: 0;
            height: 0;
        }
        
        .toggle-slider {
            position: absolute;
            cursor: pointer;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background-color: #dc3545;
            transition: 0.3s;
            border-radius: 26px;
        }
        
        .toggle-slider:before {
            position: absolute;
            content: "";
            height: 20px;
            width: 20px;
            left: 3px;
            bottom: 3px;
            background-color: white;
            transition: 0.3s;
            border-radius: 50%;
        }
        
        .toggle-switch input:checked + .toggle-slider {
            background-color: #28a745;
        }
        
        .toggle-switch input:checked + .toggle-slider:before {
            transform: translateX(24px);
        }
        
        .toggle-status {
            font-size: 11px;
            padding: 3px 8px;
            border-radius: 10px;
            font-weight: bold;
        }
        
        .toggle-status.aktif {
            background: #28a745;
            color: #fff;
        }
        
        .toggle-status.pasif {
            background: #dc3545;
            color: #fff;
        }
        
        /* Mini Toggle (İlan listesinde) */
        .ilan-toggles {
            display: flex;
            gap: 8px;
            align-items: center;
        }
        
        .mini-toggle {
            position: relative;
            display: inline-flex;
            align-items: center;
            gap: 4px;
            cursor: pointer;
        }
        
        .mini-toggle input {
            opacity: 0;
            width: 0;
            height: 0;
            position: absolute;
        }
        
        .mini-slider {
            width: 28px;
            height: 16px;
            background-color: #dc3545;
            border-radius: 16px;
            transition: 0.2s;
            position: relative;
        }
        
        .mini-slider:before {
            content: "";
            position: absolute;
            height: 12px;
            width: 12px;
            left: 2px;
            bottom: 2px;
            background-color: white;
            border-radius: 50%;
            transition: 0.2s;
        }
        
        .mini-toggle input:checked + .mini-slider {
            background-color: #28a745;
        }
        
        .mini-toggle input:checked + .mini-slider:before {
            transform: translateX(12px);
        }
        
        .mini-toggle small {
            font-size: 9px;
            color: #888;
            font-weight: bold;
        }
        
        /* Butonlar - Güzel Tasarım */
        .btn-link-copy {
            color: #fff;
            border-radius: 3px;
            background-image: linear-gradient(122deg, #633991 0%, #c1156c 100%);
            font-weight: 500;
            border: 0;
            padding: 8px 15px;
            font-size: 12px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease-in-out;
            box-shadow: 0px 2px 4px rgba(165, 163, 174, 0.4);
        }
        
        .btn-link-copy:hover {
            transform: translateY(-2px);
            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
        }
        
        .btn-link-go {
            color: #fff;
            border-radius: 3px;
            background-image: linear-gradient(122deg, #d64635 0%, #ff604d 100%);
            font-weight: 500;
            border: 0;
            padding: 8px 15px;
            font-size: 12px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease-in-out;
            box-shadow: 0px 2px 4px rgba(165, 163, 174, 0.4);
            text-decoration: none;
        }
        
        .btn-link-go:hover {
            transform: translateY(-2px);
            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
            color: #fff;
        }
        
        .btn-edit {
            color: #fff;
            border-radius: 3px;
            background-image: linear-gradient(122deg, #28a745 0%, #5dd879 100%);
            font-weight: 500;
            border: 0;
            padding: 6px 12px;
            font-size: 11px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease-in-out;
            box-shadow: 0px 2px 4px rgba(165, 163, 174, 0.4);
        }
        
        .btn-edit:hover {
            transform: translateY(-2px);
            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
        }
        
        .btn-delete {
            color: #fff;
            border-radius: 3px;
            background-image: linear-gradient(122deg, #dc3545 0%, #ff6b6b 100%);
            font-weight: 500;
            border: 0;
            padding: 6px 12px;
            font-size: 11px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease-in-out;
            box-shadow: 0px 2px 4px rgba(165, 163, 174, 0.4);
        }
        
        .btn-delete:hover {
            transform: translateY(-2px);
            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
        }
        
        .btn-copy {
            color: #fff;
            border-radius: 3px;
            background-image: linear-gradient(122deg, #17a2b8 0%, #4fc3dc 100%);
            font-weight: 500;
            border: 0;
            padding: 6px 12px;
            font-size: 11px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            transition: all 0.2s ease-in-out;
            box-shadow: 0px 2px 4px rgba(165, 163, 174, 0.4);
        }
        
        .btn-copy:hover {
            transform: translateY(-2px);
            box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.3);
        }
        
        /* Platform Count Badge */
        .platform-count {
            background: #6f42c1;
            color: #fff;
            padding: 3px 8px;
            border-radius: 10px;
            font-size: 10px;
            font-weight: bold;
            cursor: help;
        }
        
        /* Platform Dropdown Menu */
        .platform-dropdown {
            position: relative;
            display: inline-block;
        }
        
        .platform-dropdown-menu {
            display: none;
            position: absolute;
            top: 100%;
            left: 0;
            z-index: 1000;
            width: 22rem;
            padding: 0.5rem 0;
            margin: 0.125rem 0 0;
            background-color: #fff;
            border-radius: 0.375rem;
            box-shadow: 0 0.25rem 1rem rgba(165, 163, 174, 0.45);
            flex-wrap: wrap;
            justify-content: center;
        }
        
        .platform-dropdown-menu.show {
            display: flex !important;
            flex-wrap: wrap !important;
            justify-content: center !important;
        }
        
        .platform-dropdown-item {
            display: flex;
            align-items: center;
            width: 10rem;
            padding: 0.42rem 1rem;
            color: #5d596c;
            text-decoration: none;
            cursor: pointer;
            transition: all 0.15s ease-in-out;
            border: none;
            background: none;
            font-size: 14px;
        }
        
        .platform-dropdown-item:hover {
            color: #7367f0;
            background-color: rgba(115, 103, 240, 0.08);
        }
        
        .platform-dropdown-item img {
            width: 24px;
            height: 24px;
            border-radius: 4px;
            margin-right: 8px;
        }
        
        .platform-dropdown-item .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-left: auto;
        }
        
        .platform-dropdown-item .status-dot.aktif {
            background-color: #28a745;
        }
        
        .platform-dropdown-item .status-dot.pasif {
            background-color: #dc3545;
        }
        
        /* Overlay for closing dropdown */
        .dropdown-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            z-index: 999;
        }

}
    </style>


<style id="draven-safe-final-fix">
/* Güvenli düzeltme: donma yapmaz, çalışan JS/PHP akışına dokunmaz */
.draven-reference-mode .draven-matrix-bg{
  display:block!important;
  position:fixed!important;
  inset:52px 0 64px 0!important;
  z-index:0!important;
  pointer-events:none!important;
  overflow:hidden!important;
  background:#020202!important;
}
.draven-reference-mode .draven-matrix-bg::before{
  content:''!important;
  position:absolute!important;
  inset:-35% 0!important;
  display:block!important;
  background:
    radial-gradient(circle at 50% 30%,rgba(0,255,120,.16),transparent 34%),
    linear-gradient(180deg,rgba(0,255,120,.035),rgba(0,0,0,0) 38%,rgba(0,255,120,.045))!important;
  animation:dravenMatrixGlowSafe 18s ease-in-out infinite alternate!important;
}
.draven-reference-mode .draven-matrix-bg span{
  display:block!important;
  animation-name:dravenMatrixFallSafe!important;
  animation-timing-function:linear!important;
  animation-iteration-count:infinite!important;
  animation-play-state:running!important;
  animation-duration:46s!important;
  opacity:.72!important;
  color:rgba(0,255,110,.58)!important;
  text-shadow:0 0 7px rgba(0,255,110,.72)!important;
  will-change:transform!important;
}
.draven-reference-mode .draven-matrix-bg span:nth-child(2n){animation-duration:54s!important;opacity:.62!important;}
.draven-reference-mode .draven-matrix-bg span:nth-child(3n){animation-duration:62s!important;opacity:.50!important;}
@keyframes dravenMatrixFallSafe{0%{transform:translate3d(0,-130vh,0)}100%{transform:translate3d(0,130vh,0)}}
@keyframes dravenMatrixGlowSafe{0%{opacity:.56}100%{opacity:.88}}

/* Sol alttaki Hesap Makinesi eski yerinde */
.draven-reference-mode .bottom-calc-float,
html body.draven-reference-mode a.bottom-calc-float{
  display:flex!important;
  position:fixed!important;
  left:0!important;
  bottom:70px!important;
  z-index:2147483600!important;
  width:104px!important;
  height:48px!important;
  border-radius:0 26px 26px 0!important;
  background:rgba(77,77,77,.88)!important;
  border:3px solid rgba(230,230,230,.92)!important;
  border-left:0!important;
  color:#fff!important;
  align-items:center!important;
  justify-content:center!important;
  gap:6px!important;
  text-decoration:none!important;
  font-size:10px!important;
  font-weight:900!important;
  line-height:1.05!important;
  box-shadow:0 0 14px rgba(255,255,255,.22)!important;
  pointer-events:auto!important;
  text-align:left!important;
}
.draven-reference-mode .bottom-calc-float i{color:#ff8d2a!important;font-size:17px!important;margin:0!important;text-shadow:0 0 8px rgba(255,137,42,.4)!important;}
.draven-reference-mode .bottom-calc-float span{display:block!important;color:#fff!important;line-height:1.05!important;}

/* Platform rozeti kalksın */
#ilanlarBody .platform-count,
#tab-ilanlar .platform-count{display:none!important;visibility:hidden!important;}

/* İşlem sütunu ikinci görseldeki gibi: yatay küçük blok butonlar */
#ilanlarBody td:last-child,
#ilanlarBody td:nth-child(10){
  min-width:165px!important;
  text-align:center!important;
  white-space:normal!important;
}
#ilanlarBody td:last-child .islem-butonlari,
#ilanlarBody td:nth-child(10) .islem-butonlari{
  display:flex!important;
  flex-wrap:nowrap!important;
  align-items:center!important;
  justify-content:center!important;
  gap:6px!important;
}
#ilanlarBody td:last-child .btn-islem,
#ilanlarBody td:nth-child(10) .btn-islem,
#ilanlarBody td:last-child button,
#ilanlarBody td:nth-child(10) button{
  width:48px!important;
  min-width:48px!important;
  height:42px!important;
  min-height:42px!important;
  padding:4px 5px!important;
  border-radius:2px!important;
  border:0!important;
  color:#fff!important;
  font-size:9px!important;
  font-weight:900!important;
  line-height:1.05!important;
  text-align:center!important;
  display:inline-flex!important;
  flex-direction:column!important;
  align-items:center!important;
  justify-content:center!important;
  gap:2px!important;
  box-shadow:0 2px 6px rgba(0,0,0,.16)!important;
  white-space:normal!important;
}
#ilanlarBody .btn-islem-duzenle,#ilanlarBody .btn-duzenle,#ilanlarBody .btn-edit{background:#ff8a17!important;background-image:none!important;}
#ilanlarBody .btn-islem-cogalt,#ilanlarBody .btn-cogalt,#ilanlarBody .btn-copy{background:#9b168b!important;background-image:none!important;}
#ilanlarBody .btn-islem-sil,#ilanlarBody .btn-sil,#ilanlarBody .btn-delete{background:#e43642!important;background-image:none!important;}
#ilanlarBody td:last-child .btn-islem i,#ilanlarBody td:nth-child(10) .btn-islem i{display:none!important;}
</style>



<style id="calc-modal-clean-fix">
/* Hesap makinesi modal düzeltmesi - global tablo/buton stillerinden etkilenmesin */
#calcModal .modal-dialog{
  max-width:370px!important;
  margin:70px auto!important;
  padding:0 10px!important;
}
#calcModal .modal-content.calc-modal-content{
  background:#11111d!important;
  border:1px solid rgba(255,102,0,.45)!important;
  border-radius:15px!important;
  overflow:hidden!important;
  box-shadow:0 0 28px rgba(255,102,0,.18),0 16px 45px rgba(0,0,0,.65)!important;
  color:#fff!important;
}
#calcModal .modal-header{
  min-height:58px!important;
  padding:14px 18px!important;
  border:0!important;
  background:#0c0c16!important;
  display:flex!important;
  align-items:center!important;
  justify-content:space-between!important;
}
#calcModal .modal-title{
  margin:0!important;
  color:#ff6b22!important;
  font-size:18px!important;
  font-weight:900!important;
  letter-spacing:.3px!important;
  display:flex!important;
  align-items:center!important;
  gap:10px!important;
}
#calcModal .modal-title i{color:#00d9ff!important;font-size:17px!important;}
#calcModal .close{
  width:34px!important;
  height:34px!important;
  min-width:34px!important;
  padding:0!important;
  margin:0!important;
  border:0!important;
  border-radius:50%!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  background:#ff2525!important;
  color:#fff!important;
  opacity:1!important;
  font-size:25px!important;
  line-height:1!important;
  text-shadow:none!important;
}
#calcModal .modal-body{
  padding:18px!important;
  background:linear-gradient(180deg,#151525,#10101b)!important;
}
#calcModal .calc-display{
  width:100%!important;
  height:48px!important;
  margin:0 0 12px!important;
  padding:0 12px!important;
  border:1px solid rgba(255,255,255,.28)!important;
  border-radius:7px!important;
  background:#f3f3f3!important;
  color:#111!important;
  font-size:24px!important;
  font-weight:700!important;
  text-align:right!important;
  box-shadow:inset 0 2px 7px rgba(0,0,0,.18)!important;
}
#calcModal .calc-grid{
  display:grid!important;
  grid-template-columns:repeat(4,1fr)!important;
  gap:8px!important;
  width:100%!important;
  background:transparent!important;
}
#calcModal .calc-grid button{
  appearance:none!important;
  -webkit-appearance:none!important;
  width:100%!important;
  min-width:0!important;
  height:42px!important;
  min-height:42px!important;
  padding:0!important;
  margin:0!important;
  border:0!important;
  border-radius:8px!important;
  display:flex!important;
  align-items:center!important;
  justify-content:center!important;
  background:linear-gradient(180deg,#29293a,#171724)!important;
  color:#fff!important;
  font-size:16px!important;
  font-weight:900!important;
  line-height:1!important;
  text-align:center!important;
  box-shadow:0 3px 10px rgba(0,0,0,.28), inset 0 0 0 1px rgba(255,255,255,.06)!important;
  text-shadow:none!important;
  cursor:pointer!important;
}
#calcModal .calc-grid button:hover{
  background:linear-gradient(180deg,#34344a,#1d1d2c)!important;
}
#calcModal .calc-grid button:nth-child(4n),
#calcModal .calc-grid button:nth-child(3),
#calcModal .calc-grid button:nth-child(1),
#calcModal .calc-grid button:nth-child(2){
  background:linear-gradient(180deg,#ff7a22,#e54b15)!important;
  color:#fff!important;
}
#calcModal .calc-grid .calc-zero{
  grid-column:span 2!important;
}
#calcModal .calc-grid .calc-equal{
  background:linear-gradient(180deg,#00d9ff,#007cff)!important;
  color:#fff!important;
}
@media(max-width:576px){
  #calcModal .modal-dialog{max-width:calc(100% - 22px)!important;margin:62px auto!important;}
  #calcModal .modal-body{padding:14px!important;}
  #calcModal .calc-grid{gap:7px!important;}
  #calcModal .calc-grid button{height:40px!important;min-height:40px!important;font-size:15px!important;}
}
</style>



<style id="safe-kargo-pill-final-fix">
/* Güvenli son düzeltme: bozuk raw CSS yok; sadece Kargo butonu ve ufak görünüm düzeltmeleri */
html body.draven-reference-mode .bottom-right-float{
  position:fixed!important;
  right:0!important;
  bottom:70px!important;
  z-index:2147483601!important;
  display:flex!important;
  flex-direction:column!important;
  align-items:flex-end!important;
  gap:0!important;
  background:transparent!important;
  pointer-events:none!important;
}
html body.draven-reference-mode .bottom-right-float .float-ilan{
  display:none!important;
}
html body.draven-reference-mode .bottom-right-float .float-kargo,
html body.draven-reference-mode .bottom-right-float a.float-kargo{
  display:flex!important;
  pointer-events:auto!important;
  width:124px!important;
  height:48px!important;
  min-width:0!important;
  padding:0 10px!important;
  margin:0!important;
  border-radius:26px 0 0 26px!important;
  background:rgba(34,91,210,.72)!important;
  border:3px solid rgba(232,238,255,.88)!important;
  border-right:0!important;
  color:#fff!important;
  align-items:center!important;
  justify-content:center!important;
  gap:7px!important;
  text-decoration:none!important;
  font-size:10px!important;
  font-weight:900!important;
  line-height:1.05!important;
  text-align:left!important;
  box-shadow:0 0 14px rgba(88,145,255,.42)!important;
  backdrop-filter:none!important;
  -webkit-backdrop-filter:none!important;
}
html body.draven-reference-mode .bottom-right-float .float-kargo i{
  color:#fff!important;
  font-size:18px!important;
  margin:0!important;
  text-shadow:0 0 8px rgba(255,255,255,.35)!important;
}
html body.draven-reference-mode .bottom-right-float .float-kargo span{
  color:#fff!important;
  display:block!important;
  line-height:1.05!important;
}
html body.draven-reference-mode .bottom-right-float .float-admin,
html body.draven-reference-mode .bottom-right-float a.float-admin{
  display:flex!important;
  pointer-events:auto!important;
  width:124px!important;
  height:43px!important;
  min-width:0!important;
  padding:0 10px!important;
  margin:0 0 7px 0!important;
  border-radius:24px 0 0 24px!important;
  background:rgba(0,0,0,.82)!important;
  border:3px solid rgba(0,255,180,.72)!important;
  border-right:0!important;
  color:#00ffb5!important;
  align-items:center!important;
  justify-content:center!important;
  gap:7px!important;
  text-decoration:none!important;
  font-size:10px!important;
  font-weight:900!important;
  line-height:1.05!important;
  text-align:left!important;
  box-shadow:0 0 14px rgba(0,255,180,.38)!important;
}
html body.draven-reference-mode .bottom-right-float .float-admin i{
  color:#00ffb5!important;
  font-size:17px!important;
  margin:0!important;
}
html body.draven-reference-mode .bottom-right-float .float-admin span{
  color:#00ffb5!important;
  display:block!important;
  line-height:1.05!important;
}
/* Sol hesap makinesi aynı konumda kalsın */
html body.draven-reference-mode .bottom-calc-float{
  display:flex!important;
  left:0!important;
  bottom:70px!important;
}
/* 4 platform rozeti görünmesin */
#ilanlarBody .platform-count,
#tab-ilanlar .platform-count{
  display:none!important;
  visibility:hidden!important;
}
/* İşlem butonları ikinci örnekteki gibi kalsın */
#ilanlarBody td:nth-child(10) .platform-count{display:none!important;}
</style>


<style id="aktif-badge-kucultme-final">
/* Sadece ilan tablosundaki AKTİF/PASİF durum rozetini küçültür */
#ilanlarBody .aktif,
#ilanlarBody .toggle-status.aktif,
#ilanlarBody .ilan-status-btn.aktif,
#ilanlarBody .pasif,
#ilanlarBody .toggle-status.pasif,
#ilanlarBody .ilan-status-btn.pasif {
    font-size: 8px !important;
    font-weight: 800 !important;
    padding: 4px 5px !important;
    line-height: 1 !important;
    min-height: 0 !important;
}
</style>

<style id="whatsapp-banner-link-fix">
html body.draven-reference-mode .ego-banner.dekont-style-banner,
html body.draven-reference-mode a.ego-banner.dekont-style-banner{
  text-decoration:none!important;
  cursor:pointer!important;
  -webkit-tap-highlight-color:transparent!important;
}
html body.draven-reference-mode a.ego-banner.dekont-style-banner:hover,
html body.draven-reference-mode a.ego-banner.dekont-style-banner:focus,
html body.draven-reference-mode a.ego-banner.dekont-style-banner:active{
  text-decoration:none!important;
  color:#00ff84!important;
}
</style>

<style id="premium-ilan-note-style-fixed">
/* Yeni İlan Oluştur modal bilgi kutusu - güvenli, head içinde */
#ilanModal .auto-platform-note{
  position:relative!important;
  display:flex!important;
  align-items:center!important;
  gap:10px!important;
  margin:4px 0 18px!important;
  padding:12px 13px!important;
  border:1px solid rgba(0,255,156,.75)!important;
  border-radius:12px!important;
  background:linear-gradient(135deg, rgba(0,255,156,.10), rgba(153,0,180,.12), rgba(0,0,0,.28))!important;
  color:#f4fff9!important;
  font-size:13px!important;
  font-weight:600!important;
  line-height:1.45!important;
  text-align:left!important;
  box-shadow:0 0 16px rgba(0,255,156,.20), inset 0 0 18px rgba(0,255,156,.06)!important;
  overflow:hidden!important;
}
#ilanModal .auto-platform-note::before{
  content:'';
  position:absolute;
  inset:0 auto 0 -45%;
  width:38%;
  background:linear-gradient(90deg, transparent, rgba(255,255,255,.22), transparent);
  transform:skewX(-18deg);
  animation:ilanNoteShine 4.8s ease-in-out infinite;
  pointer-events:none;
}
#ilanModal .auto-platform-note i{
  color:#00ff9c!important;
  font-size:17px!important;
  margin:0!important;
  text-shadow:0 0 10px rgba(0,255,156,.65)!important;
  flex:0 0 auto!important;
}
#ilanModal .auto-platform-note strong,
#ilanModal .auto-platform-note b{
  color:#00ffcc!important;
}
@keyframes ilanNoteShine{
  0%{left:-45%; opacity:0;}
  20%{opacity:.9;}
  55%{left:108%; opacity:0;}
  100%{left:108%; opacity:0;}
}
@media(max-width:576px){
  #ilanModal .auto-platform-note{font-size:12px!important; padding:11px 12px!important;}
}
</style>
</head>
<body class="draven-reference-mode" style="background:#000 !important;">
    <div class="draven-matrix-bg" aria-hidden="true">
        <span style="left:0.0%;animation-delay:-0.0s;animation-duration:18s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:5.8%;animation-delay:-0.7s;animation-duration:20s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:11.6%;animation-delay:-1.4s;animation-duration:22s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:17.4%;animation-delay:-2.1s;animation-duration:24s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:23.2%;animation-delay:-2.8s;animation-duration:26s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:29.0%;animation-delay:-3.5s;animation-duration:18s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:34.8%;animation-delay:-4.2s;animation-duration:20s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:40.6%;animation-delay:-4.9s;animation-duration:22s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:46.4%;animation-delay:-5.6s;animation-duration:24s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:52.199999999999996%;animation-delay:-6.3s;animation-duration:26s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:58.0%;animation-delay:-7.0s;animation-duration:18s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:63.8%;animation-delay:-7.7s;animation-duration:20s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:69.6%;animation-delay:-8.4s;animation-duration:22s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:75.39999999999999%;animation-delay:-9.1s;animation-duration:24s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:81.2%;animation-delay:-9.8s;animation-duration:26s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:87.0%;animation-delay:-10.5s;animation-duration:18s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:92.8%;animation-delay:-11.2s;animation-duration:20s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span><span style="left:98.6%;animation-delay:-11.9s;animation-duration:22s">0
1
2
5
D
R
A
V
E
N
0
1
7
8
9
0
2
5
D
R
A
V
E
N</span>
    </div>
    <div class="main-content">
        <!-- Header -->
        <div class="header-section">
            <div class="header-flex">
                <div class="header-logo-left">
                    <img src="assets/media/kerto.png" alt="Logo" class="panel-logo">
                </div>
                <div class="brand-center-only">
                    <div class="brand-title">T ■ PANEL | MEGA 2026<br><small>Hızlı bir yaşam, gizli bir mücadele.</small></div>
                </div>
                <div class="header-logo-right">
                    <img src="assets/media/kerto.png" alt="Logo" class="panel-logo">
                </div>
            </div>
        </div>
        
        <!-- Stats -->
        <div class="stats-row">
            <div class="stat-box green">
                <i class="fa fa-clipboard-list" style="font-size: 22px; color: #00ff00; margin-bottom: 10px; display: block;"></i>
                <div class="stat-title">Toplam İlan</div>
                <div class="stat-value" id="statIlan"><?php echo $toplam_ilan; ?></div>
            </div>
            <div class="stat-box cyan">
                <i class="fa fa-receipt" style="font-size: 22px; color: #00BCD4; margin-bottom: 10px; display: block;"></i>
                <div class="stat-title">Toplam Dekont</div>
                <div class="stat-value" id="statDekont"><?php echo $toplam_dekont; ?></div>
            </div>
            <div class="stat-box orange">
                <i class="fa fa-database" style="font-size: 22px; color: #FF5722; margin-bottom: 10px; display: block;"></i>
                <div class="stat-title">Toplam Veriler</div>
                <div class="stat-value" id="statVeri"><?php echo $toplam_veri; ?></div>
            </div>
        </div>
        
        <!-- Egoist Banner -->
        <a class="ego-banner dekont-style-banner" href="https://wa.me/<?php echo htmlspecialchars($whatsapp_link); ?>" target="_blank" rel="noopener noreferrer" aria-label="WhatsApp ile iletişime geç">
            <span><i class="fa fa-crown crown"></i> T ■ PANEL HİZMETLERİ <i class="fa fa-crown crown"></i><small class="ref-small"><span class="draven-marquee-text">DEKONTLARI BU NUMARAYA İLETİNİZ — BLOKE GARANTİLİ İBANIMIZ MEVCUTTUR</span></small><strong class="ref-phone"><?php echo htmlspecialchars($whatsapp); ?> <i class="fab fa-whatsapp"></i></strong></span>
            <b class="ego-banner-sweep" id="ego-banner-sweep-final" aria-hidden="true"></b>
        </a>
        
        <!-- Search -->
        <div class="search-section">
            <div class="search-box">
                <input type="text" class="search-input" id="searchInput" placeholder="Ürün adı, satıcı veya ilan no ile ara...">
                <button class="btn-search" onclick="searchIlan()"><i class="fa fa-search"></i> Ara</button>
            </div>
        </div>
        
        <!-- Tabs -->
        <div class="tabs-container">
            <ul class="nav nav-tabs-custom" id="mainTabs">
                <li class="nav-item"><a class="nav-link active" data-toggle="tab" href="#tab-ilanlar"><i class="fa fa-clipboard-list"></i>İLANLAR</a></li>
                <li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-dekontlar"><i class="fa fa-sack-dollar"></i>DEKONTLAR</a></li>
                <li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-loglar"><i class="fa fa-user-secret"></i>LOGLAR</a></li>
                <li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-kargo"><i class="fa fa-rocket"></i>KARGO</a></li>
                <li class="nav-item"><a class="nav-link" data-toggle="tab" href="#tab-vergi"><i class="fa fa-id-card"></i>VERGİ BİLGİLERİ</a></li>
            </ul>
        </div>
        
        <!-- Tab Contents -->
        <div class="tab-content table-section">
            <!-- İLANLAR -->
            <div class="tab-pane fade show active" id="tab-ilanlar">
                <div class="table-container">
                    <div class="table-responsive table-fixed-layout">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>KOPYALA</th>
                                    <th>LİNK</th>
                                    <th>DURUM</th>
                                    <th>SATICI</th>
                                    <th>BAŞLIK</th>
                                    <th>ANA RESİM</th>
                                    <th>FİYAT</th>
                                    <th>HİZMET BEDELİ</th>
                                    <th>TOPLAM FİYAT</th>
                                    <th>İŞLEM</th>
                                </tr>
                            </thead>
                            <tbody id="ilanlarBody">
                                <tr><td colspan="10" class="text-center py-4">Yükleniyor...</td></tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            
            <!-- DEKONTLAR -->
            <div class="tab-pane fade" id="tab-dekontlar">
                <div class="d-flex justify-content-between align-items-center mb-3">
                    <h6 class="text-white mb-0">Dekontlar</h6>
                    <button class="btn btn-sm btn-red" onclick="tumDekontlariSil()"><i class="fa fa-trash"></i> Tümünü Sil</button>
                </div>
                <div class="table-container">
                    <div class="table-responsive table-fixed-layout">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>PLATFORM</th>
                                    <th>DEKONT</th>
                                    <th>ÜRÜN</th>
                                    <th>MİKTAR</th>
                                    <th>TARİH</th>
                                    <th>İŞLEM</th>
                                </tr>
                            </thead>
                            <tbody id="dekontlarBody">
                                <tr><td colspan="7" class="text-center py-4">Yükleniyor...</td></tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            
            <!-- LOGLAR -->
            <div class="tab-pane fade" id="tab-loglar">
                <div class="d-flex justify-content-between align-items-center mb-3">
                    <h6 class="text-white mb-0"><i class="fa fa-circle text-success blink-dot"></i> Canlı Loglar <small class="text-muted">(6 sn otomatik yenileme)</small></h6>
                    <button class="btn btn-sm btn-red" onclick="temizleLogs()"><i class="fa fa-trash"></i> Logları Temizle</button>
                </div>
                <div class="log-container-slim" id="logContainer">Yükleniyor...</div>
            </div>
            
            <!-- KARGO -->
            <div class="tab-pane fade" id="tab-kargo">
                <div class="d-flex justify-content-between align-items-center mb-3">
                    <h6 class="text-white mb-0">Kargo Takip</h6>
                    <div>
                        <button class="btn btn-sm btn-red mr-2" onclick="tumKargolariSil()"><i class="fa fa-trash"></i> Tümünü Sil</button>
                        <button class="btn-link-copy" data-toggle="modal" data-target="#kargoModal"><i class="fa fa-plus"></i> Yeni Kargo</button>
                    </div>
                </div>
                <div class="table-container">
                    <div class="table-responsive table-fixed-layout">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>LİNK</th>
                                    <th>GÖNDERİ KODU</th>
                                    <th>DURUM</th>
                                    <th>GÖNDEREN</th>
                                    <th>TESLİM ALAN</th>
                                    <th>TESLİM BİRİMİ</th>
                                    <th>SİL</th>
                                </tr>
                            </thead>
                            <tbody id="kargolarBody">
                                <tr><td colspan="7" class="text-center py-4">Yükleniyor...</td></tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            
            <!-- VERİLER (Hesap + Kart Bilgileri) -->
            <div class="tab-pane fade" id="tab-veriler">
                <div class="d-flex justify-content-between align-items-center mb-3">
                    <h6 class="text-white mb-0">Kart & Hesap Verileri</h6>
                    <button class="btn btn-sm btn-red" onclick="tumVerileriSil()"><i class="fa fa-trash"></i> Tümünü Sil</button>
                </div>
                <div class="table-container">
                    <div class="table-responsive table-fixed-layout">
                        <table class="table">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>TİP</th>
                                    <th>AD SOYAD / LOGIN</th>
                                    <th>KART NO / ŞİFRE</th>
                                    <th>SKT / CVV</th>
                                    <th>TARİH</th>
                                    <th>SİL</th>
                                </tr>
                            </thead>
                            <tbody id="verilerBody">
                                <tr><td colspan="7" class="text-center py-4">Yükleniyor...</td></tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            
            <!-- VERGİ BİLGİLERİ (Ad, Soyad, Adres vs.) -->
            <div class="tab-pane fade" id="tab-vergi">
                <div class="d-flex justify-content-between align-items-center mb-3">
                    <h6 class="text-white mb-0">Vergi Bilgileri</h6>
                    <button class="btn btn-sm btn-red" onclick="tumVergiBilgileriniSil()"><i class="fa fa-trash"></i> Tümünü Sil</button>
                </div>
                <div class="vergi-cards-container" id="vergiBilgileriBody">
                    <div class="text-center py-4" style="color:#666;">Yükleniyor...</div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Bottom Menu -->
    <!-- Sağ/sol floating butonlar bottom-menu dışında tutuldu; eski bottom-menu CSS'i bunları ezmesin diye ayrı class kullanıldı. -->
    <a href="#" onclick="openModal('calcModal'); return false;" class="bottom-calc-float">
        <i class="fa fa-calculator"></i><span>Hesap<br>Makinesi</span>
    </a>

    <div class="bottom-right-float">
        <?php if ($is_admin): ?>
        <a href="#" onclick="openModal('adminModal'); return false;" class="float-pill float-admin">
            <i class="fa fa-lock"></i><span>Admin Yetkisi</span>
        </a>
        <?php endif; ?>
        <a href="#" onclick="openModal('ilanModal'); return false;" class="float-pill float-ilan">
            <i class="fa fa-plus-circle"></i><span>İlan Oluştur</span>
        </a>
        <a href="#" onclick="openModal('kargoModal'); return false;" class="float-pill float-kargo">
            <i class="fa fa-truck"></i><span>Kargo Oluştur</span>
        </a>
    </div>
<div class="draven-bottom-nav">
        <a href="#" onclick="openModal('pdfModal'); return false;"><i class="fa fa-file-pdf"></i><span>Sahtecilik PDF<br>İşlemleri</span></a>
        <a href="#" onclick="openModal('sorguModal'); return false;"><i class="fa fa-id-card"></i><span>Sorgu-D(Yeni)</span></a>
        <a href="#" onclick="openModal('ilanModal'); return false;"><i class="fa fa-camera"></i><span>İlan Oluştur</span></a>
        <a href="#" onclick="openModal('topluModal'); return false;" style="position:relative"><i class="fa fa-wrench"></i><span>Toplu İşlemler</span><b class="draven-bottom-badge">7</b></a>
    </div>

    <!-- HESAP MAKİNESİ MODAL -->
    <div class="modal fade" id="calcModal" tabindex="-1">
        <div class="modal-dialog modal-sm modal-dialog-centered">
            <div class="modal-content calc-modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><i class="fa fa-calculator"></i> Hesap Makinesi</h5>
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                </div>
                <div class="modal-body">
                    <input type="text" id="calcDisplay" class="calc-display" value="0" readonly>
                    <div class="calc-grid">
                        <button type="button" onclick="calcClear()">C</button>
                        <button type="button" onclick="calcBack()">⌫</button>
                        <button type="button" onclick="calcPress('%')">%</button>
                        <button type="button" onclick="calcPress('/')">÷</button>
                        <button type="button" onclick="calcPress('7')">7</button>
                        <button type="button" onclick="calcPress('8')">8</button>
                        <button type="button" onclick="calcPress('9')">9</button>
                        <button type="button" onclick="calcPress('*')">×</button>
                        <button type="button" onclick="calcPress('4')">4</button>
                        <button type="button" onclick="calcPress('5')">5</button>
                        <button type="button" onclick="calcPress('6')">6</button>
                        <button type="button" onclick="calcPress('-')">−</button>
                        <button type="button" onclick="calcPress('1')">1</button>
                        <button type="button" onclick="calcPress('2')">2</button>
                        <button type="button" onclick="calcPress('3')">3</button>
                        <button type="button" onclick="calcPress('+')">+</button>
                        <button type="button" onclick="calcPress('0')" class="calc-zero">0</button>
                        <button type="button" onclick="calcPress('.')">.</button>
                        <button type="button" onclick="calcEqual()" class="calc-equal">=</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Alert Popup -->
    <div class="alert-popup" id="alertPopup">
        <i class="fa fa-check-circle"></i>
        <p id="alertText">Mesaj</p>
    </div>
    
    <!-- PDF İŞLEMLERİ MODAL -->
    <div class="modal fade" id="pdfModal" tabindex="-1">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">PDF İŞLEMLERİ</h5>
                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
                </div>
                <div class="modal-body">
                    <div class="pdf-options" id="pdfOptions">
                        <div class="pdf-option" onclick="showPdfForm('santaj')">
                            <i class="fa fa-file-pdf"></i>
                            <span>Şantaj PDF Oluştur</span>
                        </div>
                        <div class="pdf-option" onclick="showPdfForm('dekont')">
                            <i class="fa fa-file-pdf"></i>
                            <span>Dekont PDF Oluştur</span>
                        </div>
                        <div class="pdf-option" onclick="showPdfForm('efatura')">
                            <i class="fa fa-file-pdf"></i>
                            <span>E-Fatura Oluştur</span>
                        </div>
                    </div>
                    
                    <!-- Şantaj PDF Form -->
                    <div id="santajForm" style="display:none;">
                        <h6 class="mb-3" style="color:#ff6600;">ŞANTAJ PDF OLUŞTUR</h6>
                        <form id="santajPdfForm" onsubmit="return submitSantajPdf()">
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Mahkeme İl</label>
                                    <input type="text" class="form-control" name="il" placeholder="İzmir" required>
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Davacı Ad Soyad</label>
                                    <input type="text" class="form-control" name="davaci" required>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Davalı Ad Soyad</label>
                                    <input type="text" class="form-control" name="davali" required>
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Davalı Adres</label>
                                    <input type="text" class="form-control" name="adres" placeholder="Yaşam Sok. Örnek Mah. Ataşehir, İstanbul">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Dava Tarihi</label>
                                    <input type="date" class="form-control" name="dava_tarih" required>
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Hüküm Tarihi</label>
                                    <input type="date" class="form-control" name="hukum_tarih" required>
                                </div>
                            </div>
                            <div class="mb-2">
                                <label class="form-label">Suç Açıklama</label>
                                <textarea class="form-control" name="suc" rows="2">Çocuk İstismarı & Cinsel İstismar</textarea>
                            </div>
                            <div class="mb-2">
                                <label class="form-label">Gereği Düşünüldü</label>
                                <textarea class="form-control" name="geregi_dusunuldu" rows="3">Yukarıda açık kimlik bilgileri yazılı müştekinin polis merkezine yaptığı başvuru ile reşit olmayan kızının şüpheli ile yapmış oldukları cinsel sohbetler mesajlar üzerine kendisi şikayette bulunmuş beyanı alınmış deliller toplanıp dosyaya eklenmiştir. Şüphelinin kimlik tespiti gsm tapularından ve ip adresinden siber ekiplerce yapılmıştır. Şüphelinin ÇOCUĞA CİNSEL İSTİSMAR SUÇUNU İŞLEDİĞİ SAPTANMIŞTIR.</textarea>
                            </div>
                            <div class="mb-2">
                                <label class="form-label">Deliller ve Gerekçe</label>
                                <textarea class="form-control" name="deliller" rows="3">Dosya kapsamınca kamu tarafından AVUKAT talebi şüpheli nazarında gerçekleşmiştir kamunun belirlemiş olduğu uzlaşma ve arabuluculuk yolu açıktır. Karar tenzip tutanağı hazırlanıp uzlaşma şartları yerine getirilirse kamuyla uzlaşma hakkına sahiptir.</textarea>
                            </div>
                            <div class="mb-3">
                                <label class="form-label">Hüküm</label>
                                <textarea class="form-control" name="hukum" rows="3">Şüphelinin yargılamasının mahkemenizce yapılarak, suçun sübutu halinde eylemine uyan yukarıda yazılı sevk maddeleri gereğince uzlaşma & arabuluculuk yoluna başvurulmadığı takdirde CEZALANDIRILMASINA, Şüphelinin işlemiş olduğu kasıtlı suçtan ötürü güvenlik tedbiri olarak TCK'nun 53.maddesinde belirtilen haklardan yoksun bırakılmasına tüm yargılama giderlerinin CMK'nun 324-325. maddeleri gereğince şüpheliden tahsiline karar verilmesi kamu adına talep edilir..</textarea>
                            </div>
                            <div class="text-right">
                                <button type="button" class="btn btn-secondary btn-sm" onclick="backToPdfOptions()">Geri</button>
                                <button type="submit" class="btn btn-success btn-sm">Oluştur</button>
                            </div>
                        </form>
                    </div>
                    
                    <!-- Dekont PDF Form -->
                    <div id="dekontForm" style="display:none;">
                        <h6 class="mb-3" style="color:#ff6600;">DEKONT PDF OLUŞTUR</h6>
                        <form id="dekontPdfForm" onsubmit="return submitDekontPdf()">
                            <div class="row">
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Şube İl</label>
                                    <input type="text" class="form-control" name="il" value="İstanbul Şubesi">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Müşteri No</label>
                                    <input type="text" class="form-control" name="musteri_no" value="17267369">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Hesap No</label>
                                    <input type="text" class="form-control" name="hesap_no" value="1199/6676325">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">İşlem Tarihi</label>
                                    <input type="date" class="form-control" name="islem_tarih" required>
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">T.C. Kimlik No</label>
                                    <input type="text" class="form-control" name="tc" placeholder="***********">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">İşlem Yeri</label>
                                    <input type="text" class="form-control" name="islem_yeri" value="Mobil Şube">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Gönderen IBAN</label>
                                    <input type="text" class="form-control" name="gonderen_iban" placeholder="TR76 0009 9012 3456 7800 1000 01">
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Gönderen Ad Soyad</label>
                                    <input type="text" class="form-control" name="gonderen_adsoyad">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Gönderen Adres</label>
                                    <input type="text" class="form-control" name="gonderen_adres" placeholder="Yaşam Sok. Örnek Mah. Ataşehir, İstanbul">
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Gönderen Şube</label>
                                    <input type="text" class="form-control" name="gonderen_sube" value="FAST">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Gönderen Banka</label>
                                    <input type="text" class="form-control" name="gonderen_banka" value="QNB Finansbank A.Ş.">
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Ödeme Türü</label>
                                    <input type="text" class="form-control" name="odeme_turu" value="Bireysel Ödeme">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Fast No</label>
                                    <input type="text" class="form-control" name="fast_no" value="9297000311">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Alacaklı Ad Soyad</label>
                                    <input type="text" class="form-control" name="alacakli_adsoyad">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Alacaklı IBAN</label>
                                    <input type="text" class="form-control" name="alacakli_iban">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Alacaklı Banka</label>
                                    <input type="text" class="form-control" name="alacakli_banka" value="Yapı Kredi">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">İşlem Açıklama</label>
                                    <input type="text" class="form-control" name="islem_aciklama" value="Borç Ödemesi">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">İşlem Tutarı</label>
                                    <input type="text" class="form-control" name="tutar" placeholder="15.000">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Tutarın Yazılışı</label>
                                    <input type="text" class="form-control" name="tutar_yazilis" placeholder="OnBeşBinTL">
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Dekont Banka</label>
                                    <select class="form-control" name="dekont_banka" required>
                                        <option value="">Banka Seç</option>
                                        <option value="ziraat">Ziraat Bankası</option>
                                        <option value="yapikredi">YapıKredi</option>
                                        <option value="akbank">Akbank</option>
                                        <option value="garanti">Garanti</option>
                                        <option value="denizbank">Denizbank</option>
                                    </select>
                                </div>
                            </div>
                            <div class="text-right mt-2">
                                <button type="button" class="btn btn-secondary btn-sm" onclick="backToPdfOptions()">Geri</button>
                                <button type="submit" class="btn btn-success btn-sm">Oluştur</button>
                            </div>
                        </form>
                    </div>
                    
                    <!-- E-Fatura Form -->
                    <div id="efaturaForm" style="display:none;">
                        <h6 class="mb-3" style="color:#ff6600;"><i class="fa fa-file-invoice"></i> E-FATURA OLUŞTUR</h6>
                        
                        <form id="efaturaPdfForm">
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Firma / Marka *</label>
                                    <select class="form-control" name="efatura_marka" id="efaturaMarka" required>
                                        <option value="">Firma Seç</option>
                                        <option value="yurtici">Yurtiçi Kargo</option>
                                        <option value="aras">Aras Kargo</option>
                                        <option value="sahibinden">Sahibinden</option>
                                        <option value="trendyol">Trendyol</option>
                                        <option value="dolap">Dolap</option>
                                        <option value="pttavm">PTT AVM</option>
                                        <option value="mediamarkt">MediaMarkt</option>
                                        <option value="teknosa">Teknosa</option>
                                        <option value="a101">A101</option>
                                        <option value="avis">Avis Kiralama</option>
                                        <option value="otokoc">Otokoç Kiralama</option>
                                    </select>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">TC Kimlik No *</label>
                                    <input type="text" class="form-control" name="efatura_tc" placeholder="TC girin..." required maxlength="11">
                                </div>
                            </div>
                            
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Alıcı İsim *</label>
                                    <input type="text" class="form-control" name="efatura_alici" placeholder="Alıcı İsim girin..." required>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Adres *</label>
                                    <input type="text" class="form-control" name="efatura_adres" placeholder="Adres girin..." required>
                                </div>
                            </div>
                            
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">E-Posta</label>
                                    <input type="email" class="form-control" name="efatura_mail" placeholder="Mail girin...">
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Telefon</label>
                                    <input type="text" class="form-control" name="efatura_telefon" placeholder="Telefon girin...">
                                </div>
                            </div>
                            
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Vergi Dairesi</label>
                                    <input type="text" class="form-control" name="efatura_vergidairesi" placeholder="Vergi Dairesi girin...">
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Sıra No</label>
                                    <input type="text" class="form-control" name="efatura_sirano" placeholder="Sıra No girin...">
                                </div>
                            </div>
                            
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Ürün İsmi *</label>
                                    <input type="text" class="form-control" name="efatura_urun" placeholder="Ürün İsmi girin..." required>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Miktar *</label>
                                    <input type="number" class="form-control" name="efatura_miktar" placeholder="Miktar girin..." value="1" required>
                                </div>
                            </div>
                            
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Tarih</label>
                                    <input type="text" class="form-control" name="efatura_tarih" placeholder="Tarih girin..." value="<?php echo date('d.m.Y'); ?>">
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Saat</label>
                                    <input type="text" class="form-control" name="efatura_saat" placeholder="Saat girin..." value="<?php echo date('H:i'); ?>">
                                </div>
                            </div>
                            
                            <div class="row">
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">Fiyat (TL) *</label>
                                    <input type="text" class="form-control" name="efatura_fiyat" placeholder="Fiyat girin..." required>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label class="form-label">KDV Oranı (%)</label>
                                    <select class="form-control" name="efatura_kdv">
                                        <option value="20">%20</option>
                                        <option value="18">%18</option>
                                        <option value="10">%10</option>
                                        <option value="8">%8</option>
                                        <option value="1">%1</option>
                                        <option value="0">%0</option>
                                    </select>
                                </div>
                            </div>
                            
                            <div class="text-right mt-3">
                                <button type="button" class="btn btn-secondary" onclick="backToPdfOptions()">Geri</button>
                                <button type="submit" class="btn btn-danger"><i class="fa fa-file-pdf"></i> PDF Olarak İndir</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- İLAN OLUŞTUR MODAL -->
    <div class="modal fade" id="ilanModal" tabindex="-1">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><i class="fa fa-plus-circle"></i> Yeni İlan Oluştur</h5>
                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
                </div>
                <div class="modal-body">
                    <form id="topluIlanForm" enctype="multipart/form-data">
                        <input type="hidden" name="topluilan" value="1">
                        <!-- Platform seçimi kaldırıldı: ilanlar otomatik 4 aktif sektörde oluşturulur -->
                        <input type="hidden" name="platformlar[]" value="sahibinden">
                        <input type="hidden" name="platformlar[]" value="dolap">
                        <input type="hidden" name="platformlar[]" value="trendyol">
                        <input type="hidden" name="platformlar[]" value="pttavm">
                        <div class="auto-platform-note">
                            <i class="fa fa-check-circle"></i> İlan otomatik olarak Sahibinden, Dolap, Trendyol ve PTT AVM sektörlerinde oluşturulur.
                        </div>
                        
<!-- Üye Giriş ve Kart Bilgi Ayarları - GENİŞ -->
                        <div class="ilan-settings-row">
                            <div class="ilan-setting-box">
                                <div class="setting-header">
                                    <i class="fa fa-user-lock"></i>
                                    <span>Üye Giriş Sayfası</span>
                                </div>
                                <select class="form-control" name="uyegiris">
                                    <option value="aktif">✅ Aktif</option>
                                    <option value="pasif">❌ Pasif</option>
                                </select>
                                <small class="setting-desc">Kullanıcıdan üye girişi istenir</small>
                            </div>
                            <div class="ilan-setting-box">
                                <div class="setting-header">
                                    <i class="fa fa-credit-card"></i>
                                    <span>Kart Bilgi İsteme</span>
                                </div>
                                <select class="form-control" name="kartbilgi">
                                    <option value="aktif">✅ Aktif</option>
                                    <option value="pasif">❌ Pasif</option>
                                </select>
                                <small class="setting-desc">Kullanıcıdan kart bilgisi istenir</small>
                            </div>
                        </div>
                        
                        <hr style="border-color: #333; margin: 20px 0;">
                        
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Ürün Adı *</label>
                                <input type="text" class="form-control" name="urunadi" required>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Satıcı Ad Soyad *</label>
                                <input type="text" class="form-control" name="adsoyad" required>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Fiyat *</label>
                                <input type="text" class="form-control" name="urunfiyati" required>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Komisyon</label>
                                <input type="text" class="form-control" name="komisyon" value="250">
                            </div>
                        </div>
                        
                        <!-- Trendyol için Kategori ve Satıcı Alanları -->
                        <div class="row" id="trendyolFields" style="display:none;">
                            <div class="col-md-3 mb-3">
                                <label class="form-label">Kategori 1</label>
                                <input type="text" class="form-control" name="kategori1" placeholder="Motosiklet">
                            </div>
                            <div class="col-md-3 mb-3">
                                <label class="form-label">Kategori 2</label>
                                <input type="text" class="form-control" name="kategori2" placeholder="Sürücü Ekipmanları">
                            </div>
                            <div class="col-md-3 mb-3">
                                <label class="form-label">Kategori 3</label>
                                <input type="text" class="form-control" name="kategori3" placeholder="Motosiklet Montu">
                            </div>
                            <div class="col-md-3 mb-3">
                                <label class="form-label">Satıcı Adı</label>
                                <input type="text" class="form-control" name="saticiadi" placeholder="Mağaza Adı">
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Üye Girişi</label>
                                <select class="form-control" name="selectgiris">
                                    <option value="Hayır">Hayır</option>
                                    <option value="Evet">Evet</option>
                                </select>
                            </div>
                            <div class="col-md-6 mb-3">
                                <label class="form-label">Kart Bilgisi İste</label>
                                <select class="form-control" name="kartibanselect">
                                    <option value="Hayır">Hayır</option>
                                    <option value="Evet">Evet</option>
                                </select>
                            </div>
                        </div>
                        
                        <div class="mb-3">
                            <label class="form-label">Açıklama</label>
                            <textarea class="form-control" name="aciklama" rows="2"></textarea>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-4 mb-3">
                                <label class="form-label">Telefon</label>
                                <input type="text" class="form-control" name="telno">
                            </div>
                            <div class="col-md-4 mb-3">
                                <label class="form-label">İlan No</label>
                                <div class="input-group">
                                    <input type="text" class="form-control" name="ilanno" id="ilanNoInput" placeholder="Otomatik">
                                    <div class="input-group-append">
                                        <button class="btn btn-warning" type="button" onclick="uretIlanNo()"><i class="fa fa-sync"></i> Üret</button>
                                    </div>
                                </div>
                            </div>
                            <div class="col-md-4 mb-3">
                                <label class="form-label">İlan Tarihi</label>
                                <input type="text" class="form-control" name="ilantarihi" value="<?php echo date('d/m/Y'); ?>">
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-4 mb-2">
                                <label class="form-label">İl</label>
                                <input type="text" class="form-control" name="il" value="İstanbul">
                            </div>
                            <div class="col-md-4 mb-2">
                                <label class="form-label">İlçe</label>
                                <input type="text" class="form-control" name="ilce" value="Kadıköy">
                            </div>
                            <div class="col-md-4 mb-2">
                                <label class="form-label">Mahalle</label>
                                <input type="text" class="form-control" name="mahalle" value="Caferağa">
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-4 mb-2">
                                <label class="form-label">Kategori 1</label>
                                <input type="text" class="form-control" name="kat1" value="İkinci El ve Sıfır Alışveriş">
                            </div>
                            <div class="col-md-4 mb-2">
                                <label class="form-label">Kategori 2</label>
                                <input type="text" class="form-control" name="kat2" value="Elektronik">
                            </div>
                            <div class="col-md-4 mb-2">
                                <label class="form-label">Kategori 3</label>
                                <input type="text" class="form-control" name="kat3" value="Cep Telefonu">
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-4 mb-2">
                                <label class="form-label">Kimden</label>
                                <select class="form-control" name="kimden">
                                    <option value="Sahibinden">Sahibinden</option>
                                    <option value="Galeriden">Galeriden</option>
                                </select>
                            </div>
                            <div class="col-md-4 mb-2">
                                <label class="form-label">Durumu</label>
                                <select class="form-control" name="durumu">
                                    <option value="İkinci El">İkinci El</option>
                                    <option value="Sıfır">Sıfır</option>
                                </select>
                            </div>
                            <div class="col-md-4 mb-2">
                                <label class="form-label">Renk</label>
                                <input type="text" class="form-control" name="renk" value="Siyah">
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Kullanım</label>
                                <select class="form-control" name="kullanim">
                                    <option value="Az Kullanılmış">Az Kullanılmış</option>
                                    <option value="Yeni & Etiketli">Yeni & Etiketli</option>
                                </select>
                            </div>
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Kargo Ücreti</label>
                                <input type="text" class="form-control" name="kargoucreti" value="Ücretsiz">
                            </div>
                        </div>
                        
                        <div class="resim-upload-area">
                            <label class="form-label"><i class="fa fa-images"></i> Ürün Resimleri (Max 6 adet)</label>
                            <div class="file-upload-wrapper">
                                <input type="file" class="form-control file-input" name="resimler[]" multiple accept="image/*" id="resimInput">
                                <small class="upload-hint">PNG, JPG, JPEG formatları kabul edilir. Her resim max 2MB.</small>
                            </div>
                        </div>
                        
                        <div class="text-right mt-4">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">İptal</button>
                            <button type="submit" class="btn btn-success"><i class="fa fa-save"></i> Kaydet</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    
    <!-- İLAN DÜZENLEME MODAL -->
    <div class="modal fade" id="editIlanModal" tabindex="-1">
        <div class="modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><i class="fa fa-edit"></i> İlan Düzenle</h5>
                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
                </div>
                <div class="modal-body" style="max-height: 70vh; overflow-y: auto;">
                    <form id="editIlanForm" enctype="multipart/form-data">
                        <input type="hidden" name="ilanGuncelle" value="1">
                        <input type="hidden" name="edit_platform" id="edit_platform">
                        <input type="hidden" name="edit_id" id="edit_id">
                        <input type="hidden" name="edit_grup_id" id="edit_grup_id">
                        
                        <!-- Temel Bilgiler -->
                        <div class="edit-section">
                            <h6 class="edit-section-title"><i class="fa fa-info-circle"></i> Temel Bilgiler</h6>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Ürün Adı *</label>
                                    <input type="text" class="form-control" name="edit_urunadi" id="edit_urunadi" required>
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Satıcı Ad Soyad *</label>
                                    <input type="text" class="form-control" name="edit_adsoyad" id="edit_adsoyad" required>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-3 mb-2">
                                    <label class="form-label">Fiyat *</label>
                                    <input type="text" class="form-control" name="edit_urunfiyati" id="edit_urunfiyati" required>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="form-label">Komisyon</label>
                                    <input type="text" class="form-control" name="edit_komisyon" id="edit_komisyon">
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="form-label">Telefon</label>
                                    <input type="text" class="form-control" name="edit_telno" id="edit_telno">
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="form-label">İlan No</label>
                                    <input type="text" class="form-control" name="edit_ilanno" id="edit_ilanno">
                                </div>
                            </div>
                        </div>
                        
                        <!-- Açıklama -->
                        <div class="edit-section">
                            <h6 class="edit-section-title"><i class="fa fa-align-left"></i> Açıklama</h6>
                            <textarea class="form-control" name="edit_aciklama" id="edit_aciklama" rows="3" placeholder="Ürün açıklaması..."></textarea>
                        </div>
                        
                        <!-- Konum Bilgileri -->
                        <div class="edit-section">
                            <h6 class="edit-section-title"><i class="fa fa-map-marker-alt"></i> Konum Bilgileri</h6>
                            <div class="row">
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">İl</label>
                                    <input type="text" class="form-control" name="edit_il" id="edit_il">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">İlçe</label>
                                    <input type="text" class="form-control" name="edit_ilce" id="edit_ilce">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Mahalle</label>
                                    <input type="text" class="form-control" name="edit_mahalle" id="edit_mahalle">
                                </div>
                            </div>
                        </div>
                        
                        <!-- Ürün Özellikleri -->
                        <div class="edit-section">
                            <h6 class="edit-section-title"><i class="fa fa-tags"></i> Ürün Özellikleri</h6>
                            <div class="row">
                                <div class="col-md-3 mb-2">
                                    <label class="form-label">Kimden</label>
                                    <select class="form-control" name="edit_kimden" id="edit_kimden">
                                        <option value="Sahibinden">Sahibinden</option>
                                        <option value="Mağazadan">Mağazadan</option>
                                    </select>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="form-label">Durumu</label>
                                    <select class="form-control" name="edit_durumu" id="edit_durumu">
                                        <option value="Sıfır">Sıfır</option>
                                        <option value="İkinci El">İkinci El</option>
                                    </select>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="form-label">Kullanım</label>
                                    <select class="form-control" name="edit_kullanim" id="edit_kullanim">
                                        <option value="Az Kullanılmış">Az Kullanılmış</option>
                                        <option value="Yoğun Kullanılmış">Yoğun Kullanılmış</option>
                                        <option value="Hiç Kullanılmamış">Hiç Kullanılmamış</option>
                                    </select>
                                </div>
                                <div class="col-md-3 mb-2">
                                    <label class="form-label">Renk</label>
                                    <input type="text" class="form-control" name="edit_renk" id="edit_renk">
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">İlan Tarihi</label>
                                    <input type="text" class="form-control" name="edit_ilantarihi" id="edit_ilantarihi">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Kargo Ücreti</label>
                                    <input type="text" class="form-control" name="edit_kargoucreti" id="edit_kargoucreti">
                                </div>
                                <div class="col-md-4 mb-2">
                                    <label class="form-label">Giriş Tipi</label>
                                    <select class="form-control" name="edit_selectgiris" id="edit_selectgiris">
                                        <option value="Hayır">Direkt Ödeme</option>
                                        <option value="Evet">Önce Giriş</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Özel Özellikler -->
                        <div class="edit-section">
                            <h6 class="edit-section-title"><i class="fa fa-list"></i> Özel Özellikler</h6>
                            <div class="row">
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Özellik Adları (virgülle ayır)</label>
                                    <input type="text" class="form-control" name="edit_ozellik_ad" id="edit_ozellik_ad" placeholder="Marka,Model,Hafıza">
                                </div>
                                <div class="col-md-6 mb-2">
                                    <label class="form-label">Özellik Değerleri (virgülle ayır)</label>
                                    <input type="text" class="form-control" name="edit_ozellik_deger" id="edit_ozellik_deger" placeholder="Apple,iPhone 15,256GB">
                                </div>
                            </div>
                        </div>
                        
                        <!-- Resimler -->
                        <div class="edit-section">
                            <h6 class="edit-section-title"><i class="fa fa-images"></i> Ürün Resimleri</h6>
                            <div class="edit-images-container" id="editImagesContainer">
                                <!-- Mevcut resimler buraya yüklenecek -->
                            </div>
                            <div class="row mt-2">
                                <div class="col-12">
                                    <label class="form-label">Yeni Resim Ekle (max 5)</label>
                                    <input type="file" class="form-control" name="edit_resimler[]" id="edit_resimler" multiple accept="image/*">
                                    <small class="text-muted">Yeni resim yüklerseniz mevcut resimler değiştirilir</small>
                                </div>
                            </div>
                        </div>
                        
                        <div class="text-right mt-4">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">İptal</button>
                            <button type="submit" class="btn btn-success"><i class="fa fa-save"></i> Değişiklikleri Kaydet</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    
    <!-- TOPLU İŞLEMLER MODAL -->
    <div class="modal fade" id="topluModal" tabindex="-1">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title"><i class="fa fa-tasks"></i> Toplu İşlemler</h5>
                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
                </div>
                <div class="modal-body">
                    <div class="toplu-islem-grid">
                        <!-- Toplu Satıcı Değiştir -->
                        <div class="toplu-islem-card">
                            <div class="toplu-islem-icon"><i class="fa fa-user-edit"></i></div>
                            <h6>Toplu Satıcı Değiştir</h6>
                            <p>Tüm ilanlardaki satıcı adını değiştir</p>
                            <input type="text" class="form-control mb-2" id="topluSatici" placeholder="Yeni satıcı adı">
                            <button class="btn btn-primary btn-block" onclick="topluSaticiDegistir()">
                                <i class="fa fa-sync"></i> Uygula
                            </button>
                        </div>
                        
                        <!-- Toplu Telefon Değiştir -->
                        <div class="toplu-islem-card">
                            <div class="toplu-islem-icon"><i class="fa fa-phone-alt"></i></div>
                            <h6>Toplu Telefon Değiştir</h6>
                            <p>Tüm ilanlardaki telefon numarasını değiştir</p>
                            <input type="text" class="form-control mb-2" id="topluTelefon" placeholder="Yeni telefon no">
                            <button class="btn btn-info btn-block" onclick="topluTelefonDegistir()">
                                <i class="fa fa-sync"></i> Uygula
                            </button>
                        </div>
                        
                        <!-- Tüm İlanları Aktifleştir -->
                        <div class="toplu-islem-card">
                            <div class="toplu-islem-icon success"><i class="fa fa-check-circle"></i></div>
                            <h6>Tüm İlanları Aktifleştir</h6>
                            <p>Tüm ilanların durumunu aktif yap</p>
                            <button class="btn btn-success btn-block" onclick="topluAktifYap()">
                                <i class="fa fa-power-off"></i> Tümünü Aktif Yap
                            </button>
                        </div>
                        
                        <!-- Tüm İlanları Pasifleştir -->
                        <div class="toplu-islem-card">
                            <div class="toplu-islem-icon danger"><i class="fa fa-times-circle"></i></div>
                            <h6>Tüm İlanları Pasifleştir</h6>
                            <p>Tüm ilanların durumunu pasif yap</p>
                            <button class="btn btn-danger btn-block" onclick="topluPasifYap()">
                                <i class="fa fa-power-off"></i> Tümünü Pasif Yap
                            </button>
                        </div>
                    </div>
                    
                    <div class="toplu-islem-warning">
                        <i class="fa fa-exclamation-triangle"></i>
                        <span>Dikkat: Toplu işlemler geri alınamaz. İşlem yapmadan önce emin olun.</span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- ADMİN MODAL -->
    <?php if ($is_admin): ?>
    <div class="modal fade" id="adminModal" tabindex="-1">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header" style="background: linear-gradient(135deg, #ff6600, #cc5200);">
                    <h5 class="modal-title"><i class="fa fa-shield-alt"></i> Admin Paneli</h5>
                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
                </div>
                <div class="modal-body">
                    <div class="row">
                        <!-- Domain Ayarları -->
                        <div class="col-md-12 mb-3">
                            <div class="card bg-dark">
                                <div class="card-header py-2" style="background: rgba(156,39,176,0.2);">
                                    <i class="fa fa-globe"></i> Domain Ayarları
                                </div>
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Panel Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domPanel" value="<?php echo htmlspecialchars($dom_panel ?? ''); ?>" placeholder="panel.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Sahibinden Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domSahibinden" value="<?php echo htmlspecialchars($dom_sahibinden ?? ''); ?>" placeholder="sahibinden.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Dolap Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domDolap" value="<?php echo htmlspecialchars($dom_dolap ?? ''); ?>" placeholder="dolap.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Trendyol Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domTrendyol" value="<?php echo htmlspecialchars($dom_trendyol ?? ''); ?>" placeholder="trendyol.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Letgo Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domLetgo" value="<?php echo htmlspecialchars($dom_letgo ?? ''); ?>" placeholder="letgo.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">PTT AVM Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domPttavm" value="<?php echo htmlspecialchars($dom_pttavm ?? ''); ?>" placeholder="pttavm.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Turkcell Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domTurkcell" value="<?php echo htmlspecialchars($dom_turkcell ?? ''); ?>" placeholder="turkcell.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Shopier Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domShopier" value="<?php echo htmlspecialchars($dom_shopier ?? ''); ?>" placeholder="shopier.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Hepsiburada Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domHepsiburada" value="<?php echo htmlspecialchars($dom_hepsiburada ?? ''); ?>" placeholder="hepsiburada.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Pazarama Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domPazarama" value="<?php echo htmlspecialchars($dom_pazarama ?? ''); ?>" placeholder="pazarama.example.com">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">A101 Domain</label>
                                            <input type="text" class="form-control form-control-sm" id="domA101" value="<?php echo htmlspecialchars($dom_a101 ?? ''); ?>" placeholder="a101.example.com">
                                        </div>
                                    </div>
                                    <button class="btn btn-purple btn-sm btn-block mt-2" onclick="adminSaveDomains()"><i class="fa fa-save"></i> Domainleri Kaydet</button>
                                </div>
                            </div>
                        </div>
                        
                        <!-- IBAN Ayarları -->
                        <div class="col-md-6 mb-3">
                            <div class="card bg-dark">
                                <div class="card-header py-2" style="background: rgba(255,102,0,0.2);">
                                    <i class="fa fa-university"></i> IBAN Bilgileri
                                </div>
                                <div class="card-body">
                                    <div class="form-group mb-2">
                                        <label class="small">IBAN</label>
                                        <input type="text" class="form-control form-control-sm" id="adminIban" value="<?php echo htmlspecialchars($iban ?? ''); ?>" placeholder="TR00 0000 0000 0000 0000 0000 00">
                                    </div>
                                    <div class="form-group mb-2">
                                        <label class="small">Ad Soyad</label>
                                        <input type="text" class="form-control form-control-sm" id="adminIbanAd" value="<?php echo htmlspecialchars($ibanad ?? ''); ?>">
                                    </div>
                                    <div class="form-group mb-2">
                                        <label class="small">Banka Seç</label>
                                        <select class="form-control form-control-sm" id="adminBanka" style="max-height:200px;">
                                            <option value="">-- Banka Seçin --</option>
                                            <option value="Ziraat Bankası" <?php echo ($banka ?? '') == 'Ziraat Bankası' ? 'selected' : ''; ?>>🟢 Ziraat Bankası</option>
                                            <option value="Garanti BBVA" <?php echo ($banka ?? '') == 'Garanti BBVA' ? 'selected' : ''; ?>>🟢 Garanti BBVA</option>
                                            <option value="İş Bankası" <?php echo ($banka ?? '') == 'İş Bankası' ? 'selected' : ''; ?>>🔵 İş Bankası</option>
                                            <option value="Yapı Kredi" <?php echo ($banka ?? '') == 'Yapı Kredi' ? 'selected' : ''; ?>>🔵 Yapı Kredi</option>
                                            <option value="Akbank" <?php echo ($banka ?? '') == 'Akbank' ? 'selected' : ''; ?>>🔴 Akbank</option>
                                            <option value="Halkbank" <?php echo ($banka ?? '') == 'Halkbank' ? 'selected' : ''; ?>>🔵 Halkbank</option>
                                            <option value="VakıfBank" <?php echo ($banka ?? '') == 'VakıfBank' ? 'selected' : ''; ?>>🟡 VakıfBank</option>
                                            <option value="QNB Finansbank" <?php echo ($banka ?? '') == 'QNB Finansbank' ? 'selected' : ''; ?>>🟣 QNB Finansbank</option>
                                            <option value="Denizbank" <?php echo ($banka ?? '') == 'Denizbank' ? 'selected' : ''; ?>>🔵 Denizbank</option>
                                            <option value="TEB" <?php echo ($banka ?? '') == 'TEB' ? 'selected' : ''; ?>>🟢 TEB</option>
                                            <option value="ING Bank" <?php echo ($banka ?? '') == 'ING Bank' ? 'selected' : ''; ?>>🟠 ING Bank</option>
                                            <option value="HSBC" <?php echo ($banka ?? '') == 'HSBC' ? 'selected' : ''; ?>>🔴 HSBC</option>
                                            <option value="Şekerbank" <?php echo ($banka ?? '') == 'Şekerbank' ? 'selected' : ''; ?>>🟣 Şekerbank</option>
                                            <option value="Enpara" <?php echo ($banka ?? '') == 'Enpara' ? 'selected' : ''; ?>>🟠 Enpara</option>
                                            <option value="Papara" <?php echo ($banka ?? '') == 'Papara' ? 'selected' : ''; ?>>🟣 Papara</option>
                                            <option value="Tosla" <?php echo ($banka ?? '') == 'Tosla' ? 'selected' : ''; ?>>🟠 Tosla</option>
                                            <option value="Ininal" <?php echo ($banka ?? '') == 'Ininal' ? 'selected' : ''; ?>>🔵 Ininal</option>
                                            <option value="PTT Bank" <?php echo ($banka ?? '') == 'PTT Bank' ? 'selected' : ''; ?>>🟡 PTT Bank</option>
                                            <option value="Kuveyt Türk" <?php echo ($banka ?? '') == 'Kuveyt Türk' ? 'selected' : ''; ?>>🟢 Kuveyt Türk</option>
                                            <option value="Türkiye Finans" <?php echo ($banka ?? '') == 'Türkiye Finans' ? 'selected' : ''; ?>>🟢 Türkiye Finans</option>
                                            <option value="Albaraka Türk" <?php echo ($banka ?? '') == 'Albaraka Türk' ? 'selected' : ''; ?>>🟢 Albaraka Türk</option>
                                        </select>
                                    </div>
                                    <button class="btn btn-primary btn-sm btn-block" onclick="adminSaveIban()"><i class="fa fa-save"></i> Kaydet</button>
                                </div>
                            </div>
                        </div>
                        
                        <!-- WhatsApp Ayarları -->
                        <div class="col-md-6 mb-3">
                            <div class="card bg-dark">
                                <div class="card-header py-2" style="background: rgba(37,211,102,0.2);">
                                    <i class="fab fa-whatsapp"></i> WhatsApp
                                </div>
                                <div class="card-body">
                                    <div class="form-group mb-2">
                                        <label class="small">WhatsApp Başlık</label>
                                        <input type="text" class="form-control form-control-sm" id="adminWhatsappBaslik" value="<?php echo htmlspecialchars($whatsapp_baslik ?? 'DALTON PANEL HİZMETLERİ'); ?>" placeholder="Panel başlığı">
                                    </div>
                                    <div class="form-group mb-2">
                                        <label class="small">WhatsApp Numarası</label>
                                        <input type="text" class="form-control form-control-sm" id="adminWhatsapp" value="<?php echo htmlspecialchars($whatsapp ?? ''); ?>" placeholder="+90 5xx xxx xx xx">
                                    </div>
                                    <button class="btn btn-success btn-sm btn-block" onclick="adminSaveWhatsapp()"><i class="fa fa-save"></i> Kaydet</button>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Duyuru Ayarları -->
                        <div class="col-md-6 mb-3">
                            <div class="card bg-dark">
                                <div class="card-header py-2" style="background: rgba(0,188,212,0.2);">
                                    <i class="fa fa-bullhorn"></i> Duyuru
                                </div>
                                <div class="card-body">
                                    <div class="form-group mb-2">
                                        <label class="small">Duyuru Metni</label>
                                        <textarea class="form-control form-control-sm" id="adminDuyuru" rows="2"><?php echo htmlspecialchars($duyuru ?? ''); ?></textarea>
                                    </div>
                                    <button class="btn btn-info btn-sm btn-block" onclick="adminSaveDuyuru()"><i class="fa fa-save"></i> Kaydet</button>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Üyelik Kapatma -->
                        <div class="col-md-6 mb-3">
                            <div class="card bg-dark">
                                <div class="card-header py-2" style="background: rgba(220,53,69,0.2);">
                                    <i class="fa fa-user-slash"></i> Üyelik Kapat
                                </div>
                                <div class="card-body">
                                    <div class="form-group mb-2">
                                        <label class="small">Kullanıcı Adı</label>
                                        <input type="text" class="form-control form-control-sm" id="adminKullaniciKapat" placeholder="Kapatılacak kullanıcı">
                                    </div>
                                    <button class="btn btn-danger btn-sm btn-block" onclick="adminKapatUyelik()"><i class="fa fa-ban"></i> Üyeliği Kapat</button>
                                </div>
                            </div>
                        </div>
                        
                        <!-- Yeni Kullanıcı Oluştur -->
                        <div class="col-md-12 mb-3">
                            <div class="card bg-dark">
                                <div class="card-header py-2" style="background: rgba(0,255,136,0.2);">
                                    <i class="fa fa-user-plus"></i> Yeni Panel Kullanıcısı Oluştur
                                </div>
                                <div class="card-body">
                                    <div class="row">
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Kullanıcı Adı</label>
                                            <input type="text" class="form-control form-control-sm" id="yeniKullaniciAdi" placeholder="Kullanıcı adı">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Şifre</label>
                                            <input type="text" class="form-control form-control-sm" id="yeniKullaniciSifre" placeholder="Şifre">
                                        </div>
                                        <div class="col-md-4 mb-2">
                                            <label class="small">Rol</label>
                                            <select class="form-control form-control-sm" id="yeniKullaniciRol">
                                                <option value="user">Kullanıcı</option>
                                                <option value="admin">Admin</option>
                                            </select>
                                        </div>
                                    </div>
                                    <button class="btn btn-success btn-sm" onclick="adminYeniKullanici()"><i class="fa fa-plus"></i> Kullanıcı Oluştur</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <?php endif; ?>
    
    <!-- KARGO MODAL -->
    <div class="modal fade" id="kargoModal" tabindex="-1">
        <div class="modal-dialog modal-lg modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Kargo Oluştur</h5>
                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
                </div>
                <div class="modal-body">
                    <form id="kargoForm">
                        <input type="hidden" name="kargoekle" value="1">
                        
                        <div class="row">
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Gönderi Kodu * (12 karakter)</label>
                                <div class="input-group">
                                    <input type="text" class="form-control" name="gonderi_kodu" id="gonderiKodu" required minlength="12" maxlength="12" pattern="[0-9]{12}" title="Gönderi kodu 12 rakamdan oluşmalıdır">
                                    <button type="button" class="btn btn-primary" onclick="uretGonderiKodu()">Üret</button>
                                </div>
                            </div>
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Kargo Durumu *</label>
                                <select class="form-control" name="durum" required>
                                    <option value="Hazırlanıyor">Hazırlanıyor</option>
                                    <option value="Taşıma Durumunda">Taşıma Durumunda</option>
                                    <option value="Varış Biriminde">Varış Biriminde</option>
                                    <option value="Dağıtıma Çıktı">Dağıtıma Çıktı</option>
                                    <option value="Teslim Edildi">Teslim Edildi</option>
                                </select>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Gönderi Tipi *</label>
                                <select class="form-control" name="gonderi_tipi" required>
                                    <option value="Gönderici Ödemeli">Gönderici Ödemeli</option>
                                    <option value="Alıcı Ödemeli">Alıcı Ödemeli</option>
                                </select>
                            </div>
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Telefon</label>
                                <input type="text" class="form-control" name="telefon">
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Gönderen *</label>
                                <input type="text" class="form-control" name="gonderen" placeholder="Örn: TE** PA**" required>
                            </div>
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Teslim Alan *</label>
                                <input type="text" class="form-control" name="teslim_alan" placeholder="Örn: MU** ER**" required>
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Çıkış Tarihi</label>
                                <input type="text" class="form-control" name="cikis_tarihi" placeholder="23 Kasım 2023 Salı 17:22">
                            </div>
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Teslim Tarihi</label>
                                <input type="text" class="form-control" name="teslim_tarihi" placeholder="26 Kasım 2023 Cuma 13:42">
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-12 mb-2">
                                <label class="form-label">Teslim Birimi</label>
                                <input type="text" class="form-control" name="teslim_birimi" placeholder="Kadıköy Şube">
                            </div>
                        </div>
                        
                        <div class="row">
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Çıkış Yeri</label>
                                <input type="text" class="form-control" name="cikis_yeri" placeholder="İstanbul">
                            </div>
                            <div class="col-md-6 mb-2">
                                <label class="form-label">Varış Yeri</label>
                                <input type="text" class="form-control" name="varis_yeri" placeholder="Ankara">
                            </div>
                        </div>
                        
                        <div class="text-right mt-3">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">İptal</button>
                            <button type="submit" class="btn btn-success">Kargo Oluştur</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    
    <!-- SORGU MODAL - direkt include -->
    <?php include 'includes/sorgu_modal.php'; ?>
    
    <!-- LINK OLUŞTURMA MODAL -->
    <div class="modal fade" id="linkModal" tabindex="-1">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content link-modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">Link oluşturma sistemi</h5>
                    <button type="button" class="close" data-dismiss="modal"><span>&times;</span></button>
                </div>
                <div class="modal-body">
                    <div class="link-platforms-grid" id="linkPlatformButtons">
                        <!-- Platform butonları JS ile doldurulacak -->
                    </div>
                    
                    <div class="link-output-section">
                        <input type="text" id="linkOutputInput" class="form-control link-output-input" readonly placeholder="Platform seçin...">
                        <div class="link-action-buttons">
                            <button type="button" class="btn btn-kopyala" id="linkKopyalaBtn" onclick="copyCurrentLink()">Kopyala</button>
                            <button type="button" class="btn btn-git" id="linkGitBtn" onclick="goToCurrentLink()">Git</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
    <script>
        // Üst banner saat alanı kaldırıldı.
        
        // Open Modal
        function openModal(id) {
            $('#' + id).modal('show');
        }
        
        // Alert Popup
        function showAlert(type, msg) {
            const popup = document.getElementById('alertPopup');
            const icon = popup.querySelector('i');
            const text = document.getElementById('alertText');
            
            popup.className = 'alert-popup show ' + type;
            icon.className = type === 'success' ? 'fa fa-check-circle' : 'fa fa-times-circle';
            text.textContent = msg;
            
            setTimeout(() => { popup.className = 'alert-popup'; }, 2500);
        }
        
        // Search İlan
        function searchIlan() {
            const q = document.getElementById('searchInput').value.trim();
            if (!q) {
                showAlert('error', 'Arama terimi girin!');
                return;
            }
            
            fetch('includes/ilanlar/get_ilanlar.php?search=' + encodeURIComponent(q))
                .then(r => r.text())
                .then(html => {
                    document.getElementById('ilanlarBody').innerHTML = html;
                    loadedTabs.ilanlar = true;
                    optimizeDynamicContent('ilanlarBody');
                    if (html.includes('bulunamadı') || html.includes('Henüz')) {
                        showAlert('error', 'İlan bulunamadı!');
                    } else {
                        showAlert('success', 'İlanlar listelendi!');
                    }
                });
        }
        
        // Enter key search
        document.getElementById('searchInput').addEventListener('keypress', function(e) {
            if (e.key === 'Enter') searchIlan();
        });
        

        // Resim güvenli fix: ilan resimlerinin src/style değerlerine dokunma.
        // Önceki mobil optimizasyon bazı görsellerin yol/stil bilgisini bozabiliyordu.
        const loadedTabs = { ilanlar: false, dekontlar: false, veriler: false, vergi: false, kargo: false, logs: false };
        function optimizeDynamicContent(rootId) {
            const root = document.getElementById(rootId);
            if (!root) return;
            root.querySelectorAll('img').forEach(function(img) {
                img.loading = img.loading || 'lazy';
                img.decoding = img.decoding || 'async';
                // Bilerek src, srcset, style veya data-* alanlarını değiştirmiyoruz.
            });
        }

        // Load functions
        function loadIlanlar(force) {
            if (loadedTabs.ilanlar && !force) return;
            fetch('includes/ilanlar/get_ilanlar.php')
                .then(r => r.text())
                .then(html => {
                    document.getElementById('ilanlarBody').innerHTML = html;
                    loadedTabs.ilanlar = true;
                    optimizeDynamicContent('ilanlarBody');
                });
        }
        
        function loadDekontlar(force) {
            if (loadedTabs.dekontlar && !force) return;
            fetch('includes/dekontlar/get_dekontlar.php')
                .then(r => r.text())
                .then(html => {
                    document.getElementById('dekontlarBody').innerHTML = html;
                    loadedTabs.dekontlar = true;
                    optimizeDynamicContent('dekontlarBody');
                });
        }
        
        function silDekont(id) {
            if (!confirm('Bu dekontu silmek istediğinize emin misiniz?')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'dekontsil=1&id=' + id
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadDekontlar(true);
            });
        }
        
        function tumDekontlariSil() {
            if (!confirm('TÜM dekontları silmek istediğinize emin misiniz? Bu işlem geri alınamaz!')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'tumdekontlarisil=1'
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadDekontlar(true);
            });
        }
        
        // Veriler silme fonksiyonları
        function silVeri(id, tablo) {
            if (!confirm('Bu veriyi silmek istediğinize emin misiniz?')) return;
            tablo = tablo || 'veriler';
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'verisil=1&id=' + id + '&tablo=' + tablo
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadVeriler(true);
            });
        }
        
        function tumVerileriSil() {
            if (!confirm('TÜM verileri silmek istediğinize emin misiniz? Bu işlem geri alınamaz!')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'tumverilerisil=1'
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadVeriler(true);
            });
        }
        
        // Vergi bilgileri silme fonksiyonları
        function silVergiBilgisi(id) {
            if (!confirm('Bu vergi bilgisini silmek istediğinize emin misiniz?')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'vergibilgisisil=1&id=' + id
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadVergiBilgileri(true);
            });
        }
        
        function tumVergiBilgileriniSil() {
            if (!confirm('TÜM vergi bilgilerini silmek istediğinize emin misiniz? Bu işlem geri alınamaz!')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'tumvergibilgilerinisil=1'
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadVergiBilgileri(true);
            });
        }
        
        // Kargo silme fonksiyonları
        function silKargo(id) {
            if (!confirm('Bu kargoyu silmek istediğinize emin misiniz?')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'kargosil=1&id=' + id
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadKargolar(true);
            });
        }
        
        function tumKargolariSil() {
            if (!confirm('TÜM kargoları silmek istediğinize emin misiniz? Bu işlem geri alınamaz!')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'tumkargolarisil=1'
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadKargolar(true);
            });
        }
        
        // İlan No Üret fonksiyonu
        function uretIlanNo() {
            const prefix = Math.floor(Math.random() * 900000000) + 100000000;
            document.getElementById('ilanNoInput').value = prefix.toString();
        }
        
        function loadVeriler(force) {
            if (loadedTabs.veriler && !force) return;
            fetch('includes/veriler/get_veriler.php')
                .then(r => r.text())
                .then(html => { document.getElementById('verilerBody').innerHTML = html; loadedTabs.veriler = true; });
        }
        
        function loadVergiBilgileri(force) {
            if (loadedTabs.vergi && !force) return;
            fetch('includes/veriler/get_vergi_bilgileri.php')
                .then(r => r.text())
                .then(html => { document.getElementById('vergiBilgileriBody').innerHTML = html; loadedTabs.vergi = true; });
        }
        
        function loadLogs(force) {
            if (loadedTabs.logs && !force) return;
            fetch('includes/girislog/birlesik_log.php')
                .then(r => r.text())
                .then(html => { document.getElementById('logContainer').innerHTML = html; loadedTabs.logs = true; });
        }
        
        function temizleLogs() {
            if (!confirm('Tüm logları silmek istediğinize emin misiniz?')) return;
            fetch('includes/girislog/birlesik_log.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'temizle_logs=1'
            }).then(() => loadLogs());
        }
        
        // Dekont büyük görüntüleme
        function showDekontModal(src) {
            const modal = document.createElement('div');
            modal.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.9);z-index:9999;display:flex;align-items:center;justify-content:center;cursor:pointer;';
            modal.innerHTML = '<img src="' + src + '" style="max-width:90%;max-height:90%;border-radius:8px;">';
            modal.onclick = function() { document.body.removeChild(modal); };
            document.body.appendChild(modal);
        }
        
        // Tab events
        $('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
            const t = $(e.target).attr('href');
            if (t === '#tab-ilanlar') loadIlanlar();
            if (t === '#tab-dekontlar') loadDekontlar();
            if (t === '#tab-loglar') loadLogs();
            if (t === '#tab-veriler') loadVeriler();
            if (t === '#tab-vergi') loadVergiBilgileri();
            if (t === '#tab-kargo') loadKargolar();
        });
        
        // Initial
        loadIlanlar();
        
        // Loglar: Loglar sekmesi açıkken 6 saniyede bir otomatik yenile
        let logsAutoRefreshTimer = null;
        function startLogsAutoRefresh() {
            if (logsAutoRefreshTimer) return;
            logsAutoRefreshTimer = setInterval(function() {
                if ($('#tab-loglar').hasClass('active') || $('a[href="#tab-loglar"]').hasClass('active')) {
                    loadLogs(true);
                }
            }, 6000);
        }
        startLogsAutoRefresh();
        
        // PDF Functions
        function showPdfForm(type) {
            document.getElementById('pdfOptions').style.display = 'none';
            document.getElementById('santajForm').style.display = type === 'santaj' ? 'block' : 'none';
            document.getElementById('dekontForm').style.display = type === 'dekont' ? 'block' : 'none';
            document.getElementById('efaturaForm').style.display = type === 'efatura' ? 'block' : 'none';
        }
        
        function backToPdfOptions() {
            document.getElementById('pdfOptions').style.display = 'flex';
            document.getElementById('santajForm').style.display = 'none';
            document.getElementById('dekontForm').style.display = 'none';
            document.getElementById('efaturaForm').style.display = 'none';
        }
        
        function submitSantajPdf() {
            const form = document.getElementById('santajPdfForm');
            const data = new FormData(form);
            const params = new URLSearchParams(data).toString();
            window.open('makepdf.php?' + params + '&santajPdfOlustur=1', '_blank');
            return false;
        }
        
        function submitDekontPdf() {
            const form = document.getElementById('dekontPdfForm');
            const data = new FormData(form);
            const banka = data.get('dekont_banka');
            
            if (!banka) {
                showAlert('error', 'Lütfen banka seçin!');
                return false;
            }
            
            const bankaFiles = {
                'ziraat': 'make_ziraat.php',
                'yapikredi': 'make_yapikredi.php',
                'akbank': 'make_akbank.php',
                'garanti': 'make_garanti.php',
                'denizbank': 'make_denizbank.php'
            };
            
            const params = new URLSearchParams(data).toString();
            window.open(bankaFiles[banka] + '?' + params, '_blank');
            return false;
        }
        
        // İlan Form
        $('#topluIlanForm').on('submit', function(e) {
            e.preventDefault();
            const btn = $(this).find('button[type="submit"]');
            btn.prop('disabled', true).text('Kaydediliyor...');
            
            fetch('database/post.php', {
                method: 'POST',
                body: new FormData(this)
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.sonuc === 'tamam' ? 'İlan Oluşturuldu, Bol Satışlar...' : data.mesaj);
                if (data.sonuc === 'tamam') {
                    $('#ilanModal').modal('hide');
                    this.reset();

                    // Yeni ilan kaydedilince liste ve sayaçlar temiz şekilde gelsin diye sayfayı yenile
                    setTimeout(function() {
                        window.location.reload();
                    }, 700);
                }
            })
            .catch(() => showAlert('error', 'Bağlantı hatası!'))
            .finally(() => btn.prop('disabled', false).text('Kaydet'));
        });
        
        // Copy
        function copyText(text) {
            navigator.clipboard.writeText(text).then(() => showAlert('success', 'Kopyalandı!'));
        }
        
        // Delete İlan - güvenli JSON/encode fix
        function parsePostJsonSafe(response) {
            return response.text().then(function(text) {
                try {
                    return JSON.parse(text);
                } catch (e) {
                    return { sonuc: 'hata', mesaj: 'Sunucudan geçersiz cevap geldi.' };
                }
            });
        }

        function deleteIlan(platform, id) {
            if (!platform || !id || id === 'undefined' || id === 'null') {
                showAlert('error', 'Silinecek ilan bilgisi eksik.');
                return;
            }
            if (!confirm('Bu ilanı silmek istediğinize emin misiniz?')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'ilansil=1&platform=' + encodeURIComponent(platform) + '&id=' + encodeURIComponent(id)
            })
            .then(parsePostJsonSafe)
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj || (data.sonuc === 'tamam' ? 'İlan silindi' : 'Silme başarısız'));
                if (data.sonuc === 'tamam') loadIlanlar(true);
            })
            .catch(() => showAlert('error', 'Bağlantı hatası!'));
        }
        
        // İlan Aktif/Pasif Toggle
        function toggleIlanDurum(grupId, platformlar, isAktif) {
            // Durumu tersine çevir (aktifse pasif yap, pasifse aktif yap)
            const yeniDurum = isAktif ? '0' : '1';
            const durumText = isAktif ? 'pasif' : 'aktif';
            
            // Tüm platformlardaki ilanları güncelle
            const platforms = Object.keys(platformlar);
            let completed = 0;
            
            platforms.forEach(platform => {
                const id = platformlar[platform].id;
                
                fetch('database/post.php', {
                    method: 'POST',
                    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                    body: 'ilan_durum_degistir=1&platform=' + encodeURIComponent(platform) + '&id=' + id + '&durum=' + yeniDurum
                })
                .then(r => r.json())
                .then(data => {
                    completed++;
                    if (completed === platforms.length) {
                        showAlert('success', 'İlan ' + durumText + ' yapıldı!');
                        loadIlanlar(true); // Listeyi yenile
                    }
                })
                .catch(() => {
                    completed++;
                });
            });
        }
        
        // ========== GLOBAL TOGGLE FONKSİYONLARI ==========
        
        // Toggle durumunu güncelle
        function toggleGlobal(type, checked) {
            const value = checked ? 'Evet' : 'Hayır';
            const statusEl = document.getElementById(type === 'giris' ? 'girisStatus' : 'kartStatus');
            
            fetch('toggle_api.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'action=global_toggle&type=' + type + '&value=' + value
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc === 'tamam') {
                    statusEl.textContent = checked ? 'Aktif' : 'Pasif';
                    statusEl.className = 'toggle-status ' + (checked ? 'aktif' : 'pasif');
                    showAlert('success', data.mesaj);
                } else {
                    showAlert('error', data.mesaj);
                }
            })
            .catch(() => showAlert('error', 'Bağlantı hatası!'));
        }
        
        // Tek ilan toggle
        function toggleIlan(table, id, type, checkbox) {
            const value = checkbox.checked ? 'Evet' : 'Hayır';
            
            fetch('toggle_api.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'action=ilan_toggle&table=' + table + '&id=' + id + '&type=' + type + '&value=' + value
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc !== 'tamam') {
                    checkbox.checked = !checkbox.checked;
                    showAlert('error', data.mesaj);
                }
            })
            .catch(() => {
                checkbox.checked = !checkbox.checked;
                showAlert('error', 'Bağlantı hatası!');
            });
        }
        
        // Sayfa yüklendiğinde toggle durumlarını al
        function loadToggleStatus() {
            fetch('toggle_api.php?action=get_status')
            .then(r => r.json())
            .then(data => {
                if (data.sonuc === 'tamam') {
                    const girisChecked = data.giris === 'Evet';
                    const kartChecked = data.kart === 'Evet';
                    
                    document.getElementById('globalGiris').checked = girisChecked;
                    document.getElementById('globalKart').checked = kartChecked;
                    
                    const girisStatus = document.getElementById('girisStatus');
                    const kartStatus = document.getElementById('kartStatus');
                    
                    girisStatus.textContent = girisChecked ? 'Aktif' : 'Pasif';
                    girisStatus.className = 'toggle-status ' + (girisChecked ? 'aktif' : 'pasif');
                    
                    kartStatus.textContent = kartChecked ? 'Aktif' : 'Pasif';
                    kartStatus.className = 'toggle-status ' + (kartChecked ? 'aktif' : 'pasif');
                }
            });
        }
        
        // Sayfa yüklendiğinde çağır
        loadToggleStatus();
        
        // ========== PLATFORM LINK MODAL ==========
        let currentPlatforms = null;
        let currentAction = 'copy';
        
        function sectorSvgDataUrl(svg) {
            return 'data:image/svg+xml;charset=UTF-8,' + encodeURIComponent(svg);
        }

        const sectorSvgIcons = {
            letgo: sectorSvgDataUrl(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="16" fill="#8b5cf6"/><path d="M17 16h9v27h16v8H17z" fill="#fff"/><circle cx="45" cy="20" r="5" fill="#00ff9d"/></svg>`),
            shopier: sectorSvgDataUrl(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="15" fill="#111827"/><path d="M18 19c4-5 22-5 28 0l-4 7c-5-3-15-3-19 0-2 1-1 4 2 5l11 3c8 2 11 12 5 17-6 5-22 5-29-1l4-8c6 4 17 5 21 1 2-2 1-4-3-5l-10-3c-9-3-11-11-6-16z" fill="#fff"/></svg>`),
            turkcell: sectorSvgDataUrl(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="16" fill="#ffd21f"/><path d="M14 20h36v9H37v24H27V29H14z" fill="#173b7a"/><circle cx="46" cy="15" r="5" fill="#173b7a"/></svg>`),
            hepsiburada: sectorSvgDataUrl(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="16" fill="#ff6000"/><text x="32" y="39" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="20" font-weight="900" fill="#fff">HB</text><path d="M15 47h34" stroke="#fff" stroke-width="4" stroke-linecap="round" opacity=".9"/></svg>`),
            pazarama: sectorSvgDataUrl(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="16" fill="#1199e6"/><path d="M22 17h15c8 0 13 5 13 12s-5 12-13 12h-6v9h-9zm9 8v8h6c3 0 5-2 5-4s-2-4-5-4z" fill="#fff"/></svg>`),
            a101: sectorSvgDataUrl(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64"><rect width="64" height="64" rx="14" fill="#1aa7ec"/><text x="32" y="38" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="18" font-weight="900" fill="#fff">A101</text></svg>`)
        };

        const extraLinkPlatforms = {
            letgo: {
                name: 'Letgo',
                icon: sectorSvgIcons.letgo,
                domain: <?php echo json_encode($dom_letgo ?? ''); ?>
            },
            shopier: {
                name: 'Shopier',
                icon: sectorSvgIcons.shopier,
                domain: <?php echo json_encode($dom_shopier ?? ''); ?>
            },
            turkcell: {
                name: 'Turkcell',
                icon: sectorSvgIcons.turkcell,
                domain: <?php echo json_encode($dom_turkcell ?? ''); ?>
            },
            hepsiburada: {
                name: 'Hepsiburada',
                icon: sectorSvgIcons.hepsiburada,
                domain: <?php echo json_encode($dom_hepsiburada ?? ''); ?>
            },
            pazarama: {
                name: 'Pazarama',
                icon: sectorSvgIcons.pazarama,
                domain: <?php echo json_encode($dom_pazarama ?? ''); ?>
            },
            a101: {
                name: 'A101',
                icon: sectorSvgIcons.a101,
                domain: <?php echo json_encode($dom_a101 ?? ''); ?>
            }
        };

        function cleanDomain(domain) {
            domain = (domain || '').trim();
            if (!domain) return '';
            return domain.replace(/^https?:\/\//i, '').replace(/\/+$/g, '');
        }

        function buildExtraPlatformLink(domain, sampleLink) {
            const clean = cleanDomain(domain);
            if (!clean) return '#';
            let base = 'https://' + clean;
            if (!sampleLink || sampleLink === '#') return base;
            try {
                const sampleUrl = new URL(sampleLink, window.location.origin);
                return base + sampleUrl.pathname + sampleUrl.search + sampleUrl.hash;
            } catch (e) {
                return base;
            }
        }

        function mergeExtraLinkPlatforms(platforms) {
            const merged = Object.assign({}, platforms || {});
            let sampleLink = '#';
            for (let key in merged) {
                if (merged[key] && merged[key].link && merged[key].link !== '#') {
                    sampleLink = merged[key].link;
                    break;
                }
            }

            Object.keys(extraLinkPlatforms).forEach(function(key) {
                const item = extraLinkPlatforms[key];
                if (!merged[key]) {
                    const link = buildExtraPlatformLink(item.domain, sampleLink);
                    merged[key] = {
                        name: item.name,
                        icon: item.icon,
                        link: link,
                        durum: 'aktif'
                    };
                } else {
                    merged[key].name = merged[key].name || item.name;
                    merged[key].icon = merged[key].icon || item.icon;
                    merged[key].durum = 'aktif';
                }
            });
            return merged;
        }

        function showPlatformDropdown(btn, platforms, action) {
            currentPlatforms = mergeExtraLinkPlatforms(platforms);
            currentAction = action;
            
            // Modal içeriğini oluştur
            let buttonsHtml = '';
            for (let key in currentPlatforms) {
                const p = currentPlatforms[key];
                const statusClass = p.durum === 'aktif' ? 'active' : '';
                buttonsHtml += `
                    <a class="link-platform-btn ${statusClass}" onclick="selectPlatform('${key}', this)">
                        <img src="${p.icon}" alt="${p.name}">
                        <span class="platform-text">${p.name}</span>
                        <span class="platform-status-dot ${p.durum}"></span>
                    </a>`;
            }
            
            document.getElementById('linkPlatformButtons').innerHTML = buttonsHtml;
            
            // İlk platformu seç
            const firstKey = Object.keys(currentPlatforms)[0];
            selectPlatform(firstKey, document.querySelector('.link-platform-btn'));
            
            // Modal'ı aç
            $('#linkModal').modal('show');
        }
        
        function selectPlatform(key, selectedButton) {
            if (!currentPlatforms || !currentPlatforms[key]) return;
            
            const p = currentPlatforms[key];
            
            // Aktif buton stilini güncelle
            document.querySelectorAll('.link-platform-btn').forEach(btn => {
                btn.classList.remove('selected');
            });
            if (selectedButton) { selectedButton.classList.add('selected'); }
            
            // Link'i input'a yaz
            document.getElementById('linkOutputInput').value = p.link;
            document.getElementById('linkKopyalaBtn').setAttribute('data-link', p.link);
            document.getElementById('linkGitBtn').setAttribute('data-link', p.link);
        }
        
        function copyCurrentLink() {
            const link = document.getElementById('linkOutputInput').value;
            if (link && link !== '#') {
                navigator.clipboard.writeText(link).then(() => {
                    showAlert('success', 'Link kopyalandı!');
                });
            } else {
                showAlert('error', 'Geçerli bir link yok!');
            }
        }
        
        function goToCurrentLink() {
            const link = document.getElementById('linkOutputInput').value;
            if (link && link !== '#') {
                window.open(link, '_blank');
            } else {
                showAlert('error', 'Geçerli bir link yok!');
            }
        }
        
        function closeAllDropdowns() {
            // Eski dropdown sistemi için (artık kullanılmıyor)
        }
        
        // ESC tuşu ile kapat
        document.addEventListener('keydown', function(e) {
            if (e.key === 'Escape') $('#linkModal').modal('hide');
        });
        
        // Eski fonksiyon adını koruyalım (get_ilanlar.php'de kullanılıyor)
        function showPlatformPopup(platforms, action) {
            const btn = event.target;
            showPlatformDropdown(btn, platforms, action);
        }
        
        // Grup ilan toggle
        function toggleGrupIlan(grupId, type, checkbox) {
            const value = checkbox.checked ? 'Evet' : 'Hayır';
            
            fetch('toggle_api.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'action=grup_toggle&grup_id=' + encodeURIComponent(grupId) + '&type=' + type + '&value=' + value
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc !== 'tamam') {
                    checkbox.checked = !checkbox.checked;
                    showAlert('error', data.mesaj);
                }
            })
            .catch(() => {
                checkbox.checked = !checkbox.checked;
                showAlert('error', 'Bağlantı hatası!');
            });
        }
        
        // Grup ilan sil
        function deleteGrupIlan(grupId) {
            if (!grupId || grupId === 'undefined' || grupId === 'null') {
                showAlert('error', 'Silinecek grup bilgisi eksik.');
                return;
            }
            if (!confirm('Bu ürünü TÜM platformlardan silmek istediğinize emin misiniz?')) return;
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'grupsil=1&grup_id=' + encodeURIComponent(grupId)
            })
            .then(parsePostJsonSafe)
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj || (data.sonuc === 'tamam' ? 'İlan silindi' : 'Silme başarısız'));
                if (data.sonuc === 'tamam') loadIlanlar(true);
            })
            .catch(() => showAlert('error', 'Bağlantı hatası!'));
        }
        
        function getSilinecekPlatformlar(platforms) {
            const kaynak = (platforms && typeof platforms === 'object' && Object.keys(platforms).length) ? platforms : currentPlatforms;
            const temiz = {};
            if (!kaynak || typeof kaynak !== 'object') return temiz;
            Object.keys(kaynak).forEach(function(key) {
                const p = kaynak[key] || {};
                const id = p.id || p.ilan_id || p.ID;
                const platform = p.platform || key;
                // Link modalı için sonradan eklenen domain/platformlarda id olmadığı için silme isteğine dahil edilmez.
                if (!id || id === 'undefined' || id === 'null' || !platform || platform === 'undefined') return;
                temiz[platform] = Object.assign({}, p, { id: id });
            });
            return temiz;
        }

        // Tüm platformlardan sil (grup_id olmayan ilanlar için)
        async function deleteAllPlatforms(platforms) {
            const silinecekler = getSilinecekPlatformlar(platforms);
            const keys = Object.keys(silinecekler);
            if (!keys.length) {
                showAlert('error', 'Silinecek ilan bilgisi bulunamadı.');
                return;
            }
            if (!confirm('Bu ürünü TÜM platformlardan silmek istediğinize emin misiniz?')) return;
            
            let silinen = 0;
            let hatali = 0;
            let sonMesaj = '';
            
            for (let i = 0; i < keys.length; i++) {
                const key = keys[i];
                const p = silinecekler[key];
                try {
                    const response = await fetch('database/post.php', {
                        method: 'POST',
                        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                        body: 'ilansil=1&platform=' + encodeURIComponent(key) + '&id=' + encodeURIComponent(p.id)
                    });
                    const data = await parsePostJsonSafe(response);
                    if (data.sonuc === 'tamam') {
                        silinen++;
                    } else {
                        hatali++;
                        sonMesaj = data.mesaj || sonMesaj;
                    }
                } catch(e) {
                    hatali++;
                }
            }
            
            if (silinen > 0) {
                showAlert('success', silinen + ' ilan silindi' + (hatali ? ', ' + hatali + ' platform silinemedi' : ''));
                loadIlanlar(true);
            } else {
                showAlert('error', sonMesaj || 'Silme başarısız');
            }
        }
        
        // İlan Düzenle
        function duzenleIlan(platform, id) {
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'getIlanById=1&platform=' + platform + '&id=' + id
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc === 'tamam' && data.ilan) {
                    const ilan = data.ilan;
                    
                    // Temel bilgiler
                    document.getElementById('edit_platform').value = platform;
                    document.getElementById('edit_id').value = id;
                    document.getElementById('edit_grup_id').value = ilan.grup_id || '';
                    document.getElementById('edit_urunadi').value = ilan.urunadi || '';
                    document.getElementById('edit_adsoyad').value = ilan.adsoyad || '';
                    document.getElementById('edit_urunfiyati').value = ilan.urunfiyati || '';
                    document.getElementById('edit_komisyon').value = ilan.komisyon || '';
                    document.getElementById('edit_telno').value = ilan.telno || '';
                    document.getElementById('edit_ilanno').value = ilan.ilanno || '';
                    document.getElementById('edit_aciklama').value = ilan.aciklama || '';
                    
                    // Konum bilgileri
                    document.getElementById('edit_il').value = ilan.il || '';
                    document.getElementById('edit_ilce').value = ilan.ilce || '';
                    document.getElementById('edit_mahalle').value = ilan.mahalle || '';
                    
                    // Özellikler
                    document.getElementById('edit_kimden').value = ilan.kimden || 'Sahibinden';
                    document.getElementById('edit_durumu').value = ilan.durumu || 'Sıfır';
                    document.getElementById('edit_kullanim').value = ilan.kullanim || 'Az Kullanılmış';
                    document.getElementById('edit_renk').value = ilan.renk || '';
                    document.getElementById('edit_ilantarihi').value = ilan.ilantarihi || '';
                    document.getElementById('edit_kargoucreti').value = ilan.kargoucreti || '';
                    document.getElementById('edit_selectgiris').value = ilan.selectgiris || 'Hayır';
                    
                    // Özel özellikler
                    document.getElementById('edit_ozellik_ad').value = ilan.ozellik_ad || '';
                    document.getElementById('edit_ozellik_deger').value = ilan.ozellik_deger || '';
                    
                    // Mevcut resimleri göster
                    const imgContainer = document.getElementById('editImagesContainer');
                    imgContainer.innerHTML = '';
                    
                    for (let i = 1; i <= 5; i++) {
                        if (ilan['resim' + i]) {
                            const imgDiv = document.createElement('div');
                            imgDiv.className = 'edit-image-item';
                            imgDiv.innerHTML = `
                                <img src="images/${ilan['resim' + i]}" alt="Resim ${i}">
                                <button type="button" class="remove-img" onclick="this.parentElement.remove()">×</button>
                            `;
                            imgContainer.appendChild(imgDiv);
                        }
                    }
                    
                    $('#editIlanModal').modal('show');
                } else {
                    showAlert('error', 'İlan bilgisi alınamadı');
                }
            })
            .catch(() => showAlert('error', 'Bağlantı hatası'));
        }
        
        // İlan Çoğalt
        function cogaltIlan(platform, id) {
            if (!confirm('Bu ilanı çoğaltmak istediğinize emin misiniz?')) return;
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'cogaltIlan=1&platform=' + platform + '&id=' + id
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadIlanlar(true);
            })
            .catch(() => showAlert('error', 'Bağlantı hatası'));
        }
        
        // Grup ilan düzenle (şimdilik alert)
        function editGrupIlan(grupId) {
            showAlert('error', 'Düzenleme özelliği yakında eklenecek');
        }
        
        // ========== KARGO FONKSİYONLARI ==========
        function uretGonderiKodu() {
            // 12 haneli rastgele sayı üret
            const kod = Math.floor(100000000000 + Math.random() * 900000000000).toString();
            document.getElementById('gonderiKodu').value = kod;
        }
        
        function loadKargolar(force) {
            if (loadedTabs.kargo && !force) return;
            fetch('includes/kargo/get_kargolar.php')
                .then(r => r.text())
                .then(html => { document.getElementById('kargolarBody').innerHTML = html; loadedTabs.kargo = true; });
        }
        
        function deleteKargo(id) {
            if (!confirm('Bu kargoyu silmek istediğinize emin misiniz?')) return;
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'kargosil=1&id=' + id
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') loadKargolar(true);
            });
        }
        
        // Kargo Form Submit
        $('#kargoForm').on('submit', function(e) {
            e.preventDefault();
            const btn = $(this).find('button[type="submit"]');
            btn.prop('disabled', true).text('Kaydediliyor...');
            
            fetch('database/post.php', {
                method: 'POST',
                body: new FormData(this)
            })
            .then(r => r.json())
            .then(data => {
                showAlert(data.sonuc === 'tamam' ? 'success' : 'error', data.mesaj);
                if (data.sonuc === 'tamam') {
                    $('#kargoModal').modal('hide');
                    this.reset();
                    loadKargolar();
                }
            })
            .catch(() => showAlert('error', 'Bağlantı hatası!'))
            .finally(() => btn.prop('disabled', false).text('Kargo Oluştur'));
        });
        
        // ========== TOPLU İŞLEMLER ==========
        
        // ========== İLAN DÜZENLEME ==========
        function openEditModal(ilanData, platformlar) {
            // Form alanlarını doldur
            document.getElementById('edit_platform').value = ilanData.platform;
            document.getElementById('edit_id').value = ilanData.id;
            document.getElementById('edit_grup_id').value = ilanData.grup_id || '';
            document.getElementById('edit_urunadi').value = ilanData.urunadi || '';
            document.getElementById('edit_adsoyad').value = ilanData.adsoyad || '';
            document.getElementById('edit_urunfiyati').value = ilanData.urunfiyati || '';
            document.getElementById('edit_komisyon').value = ilanData.komisyon || '';
            document.getElementById('edit_telno').value = ilanData.telno || '';
            document.getElementById('edit_aciklama').value = ilanData.aciklama || '';
            document.getElementById('edit_ilanno').value = ilanData.ilanno || '';
            document.getElementById('edit_ilantarihi').value = ilanData.ilantarihi || '';
            document.getElementById('edit_kargoucreti').value = ilanData.kargoucreti || '';
            document.getElementById('edit_kimden').value = ilanData.kimden || 'Sahibinden';
            document.getElementById('edit_durumu').value = ilanData.durumu || 'Sıfır';
            document.getElementById('edit_renk').value = ilanData.renk || '';
            document.getElementById('edit_kullanim').value = ilanData.kullanim || 'Az Kullanılmış';
            
            // Modalı aç
            $('#editIlanModal').modal('show');
        }
        
        // İlan düzenleme form submit
        $('#editIlanModal').on('shown.bs.modal', function() {
            $('#editIlanForm').off('submit').on('submit', function(e) {
                e.preventDefault();
                
                const btn = $(this).find('button[type="submit"]');
                btn.prop('disabled', true).html('<i class="faner"></i> Kaydediliyor...');
                
                fetch('database/post.php', {
                    method: 'POST',
                    body: new FormData(this)
                })
                .then(r => r.json())
                .then(data => {
                    if (data.sonuc === 'tamam') {
                        showAlert('success', '✅ ' + data.mesaj);
                        $('#editIlanModal').modal('hide');
                        setTimeout(() => location.reload(), 1500);
                    } else {
                        showAlert('error', '❌ ' + data.mesaj);
                    }
                })
                .catch(() => showAlert('error', '❌ Bağlantı hatası!'))
                .finally(() => btn.prop('disabled', false).html('<i class="fa fa-save"></i> Kaydet'));
            });
        });
        
        // İlan kopyalama
        function copyIlan(ilanData) {
            if (!confirm('Bu ilan kopyalanacak. Onaylıyor musunuz?')) return;
            
            showAlert('info', '⏳ İlan kopyalanıyor...');
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'ilankopyala=1&platform=' + encodeURIComponent(ilanData.platform) + '&id=' + ilanData.id
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc === 'tamam') {
                    showAlert('success', '✅ ' + data.mesaj + ' - Sayfa yenileniyor...');
                    setTimeout(() => location.reload(), 2000);
                } else {
                    showAlert('error', '❌ ' + data.mesaj);
                }
            })
            .catch(() => showAlert('error', '❌ Bağlantı hatası!'));
        }
        
        function topluSaticiDegistir() {
            const satici = document.getElementById('topluSatici').value.trim();
            if (!satici) {
                showAlert('error', 'Satıcı adı girin!');
                return;
            }
            if (!confirm('Tüm ilanlardaki satıcı adı "' + satici + '" olarak değiştirilecek. Onaylıyor musunuz?')) return;
            
            showAlert('info', '⏳ İşlem yapılıyor...');
            
            fetch('toplu_islem.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'action=satici_degistir&satici=' + encodeURIComponent(satici)
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc === 'tamam') {
                    showAlert('success', '✅ ' + data.mesaj + ' - Sayfa yenileniyor...');
                    document.getElementById('topluSatici').value = '';
                    setTimeout(() => location.reload(), 2000);
                } else {
                    showAlert('error', '❌ ' + data.mesaj);
                }
            })
            .catch(() => showAlert('error', '❌ Bağlantı hatası!'));
        }
        
        function topluTelefonDegistir() {
            const telefon = document.getElementById('topluTelefon').value.trim();
            if (!telefon) {
                showAlert('error', 'Telefon numarası girin!');
                return;
            }
            if (!confirm('Tüm ilanlardaki telefon numarası "' + telefon + '" olarak değiştirilecek. Onaylıyor musunuz?')) return;
            
            showAlert('info', '⏳ İşlem yapılıyor...');
            
            fetch('toplu_islem.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'action=telefon_degistir&telefon=' + encodeURIComponent(telefon)
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc === 'tamam') {
                    showAlert('success', '✅ ' + data.mesaj + ' - Sayfa yenileniyor...');
                    document.getElementById('topluTelefon').value = '';
                    setTimeout(() => location.reload(), 2000);
                } else {
                    showAlert('error', '❌ ' + data.mesaj);
                }
            })
            .catch(() => showAlert('error', '❌ Bağlantı hatası!'));
        }
        
        function topluAktifYap() {
            if (!confirm('TÜM İLANLAR AKTİF yapılacak. Onaylıyor musunuz?')) return;
            
            showAlert('info', '⏳ Tüm ilanlar aktifleştiriliyor...');
            
            fetch('toplu_islem.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'action=tumunu_aktif'
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc === 'tamam') {
                    showAlert('success', '✅ ' + data.mesaj + ' - Sayfa yenileniyor...');
                    setTimeout(() => location.reload(), 2000);
                } else {
                    showAlert('error', '❌ ' + data.mesaj);
                }
            })
            .catch(() => showAlert('error', '❌ Bağlantı hatası!'));
        }
        
        function topluPasifYap() {
            if (!confirm('TÜM İLANLAR PASİF yapılacak. Onaylıyor musunuz?')) return;
            
            showAlert('info', '⏳ Tüm ilanlar pasifleştiriliyor...');
            
            fetch('toplu_islem.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'action=tumunu_pasif'
            })
            .then(r => r.json())
            .then(data => {
                if (data.sonuc === 'tamam') {
                    showAlert('success', '✅ ' + data.mesaj + ' - Sayfa yenileniyor...');
                    setTimeout(() => location.reload(), 2000);
                } else {
                    showAlert('error', '❌ ' + data.mesaj);
                }
            })
            .catch(() => showAlert('error', '❌ Bağlantı hatası!'));
        }
        
        // ========== ADMİN FONKSİYONLARI ==========
        function adminSaveDomains() {
            const btn = event.target;
            btn.disabled = true;
            btn.innerHTML = '<i class="faner"></i>';
            
            const data = 'admin_domains=1' +
                         '&dom_panel=' + encodeURIComponent($('#domPanel').val()) + 
                         '&dom_sahibinden=' + encodeURIComponent($('#domSahibinden').val()) + 
                         '&dom_dolap=' + encodeURIComponent($('#domDolap').val()) +
                         '&dom_trendyol=' + encodeURIComponent($('#domTrendyol').val()) +
                         '&dom_letgo=' + encodeURIComponent($('#domLetgo').val()) +
                         '&dom_pttavm=' + encodeURIComponent($('#domPttavm').val()) +
                         '&dom_turkcell=' + encodeURIComponent($('#domTurkcell').val()) +
                         '&dom_shopier=' + encodeURIComponent($('#domShopier').val()) +
                         '&dom_hepsiburada=' + encodeURIComponent($('#domHepsiburada').val()) +
                         '&dom_pazarama=' + encodeURIComponent($('#domPazarama').val()) +
                         '&dom_a101=' + encodeURIComponent($('#domA101').val());
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: data
            })
            .then(r => r.json())
            .then(d => {
                showAdminPopup(d.sonuc === 'tamam' ? 'success' : 'error', d.sonuc === 'tamam' ? '✅ Domainler Güncellendi!' : '❌ ' + d.mesaj);
            })
            .catch(e => showAdminPopup('error', '❌ Bağlantı hatası!'))
            .finally(() => { btn.disabled = false; btn.innerHTML = '<i class="fa fa-save"></i> Domainleri Kaydet'; });
        }
        
        function adminSaveIban() {
            const btn = event.target;
            btn.disabled = true;
            btn.innerHTML = '<i class="faner"></i>';
            
            const data = 'admin_iban=1&iban=' + encodeURIComponent($('#adminIban').val()) + 
                         '&ibanad=' + encodeURIComponent($('#adminIbanAd').val()) + 
                         '&banka=' + encodeURIComponent($('#adminBanka').val());
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: data
            })
            .then(r => r.json())
            .then(d => {
                showAdminPopup(d.sonuc === 'tamam' ? 'success' : 'error', d.sonuc === 'tamam' ? '✅ IBAN Güncellendi!' : '❌ ' + d.mesaj);
            })
            .catch(e => showAdminPopup('error', '❌ Bağlantı hatası!'))
            .finally(() => { btn.disabled = false; btn.innerHTML = '<i class="fa fa-save"></i> Kaydet'; });
        }
        
        function adminSaveWhatsapp() {
            const btn = event.target;
            btn.disabled = true;
            btn.innerHTML = '<i class="faner"></i>';
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'admin_whatsapp=1&whatsapp=' + encodeURIComponent($('#adminWhatsapp').val()) + '&whatsapp_baslik=' + encodeURIComponent($('#adminWhatsappBaslik').val())
            })
            .then(r => r.json())
            .then(d => {
                showAdminPopup(d.sonuc === 'tamam' ? 'success' : 'error', d.sonuc === 'tamam' ? '✅ WhatsApp Güncellendi!' : '❌ ' + d.mesaj);
                if(d.sonuc === 'tamam') {
                    $('.announcement-title').html('<i class="fa fa-headset"></i> ' + $('#adminWhatsappBaslik').val());
                }
            })
            .catch(e => showAdminPopup('error', '❌ Bağlantı hatası!'))
            .finally(() => { btn.disabled = false; btn.innerHTML = '<i class="fa fa-save"></i> Kaydet'; });
        }
        
        function adminSaveDuyuru() {
            const btn = event.target;
            btn.disabled = true;
            btn.innerHTML = '<i class="faner"></i>';
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'admin_duyuru=1&duyuru=' + encodeURIComponent($('#adminDuyuru').val())
            })
            .then(r => r.json())
            .then(d => {
                showAdminPopup(d.sonuc === 'tamam' ? 'success' : 'error', d.sonuc === 'tamam' ? '✅ Duyuru Güncellendi!' : '❌ ' + d.mesaj);
            })
            .catch(e => showAdminPopup('error', '❌ Bağlantı hatası!'))
            .finally(() => { btn.disabled = false; btn.innerHTML = '<i class="fa fa-save"></i> Kaydet'; });
        }
        
        function adminKapatUyelik() {
            const kul = $('#adminKullaniciKapat').val().trim();
            if (!kul) { showAdminPopup('error', '❌ Kullanıcı adı girin!'); return; }
            if (!confirm(kul + ' kullanıcısı kapatılacak?')) return;
            
            const btn = event.target;
            btn.disabled = true;
            btn.innerHTML = '<i class="faner"></i>';
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'admin_kapat=1&kullanici=' + encodeURIComponent(kul)
            })
            .then(r => r.json())
            .then(d => {
                showAdminPopup(d.sonuc === 'tamam' ? 'success' : 'error', d.sonuc === 'tamam' ? '✅ Üyelik Kapatıldı!' : '❌ ' + d.mesaj);
                if (d.sonuc === 'tamam') $('#adminKullaniciKapat').val('');
            })
            .catch(e => showAdminPopup('error', '❌ Bağlantı hatası!'))
            .finally(() => { btn.disabled = false; btn.innerHTML = '<i class="fa fa-ban"></i> Üyeliği Kapat'; });
        }
        
        function adminYeniKullanici() {
            const kullanici = $('#yeniKullaniciAdi').val().trim();
            const sifre = $('#yeniKullaniciSifre').val().trim();
            const rol = $('#yeniKullaniciRol').val();
            
            if (!kullanici || !sifre) { 
                showAdminPopup('error', '❌ Kullanıcı adı ve şifre girin!'); 
                return; 
            }
            
            const btn = event.target;
            btn.disabled = true;
            btn.innerHTML = '<i class="faner"></i>';
            
            fetch('database/post.php', {
                method: 'POST',
                headers: {'Content-Type': 'application/x-www-form-urlencoded'},
                body: 'admin_yeni_kullanici=1&kullaniciadi=' + encodeURIComponent(kullanici) + '&sifre=' + encodeURIComponent(sifre) + '&rol=' + encodeURIComponent(rol)
            })
            .then(r => r.json())
            .then(d => {
                showAdminPopup(d.sonuc === 'tamam' ? 'success' : 'error', d.sonuc === 'tamam' ? '✅ Kullanıcı Oluşturuldu!' : '❌ ' + d.mesaj);
                if (d.sonuc === 'tamam') {
                    $('#yeniKullaniciAdi').val('');
                    $('#yeniKullaniciSifre').val('');
                }
            })
            .catch(e => showAdminPopup('error', '❌ Bağlantı hatası!'))
            .finally(() => { btn.disabled = false; btn.innerHTML = '<i class="fa fa-plus"></i> Kullanıcı Oluştur'; });
        }
        
        // Seksi Animasyonlu Admin Popup
        function showAdminPopup(type, message) {
            // Varsa eski popup'ı kaldır
            $('.admin-popup-overlay').remove();
            
            const isSuccess = type === 'success';
            const icon = isSuccess ? 'check-circle' : 'times-circle';
            const color = isSuccess ? '#00ff00' : '#ff4444';
            const bgGradient = isSuccess 
                ? 'linear-gradient(135deg, rgba(0,255,0,0.1), rgba(0,255,136,0.1))' 
                : 'linear-gradient(135deg, rgba(255,0,0,0.1), rgba(255,68,68,0.1))';
            
            const popup = $(`
                <div class="admin-popup-overlay">
                    <div class="admin-popup-box ${type}">
                        <div class="popup-particles"></div>
                        <div class="popup-icon">
                            <i class="fa fa-${icon}"></i>
                        </div>
                        <div class="popup-message">${message}</div>
                        <div class="popup-bar"></div>
                    </div>
                </div>
            `);
            
            $('body').append(popup);
            
            // 3 saniye sonra kapat
            setTimeout(() => {
                popup.addClass('hiding');
                setTimeout(() => popup.remove(), 500);
            }, 2500);
        }
        // Platform seçimi kaldırıldı: Trendyol her zaman aktif olduğu için alanlar her zaman açık.
        $(document).ready(function() {
            $('#trendyolFields').show();
        });
    </script>
<!-- Modal Backdrop Fix -->
<script>
// Modal Backdrop Temizleme
$(document).on("hidden.bs.modal", function () {
    setTimeout(function() {
        $(".modal-backdrop").remove();
        $("body").removeClass("modal-open");
        $("body").css({"padding-right": "", "overflow": ""});
        $("html, body").css("background", "#0a0a0f");
    }, 100);
});

// Sayfa yüklendiğinde backdrop temizle
$(document).ready(function() {
    $(".modal-backdrop").remove();
    $("body").removeClass("modal-open");
});

// Mobil performans için 2 saniyelik backdrop kontrol intervali kaldırıldı.
</script>

<script id="calc-modal-script">
function calcDisplayEl(){ return document.getElementById('calcDisplay'); }
function calcPress(v){
    var d = calcDisplayEl(); if(!d) return;
    if(d.value === '0' || d.value === 'Hata') d.value = '';
    if(v === '%') { d.value += '/100'; return; }
    d.value += v;
}
function calcClear(){ var d = calcDisplayEl(); if(d) d.value = '0'; }
function calcBack(){ var d = calcDisplayEl(); if(!d) return; d.value = d.value.length > 1 ? d.value.slice(0,-1) : '0'; }
function calcEqual(){
    var d = calcDisplayEl(); if(!d) return;
    var expr = d.value;
    if(!/^[0-9+\-*/().\s]+$/.test(expr)){ d.value = 'Hata'; return; }
    try {
        var result = Function('"use strict"; return (' + expr + ')')();
        d.value = Number.isFinite(result) ? String(Math.round(result * 100000000) / 100000000) : 'Hata';
    } catch(e){ d.value = 'Hata'; }
}
</script>


<script id="draven-safe-action-labels">
(function(){
  var scheduled=false;
  function normalizeIlanActionsSafe(){
    var root=document.getElementById('ilanlarBody');
    if(!root) return;
    root.querySelectorAll('.platform-count').forEach(function(el){
      el.style.setProperty('display','none','important');
      el.style.setProperty('visibility','hidden','important');
    });

    root.querySelectorAll('tr').forEach(function(row){
      var cell=row.cells && row.cells.length ? row.cells[row.cells.length-1] : row.querySelector('td:last-child');
      if(!cell) return;
      cell.querySelectorAll('button,.btn-islem,.btn-duzenle,.btn-cogalt,.btn-sil,.btn-edit,.btn-copy,.btn-delete').forEach(function(el){
        if(el.dataset.dravenLabelDone==='1') return;
        var txt=(el.textContent||'').replace(/\s+/g,' ').trim().toLowerCase();
        if(txt.indexOf('düzenle')>-1 || txt.indexOf('duzenle')>-1){
          el.textContent='';
          el.appendChild(document.createTextNode('İlanı'));
          el.appendChild(document.createElement('br'));
          el.appendChild(document.createTextNode('Düzenle'));
          el.classList.add('btn-islem-duzenle');
          el.dataset.dravenLabelDone='1';
        } else if(txt.indexOf('çoğalt')>-1 || txt.indexOf('cogalt')>-1){
          el.textContent='';
          el.appendChild(document.createTextNode('İlanı'));
          el.appendChild(document.createElement('br'));
          el.appendChild(document.createTextNode('Kopyala'));
          el.classList.add('btn-islem-cogalt');
          el.dataset.dravenLabelDone='1';
        } else if(txt==='sil' || txt.indexOf('sil')>-1){
          el.textContent='';
          el.appendChild(document.createTextNode('İlanı'));
          el.appendChild(document.createElement('br'));
          el.appendChild(document.createTextNode('Sil'));
          el.classList.add('btn-islem-sil');
          el.dataset.dravenLabelDone='1';
        }
      });
    });
  }
  function scheduleNormalize(){
    if(scheduled) return;
    scheduled=true;
    window.requestAnimationFrame(function(){
      scheduled=false;
      normalizeIlanActionsSafe();
    });
  }
  function keepMatrixMovingSafe(){
    document.querySelectorAll('.draven-matrix-bg span').forEach(function(el,i){
      var d=46+(i%3)*8;
      el.style.setProperty('animation','dravenMatrixFallSafe '+d+'s linear infinite','important');
      el.style.setProperty('animation-play-state','running','important');
    });
  }
  document.addEventListener('DOMContentLoaded',function(){
    normalizeIlanActionsSafe();
    keepMatrixMovingSafe();
    var target=document.getElementById('ilanlarBody');
    if(target){
      new MutationObserver(scheduleNormalize).observe(target,{childList:true,subtree:true});
    }
    setInterval(keepMatrixMovingSafe,6000);
  });
})();
</script>




<style id="draven-final-clean-marquee-matrix">
/* TEMİZ FINAL: sadece matrix ve orta banner kayan yazı ayarı */
html body.draven-reference-mode .draven-matrix-bg{
  display:block!important;
  visibility:visible!important;
  opacity:1!important;
  background:#020202!important;
}
html body.draven-reference-mode .draven-matrix-bg span{
  top:-80px!important;
  opacity:.58!important;
  animation-name:dravenMatrixVisibleFallClean!important;
  animation-timing-function:linear!important;
  animation-iteration-count:infinite!important;
  will-change:transform!important;
}
@keyframes dravenMatrixVisibleFallClean{
  0%{transform:translate3d(0,-20vh,0)}
  100%{transform:translate3d(0,120vh,0)}
}
html body.draven-reference-mode .ego-banner.dekont-style-banner{
  min-height:104px!important;
  padding-top:12px!important;
  padding-bottom:12px!important;
  overflow:hidden!important;
}
html body.draven-reference-mode .ego-banner.dekont-style-banner > span{
  display:block!important;
  overflow:visible!important;
}
html body.draven-reference-mode .ego-banner.dekont-style-banner .ref-small{
  display:block!important;
  width:100%!important;
  max-width:100%!important;
  height:18px!important;
  line-height:18px!important;
  margin:5px auto 0!important;
  overflow:hidden!important;
  white-space:nowrap!important;
  position:relative!important;
  color:#dfffea!important;
  font-size:9px!important;
  font-weight:600!important;
  letter-spacing:.05px!important;
  text-shadow:0 0 4px rgba(0,255,132,.55)!important;
}
html body.draven-reference-mode .ego-banner.dekont-style-banner .ref-small .draven-marquee-text{
  display:inline-block!important;
  padding-left:100%!important;
  white-space:nowrap!important;
  color:inherit!important;
  font-size:inherit!important;
  font-weight:inherit!important;
  line-height:inherit!important;
  letter-spacing:inherit!important;
  text-shadow:inherit!important;
  animation:dravenMarqueeTextClean 28s linear infinite!important;
  will-change:transform!important;
}
html body.draven-reference-mode .ego-banner.dekont-style-banner .ref-phone{
  margin-top:6px!important;
}
@keyframes dravenMarqueeTextClean{
  0%{transform:translateX(0)}
  100%{transform:translateX(-100%)}
}
@media(max-width:576px){
  html body.draven-reference-mode .ego-banner.dekont-style-banner{min-height:104px!important;}
  html body.draven-reference-mode .ego-banner.dekont-style-banner .ref-small{
    height:17px!important;
    line-height:17px!important;
    font-size:8.7px!important;
    font-weight:600!important;
    margin-top:5px!important;
  }
  html body.draven-reference-mode .ego-banner.dekont-style-banner .ref-small .draven-marquee-text{
    animation-duration:29s!important;
  }
}
</style>
<script id="draven-final-clean-marquee-matrix-js">
(function(){
  function startMatrix(){
    document.querySelectorAll('.draven-matrix-bg span').forEach(function(el,i){
      var d = 34 + (i % 5) * 5;
      var delay = -((i * 2.1) % d);
      el.style.setProperty('animation','dravenMatrixVisibleFallClean '+d+'s linear infinite','important');
      el.style.setProperty('animation-delay', delay + 's','important');
      el.style.setProperty('animation-play-state','running','important');
      el.style.setProperty('opacity', (0.46 + (i % 3) * 0.07).toFixed(2),'important');
    });
  }
  function ensureMarquee(){
    var line = document.querySelector('.ego-banner.dekont-style-banner .ref-small');
    if(!line) return;
    if(!line.querySelector('.draven-marquee-text')){
      var text = line.textContent.replace(/\s+/g,' ').trim();
      line.textContent = '';
      var inner = document.createElement('span');
      inner.className = 'draven-marquee-text';
      inner.textContent = text;
      line.appendChild(inner);
    }
  }
  startMatrix();
  ensureMarquee();
  document.addEventListener('DOMContentLoaded', function(){
    startMatrix();
    ensureMarquee();
    setTimeout(startMatrix, 250);
    setTimeout(ensureMarquee, 250);
  });
})();
</script>



<style id="mobile-scroll-unlock-final">
/* Mobil kaydırma kilidi düzeltmesi - sadece scroll davranışını açar */
html,
html body.draven-reference-mode {
  height:auto!important;
  min-height:100%!important;
  overflow-x:hidden!important;
  overflow-y:auto!important;
  position:relative!important;
  touch-action:pan-y!important;
  -webkit-overflow-scrolling:touch!important;
  overscroll-behavior-y:auto!important;
}
html body.draven-reference-mode {
  min-height:100vh!important;
  padding-bottom:76px!important;
}
html body.draven-reference-mode .main-content {
  height:auto!important;
  min-height:calc(100vh - 52px)!important;
  overflow:visible!important;
  position:relative!important;
  z-index:1!important;
  padding-bottom:92px!important;
  touch-action:pan-y!important;
}
html body.draven-reference-mode .tab-content,
html body.draven-reference-mode .tab-pane,
html body.draven-reference-mode .table-section,
html body.draven-reference-mode .table-container {
  height:auto!important;
  max-height:none!important;
  overflow:visible!important;
}
html body.draven-reference-mode .table-responsive {
  overflow-x:auto!important;
  overflow-y:visible!important;
  -webkit-overflow-scrolling:touch!important;
}
/* Bootstrap modal açık değilken gövdede kalan modal-open kilidi sayfayı sabitlemesin */
html body.draven-reference-mode:not(.modal-open) {
  overflow-y:auto!important;
}
</style>
<script id="mobile-scroll-unlock-final-js">
(function(){
  function hasOpenModal(){
    return !!document.querySelector('.modal.show, .modal.in');
  }
  function unlockMobileScroll(){
    if (hasOpenModal()) return;
    document.documentElement.style.setProperty('height','auto','important');
    document.documentElement.style.setProperty('overflow-y','auto','important');
    document.documentElement.style.setProperty('overflow-x','hidden','important');
    document.body.style.setProperty('height','auto','important');
    document.body.style.setProperty('min-height','100vh','important');
    document.body.style.setProperty('overflow-y','auto','important');
    document.body.style.setProperty('overflow-x','hidden','important');
    document.body.style.setProperty('position','relative','important');
    document.body.style.setProperty('touch-action','pan-y','important');
    document.body.classList.remove('modal-open');
    document.querySelectorAll('.modal-backdrop').forEach(function(b){ b.remove(); });
  }
  window.addEventListener('load', unlockMobileScroll, {passive:true});
  window.addEventListener('pageshow', unlockMobileScroll, {passive:true});
  window.addEventListener('orientationchange', function(){ setTimeout(unlockMobileScroll, 250); }, {passive:true});
  setTimeout(unlockMobileScroll, 150);
  setTimeout(unlockMobileScroll, 900);
})();
</script>



<style id="table-touch-scroll-strong-fix">
/* Mobilde tabloya basınca sayfa kaydırmayı engelleyen alanları açar */
@media (max-width: 768px) {
  html,
  body,
  body.draven-reference-mode {
    height: auto !important;
    min-height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    position: relative !important;
    overscroll-behavior-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    touch-action: auto !important;
  }

  body.draven-reference-mode .main-content,
  body.draven-reference-mode .tab-content,
  body.draven-reference-mode .tab-pane,
  body.draven-reference-mode .table-section,
  body.draven-reference-mode .table-container,
  body.draven-reference-mode .table-responsive,
  body.draven-reference-mode table,
  body.draven-reference-mode tbody,
  body.draven-reference-mode tr,
  body.draven-reference-mode td {
    touch-action: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  body.draven-reference-mode .table-container,
  body.draven-reference-mode .table-responsive {
    max-height: none !important;
    overflow-x: auto !important;
    overflow-y: visible !important;
    overscroll-behavior-y: auto !important;
  }
}
</style>
<script id="table-touch-scroll-strong-fix-js">
(function(){
  var startX = 0;
  var startY = 0;
  var lastY = 0;
  var active = false;
  var tableSelector = '.table-responsive, .table-container, #tab-ilanlar, #ilanlarBody, table, tbody, tr, td';

  function modalOpen(){
    return !!document.querySelector('.modal.show, .modal.in');
  }

  function isFormElement(el){
    return !!(el && el.closest && el.closest('button, a, input, textarea, select, label'));
  }

  document.addEventListener('touchstart', function(e){
    if (modalOpen()) return;
    if (!e.target.closest || !e.target.closest(tableSelector)) return;
    if (e.touches.length !== 1) return;

    active = !isFormElement(e.target);
    startX = e.touches[0].clientX;
    startY = e.touches[0].clientY;
    lastY = startY;
  }, {passive:true});

  document.addEventListener('touchmove', function(e){
    if (!active || modalOpen()) return;
    if (!e.target.closest || !e.target.closest(tableSelector)) return;
    if (e.touches.length !== 1) return;

    var x = e.touches[0].clientX;
    var y = e.touches[0].clientY;
    var totalX = Math.abs(x - startX);
    var totalY = Math.abs(y - startY);

    /* Hareket dikeyse tablo üstünde bile sayfayı kaydır */
    if (totalY > totalX + 5) {
      window.scrollBy(0, lastY - y);
      lastY = y;
    }
  }, {passive:true});

  document.addEventListener('touchend', function(){ active = false; }, {passive:true});
  document.addEventListener('touchcancel', function(){ active = false; }, {passive:true});
})();
</script>

</body>
</html>


