/* Custom ERP Styles */

:root {
    --primary-color: #4f46e5;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --sidebar-width: 260px;
    --navbar-height: 60px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f1f5f9;
    overflow-x: hidden;
}

/* Sidebar Styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    transition: all 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: #0f172a;
}

.sidebar::-webkit-scrollbar-thumb {
    background: #4f46e5;
    border-radius: 10px;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header .brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
}

.sidebar-menu li {
    margin-bottom: 5px;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: #cbd5e1;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.sidebar-menu a:hover {
    background: rgba(79, 70, 229, 0.1);
    color: white;
    padding-left: 25px;
}

.sidebar-menu > li > a.active {
    background: var(--primary-color);
    color: white;
    border-left: 4px solid white;
}

.sidebar-menu > li.has-submenu.active > a {
    color: white;
    background: rgba(79, 70, 229, 0.2);
}

.sidebar-menu a i {
    margin-right: 12px;
    font-size: 1.1rem;
    width: 20px;
}

/* ---------------------------------------------------------------------------
 * ALT MENÜ — AÇILDIĞINDA YÜKSEKLİK SINIRI YOKTUR.
 *
 * Önce `max-height: 500px` yazıyordu ve `overflow: hidden` ile birlikte
 * çalışıyordu. Finans alt menüsünde 25 madde var; 25 x ~40px = ~1000px.
 * Yani 500px'ten sonraki 15 madde EKRANDA HİÇ GÖRÜNMÜYORDU — Mali Tablolar,
 * Nakit Akışı, Kur Değerlemesi, Yevmiye Aktarımı, Vergi Beyannamesi…
 *
 * `<li>` etiketleri HTML'de vardı, izinler doğruydu, sayfalar açılıyordu.
 * Yalnızca CSS onları kesiyordu. Bu yüzden hata "izin sorunu" gibi görünüp
 * uzun süre yanlış yerde arandı: kaynağa bakan her şey doğruydu.
 *
 * Yükseklik animasyonu KALDIRILDI, yerine solma geldi. Sebebi şu: bir sayıya
 * bağlı `max-height`, menüye madde eklendikçe yeniden kırpar — aynı hata
 * sessizce geri gelir. `none` ile o sınıf hata bir daha mümkün değil.
 * Bir menünün özellik gizlemesi, animasyonsuz açılmasından kötüdür.
 *
 * (Kenar çubuğunun kendisi `overflow-y: auto`; uzun menü orada kayıyor.)
 * ------------------------------------------------------------------------ */
.sidebar-menu .submenu {
    list-style: none;
    padding-left: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.sidebar-menu .submenu.show {
    max-height: none;
    opacity: 1;
}

.sidebar-menu .submenu a {
    padding: 10px 20px 10px 52px;
    font-size: 0.9rem;
}

.sidebar-menu .submenu a.active {
    color: white;
    font-weight: 600;
    background: var(--primary-color);
    border-left: 3px solid white;
}

.bi-chevron-down {
    transition: transform 0.3s ease;
}

.bi-chevron-down.rotate-180 {
    transform: rotate(180deg);
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: all 0.3s ease;
}

/* Top Navbar */
.top-navbar {
    background: white;
    height: var(--navbar-height);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.toggle-sidebar {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--dark-color);
    cursor: pointer;
    display: none;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar-search {
    position: relative;
}

.navbar-search input {
    padding: 8px 15px 8px 40px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    width: 300px;
    transition: all 0.3s ease;
}

.navbar-search input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.navbar-search i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.user-menu {
    position: relative;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-avatar:hover {
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Page Content */
.page-content {
    padding: 30px;
}

.page-header {
    margin-bottom: 30px;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 5px;
}

.breadcrumb {
    background: none;
    padding: 0;
    margin: 0;
    font-size: 0.9rem;
}

/* Cards */
.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.card-header {
    background: white;
    border-bottom: 1px solid #f1f5f9;
    padding: 20px;
    border-radius: 12px 12px 0 0;
}

.card-body {
    padding: 20px;
}

/* Stats Cards */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.stat-icon.primary {
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary-color);
}

.stat-icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
}

.stat-icon.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
}

.stat-icon.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.stat-icon.info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info-color);
}

.stat-card h3 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 5px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background: #4338ca;
    border-color: #4338ca;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Tables */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table thead th {
    background: #f8fafc;
    color: var(--dark-color);
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
    padding: 15px;
}

.table tbody tr {
    transition: all 0.3s ease;
}

.table tbody tr:hover {
    background: #f8fafc;
}

/* Alerts */
.alert {
    border-radius: 8px;
    border: none;
    padding: 15px 20px;
}

/* Login Page Styles */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    max-width: 400px;
    width: 100%;
}

.login-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    padding: 40px 30px;
    color: white;
    text-align: center;
}

.login-body {
    padding: 40px 30px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .toggle-sidebar {
        display: block;
    }
    
    .navbar-search input {
        width: 200px;
    }
}

/* Loading Spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ==========================================================================
   VARLIK SEÇİCİ (entity_select.php + assets/js/lookup.js)

   Tek bileşen, ekrana göre iki sunum:
     • Masaüstü — alanın altında açılan liste (`.erp-lookup-list`).
     • Telefon  — ekranın altından çıkan tam panel (`.erp-sheet`).

   Aynı `<div class="erp-lookup">`ten ikisi de doğar; hangisinin
   kullanılacağına JS `matchMedia('(max-width: 768px)')` ile karar verir.
   Buradaki kesme noktası ile lookup.js'teki MOBILE_MAX AYNI olmalı; ikisi
   ayrışırsa dokunma hedefleri büyür ama panel açılmaz.
   ========================================================================== */

.erp-lookup-wrap {
    position: relative;
}

/* Liste `fixed` — konumu JS hesaplar (place()). Nedeni lookup.js'te
   yazılı: `.table-responsive` içindeki kalem satırlarında `absolute`
   bir liste yatay taşma kutusu tarafından kesiliyor. */
.erp-lookup-list {
    display: none;
    position: fixed;
    z-index: 1050;
    overflow-y: auto;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
    border: 1px solid #e2e8f0;
}

.erp-lookup-list.show {
    display: block;
}

.erp-lookup-item {
    text-align: left;
    border-left: 0;
    border-right: 0;
    padding: 0.5rem 0.75rem;
}

.erp-lookup-item:first-child { border-top: 0; }
.erp-lookup-item:last-child  { border-bottom: 0; }

/* Klavyeyle gezinirken etkin satır. Bootstrap'in `.active`i mavi dolgu
   veriyor; burada daha sakin bir vurgu yeterli çünkü satır seçilmedi,
   yalnızca üzerinde duruluyor. */
.erp-lookup-item.active,
.erp-lookup-item:hover {
    background: #eef2ff;
    color: var(--dark-color);
}

/* --- Mobil panel --------------------------------------------------------- */

.erp-sheet {
    position: fixed;
    inset: 0;
    z-index: 1060;          /* kenar çubuğu 1000, açılır liste 1050 */
}

.erp-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.erp-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    /* Ekranın tamamını kaplamıyor: üstte kalan şerit, kullanıcıya altta bir
       sayfa durduğunu ve panelin kapatılabilir olduğunu gösteriyor. */
    max-height: 85vh;
    background: #fff;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.25);
    animation: erpSheetUp 0.18s ease-out;
}

@keyframes erpSheetUp {
    from { transform: translateY(12%); opacity: 0.6; }
    to   { transform: translateY(0);   opacity: 1; }
}

/* Hareket duyarlılığı olan kullanıcılar için animasyonu kapat. */
@media (prefers-reduced-motion: reduce) {
    .erp-sheet-panel { animation: none; }
}

.erp-sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #e2e8f0;
}

.erp-sheet-title {
    font-weight: 600;
    color: var(--dark-color);
}

/* Temizle düğmesi alanın İÇİNDE, sağ kenarda. Seçim yokken hiç
   görünmüyor — boş bir alanın yanında duran bir × "burada bir şey vardı"
   izlenimi verir. */
.erp-lookup-clear {
    display: none;
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    z-index: 2;
    width: 26px;
    height: 26px;
    padding: 0;
    line-height: 1;
    font-size: 20px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #94a3b8;
}

.erp-lookup-clear.show { display: block; }
.erp-lookup-clear:hover { color: var(--danger-color); background: #f1f5f9; }

/* Düğmenin altına yazı girmesin. Sınıfı JS koyuyor; `:has()` ile
   yapmak daha kısa olurdu ama o zaman kural, tarayıcının `:has()`
   desteğine bağlı olurdu — desteklemeyen bir yerde yazı × ile
   ÜST ÜSTE biner. */
.erp-lookup-wrap.has-clear .erp-lookup-input { padding-right: 34px; }

.erp-sheet-clear {
    padding: 4px 16px 10px;
    border-bottom: 1px solid #f1f5f9;
}

/* Bootstrap'in `.btn-close`u 32px. Baş parmak için küçük — panelin
   kapatma düğmesi listeden daha zor dokunulan şey olmamalı. */
.erp-sheet-close {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    background-position: center;
    background-size: 14px;
    opacity: 0.6;
}

.erp-sheet-search {
    padding: 10px 16px;
}

/* iOS'ta yazı tipi 16px'in altındaysa alana dokunulduğunda sayfa
   YAKINLAŞTIRILIR ve bir daha eski haline dönmez. Panelin içinde bu,
   listeyi kullanılamaz hale getiriyor. */
.erp-sheet-search input {
    font-size: 16px;
    min-height: 44px;
}

.erp-sheet-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Telefonlarda alt kenardaki sistem çubuğunun altına düşen son satır
       dokunulamaz oluyor; güvenli alan kadar boşluk bırak. */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.erp-sheet-list .erp-lookup-item {
    /* 44px, dokunma hedefi için yaygın kabul gören alt sınır. */
    min-height: 44px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

/* Panel açıkken arkadaki sayfa kaymasın — yoksa kullanıcı listeyi
   kaydırdığını sanırken altındaki formu kaydırıyor. */
body.erp-sheet-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    /* Mobilde × parmakla dokunulacak: 26px yetmez. */
    .erp-lookup-clear {
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    .erp-sheet-clear button { min-height: 40px; }

    /* Alan artık bir metin kutusu değil, dokunulan bir düğme. Yazı
       imlecinin çıkması "buraya yazabilirim" yanılgısı veriyordu. */
    .erp-lookup-input {
        cursor: pointer;
        min-height: 44px;
        font-size: 16px;
    }
    .erp-lookup-input.form-control-sm {
        min-height: 38px;
        font-size: 16px;
    }
}

/* =====================================================================
   MENÜ ARAMASI (20 Eyl 2026)
   Kutu sidebar başlığının hemen altında ve menü kaydırılırken YUKARIDA
   KALIR: 211 maddelik bir ağaçta aşağı inince arama kutusu ekrandan
   çıkarsa ikinci arama için başa dönmek gerekir.
   ===================================================================== */
.sidebar-search {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 14px 0;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
}

.sidebar-search i { color: #94a3b8; font-size: 0.95rem; }

.sidebar-search input {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    color: #fff;
    font-size: 0.9rem;
}

.sidebar-search input::placeholder { color: #94a3b8; }

.sidebar-search button {
    background: transparent;
    border: 0;
    padding: 0;
    line-height: 1;
    cursor: pointer;
}

.sidebar-search button i { font-size: 0.8rem; }

.sidebar-search-empty {
    margin: 10px 14px 0;
    padding: 10px;
    color: #94a3b8;
    font-size: 0.85rem;
    text-align: center;
}

/* Arama sırasında eşleşen madde vurgulanır; kapanmış menü açılır. */
.sidebar-menu .menu-hit > a { background: rgba(79, 70, 229, 0.25); }
