/* =====================================================
   STOK TAKİP SİSTEMİ - GLOBAL CSS
   Mobil First, Bootstrap 5 ile uyumlu
   ===================================================== */

:root {
    --renk-ana: #2563eb;
    --renk-ana-koyu: #1d4ed8;
    --renk-yan: #64748b;
    --renk-basari: #16a34a;
    --renk-uyari: #f59e0b;
    --renk-tehlike: #dc2626;
    --renk-bilgi: #0891b2;
    
    --bg-genel: #f8fafc;
    --bg-kart: #ffffff;
    --bg-sidebar: #1e293b;
    --bg-sidebar-hover: #334155;
    --bg-sidebar-aktif: #2563eb;
    
    --metin-ana: #0f172a;
    --metin-yan: #475569;
    --metin-acik: #94a3b8;
    --metin-sidebar: #cbd5e1;
    
    --kenarlik: #e2e8f0;
    --golge-kart: 0 1px 3px rgba(0, 0, 0, 0.05);
    --golge-yumusak: 0 4px 6px rgba(0, 0, 0, 0.05);
    
    --sidebar-w: 260px;
    --header-h: 60px;
    --radius: 8px;
}

/* ===== GENEL ===== */
* { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-genel);
    color: var(--metin-ana);
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
    padding: 0;
}

a { color: var(--renk-ana); text-decoration: none; }
a:hover { color: var(--renk-ana-koyu); text-decoration: underline; }

/* ===== LOGIN SAYFASI ===== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 12px;
    padding: 40px 30px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--metin-ana);
    margin: 10px 0 5px;
}

.login-logo p {
    color: var(--metin-yan);
    font-size: 13px;
    margin: 0;
}

.login-icon {
    width: 60px;
    height: 60px;
    background: var(--renk-ana);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 28px;
}

/* ===== ANA YAPI: HEADER + SIDEBAR + CONTENT ===== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: #fff;
    border-bottom: 1px solid var(--kenarlik);
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 20px;
    box-shadow: var(--golge-kart);
}

.app-header .navbar-brand {
    font-weight: 700;
    color: var(--metin-ana);
    font-size: 18px;
}

.app-header .menu-toggle {
    background: transparent;
    border: 0;
    font-size: 22px;
    color: var(--metin-yan);
    margin-right: 15px;
    cursor: pointer;
}

.app-header .header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-dropdown .dropdown-toggle::after { display: none; }
.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--renk-ana);
    color: #fff;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* ===== SIDEBAR ===== */
.app-sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-sidebar);
    color: var(--metin-sidebar);
    overflow-y: auto;
    z-index: 1020;
    transition: transform 0.3s ease;
}

.app-sidebar .menu {
    list-style: none;
    margin: 0;
    padding: 15px 0;
}

.app-sidebar .menu-baslik {
    padding: 12px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--metin-acik);
    font-weight: 600;
}

.app-sidebar .menu-item a {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--metin-sidebar);
    text-decoration: none;
    transition: background 0.15s;
    font-size: 14px;
}

.app-sidebar .menu-item a i {
    width: 22px;
    margin-right: 10px;
    font-size: 16px;
}

.app-sidebar .menu-item a:hover {
    background: var(--bg-sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.app-sidebar .menu-item.aktif a {
    background: var(--bg-sidebar-aktif);
    color: #fff;
    border-left: 3px solid #fff;
}

/* ===== ANA İÇERİK ALANI ===== */
.app-content {
    margin-top: var(--header-h);
    margin-left: var(--sidebar-w);
    padding: 20px;
    min-height: calc(100vh - var(--header-h));
    transition: margin-left 0.3s ease;
}

.app-footer {
    margin-left: var(--sidebar-w);
    padding: 15px 20px;
    text-align: center;
    color: var(--metin-acik);
    font-size: 12px;
    border-top: 1px solid var(--kenarlik);
    background: #fff;
    transition: margin-left 0.3s ease;
}

/* ===== KARTLAR ===== */
.card {
    background: var(--bg-kart);
    border: 1px solid var(--kenarlik);
    border-radius: var(--radius);
    box-shadow: var(--golge-kart);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--kenarlik);
    padding: 14px 20px;
    font-weight: 600;
}

.card-body { padding: 20px; }

/* ===== SAYFA BAŞLIĞI ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--metin-ana);
}

.page-header .page-actions { display: flex; gap: 8px; }

/* ===== TABLOLAR (Mobil uyumlu) ===== */
.table-wrap {
    background: #fff;
    border: 1px solid var(--kenarlik);
    border-radius: var(--radius);
    overflow: hidden;
}

/* ===== TABLO YAPISI - ASLA TAŞMA YOK ===== */
.table-responsive { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch;
    /* Tablo container'ından taşmasın */
    max-width: 100%;
}

.table { 
    margin: 0; 
    width: 100%; 
    /* min-width yerine: hücreler doğal genişliklerini alsın */
}

.table thead th {
    background: #f8fafc;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--metin-yan);
    border-bottom: 1px solid var(--kenarlik);
    padding: 10px 12px;
    white-space: nowrap;
}

.table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--kenarlik);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f8fafc; }

/* Code/IMEI hücreleri ufalt */
.table code {
    font-size: 11px;
    word-break: break-all;
}

/* Uzun metinleri kısalt */
.table .text-truncate-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== STİCKY İŞLEM SÜTUNU (sağda sabit) ===== */
.table .col-actions {
    position: sticky;
    right: 0;
    background: #fff;
    box-shadow: -8px 0 8px -8px rgba(0, 0, 0, 0.1);
    z-index: 2;
    width: 60px;
    text-align: center;
    padding: 6px;
}

.table thead .col-actions {
    background: #f8fafc;
}

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

/* ===== KOMPAKT İŞLEM BUTONU (3 nokta menüsü) ===== */
.action-menu {
    position: relative;
    display: inline-block;
}

.action-menu-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--metin-yan);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.action-menu-btn:hover {
    background: #e5e7eb;
    color: var(--metin-koyu);
    border-color: var(--kenarlik);
}

.action-menu-btn i {
    font-size: 18px;
    line-height: 1;
}

/* Action menu dropdown - position güçlendirmesi (table-responsive içinden taşırma) */
.action-menu .dropdown-menu {
    min-width: 160px;
    padding: 4px;
    border: 1px solid var(--kenarlik);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    font-size: 13px;
    /* Table içinde de tam görünsün */
    z-index: 1050;
}

/* table-responsive scroll sorununu aşmak için 
   dropdown açılınca parent'ın overflow'u görünür olsun */
.table-responsive:has(.action-menu.show),
.card:has(.action-menu.show) {
    overflow: visible !important;
}

/* Action menu form içinde butonlar tam genişlik */
.action-menu form {
    margin: 0;
}

.action-menu form button.dropdown-item {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    cursor: pointer;
}

.action-menu .dropdown-item {
    padding: 7px 10px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.action-menu .dropdown-item i {
    font-size: 14px;
    width: 16px;
    text-align: center;
}

.action-menu .dropdown-item:hover {
    background: var(--renk-ana-soluk);
}

.action-menu .dropdown-item.text-danger:hover {
    background: #fef2f2;
    color: #dc2626;
}

.action-menu .dropdown-divider {
    margin: 4px 0;
}

/* ===== MOBİLDE TABLO İYİLEŞTİRMESİ ===== */
@media (max-width: 767.98px) {
    .table thead th,
    .table tbody td {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .table code { font-size: 10px; }
    
    /* Mobilde sticky action sütunu daha dar */
    .table .col-actions { width: 48px; }
    
    /* İçindeki badge'leri biraz küçült */
    .table .badge { font-size: 10px; padding: 3px 6px; }
}

/* Çok büyük tablolarda kullanıcıya scroll var ipucu */
.table-responsive::-webkit-scrollbar { height: 8px; }
.table-responsive::-webkit-scrollbar-track { background: #f1f5f9; }
.table-responsive::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.table-responsive::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== ROZETLER ===== */
.badge {
    font-weight: 500;
    padding: 4px 9px;
    border-radius: 6px;
    font-size: 11px;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f1f5f9; color: #475569; }

/* ===== BUTONLAR ===== */
.btn {
    border-radius: 6px;
    font-weight: 500;
    font-size: 13px;
    padding: 7px 14px;
    transition: all 0.15s;
}

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

.btn-primary:hover {
    background-color: var(--renk-ana-koyu);
    border-color: var(--renk-ana-koyu);
}

.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ===== FORM ELEMANLARI ===== */
.form-label { font-weight: 500; margin-bottom: 5px; font-size: 13px; }
.form-control, .form-select { font-size: 14px; padding: 8px 12px; border-radius: 6px; }
.form-control:focus, .form-select:focus {
    border-color: var(--renk-ana);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.required::after { content: ' *'; color: var(--renk-tehlike); }

/* ===== İSTATİSTİK KARTLARI ===== */
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 18px;
    border: 1px solid var(--kenarlik);
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-card .stat-icon.bg-blue   { background: #dbeafe; color: #1e40af; }
.stat-card .stat-icon.bg-green  { background: #dcfce7; color: #166534; }
.stat-card .stat-icon.bg-orange { background: #fef3c7; color: #92400e; }
.stat-card .stat-icon.bg-red    { background: #fee2e2; color: #991b1b; }
.stat-card .stat-icon.bg-purple { background: #ede9fe; color: #5b21b6; }

.stat-card .stat-info h3 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--metin-ana);
}
.stat-card .stat-info p {
    margin: 0;
    font-size: 12px;
    color: var(--metin-yan);
}

/* ===== MOBİL UYUMLULUK ===== */
@media (max-width: 991px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-sidebar.acik {
        transform: translateX(0);
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.3);
    }
    .app-content,
    .app-footer {
        margin-left: 0;
    }
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1010;
    }
    .sidebar-overlay.acik { display: block; }
}

@media (max-width: 575px) {
    .app-content { padding: 15px; }
    .page-header h1 { font-size: 18px; }
    .card-body { padding: 15px; }
    .stat-card { padding: 14px; gap: 10px; }
    .stat-card .stat-icon { width: 40px; height: 40px; font-size: 18px; }
    .stat-card .stat-info h3 { font-size: 18px; }
    .login-card { padding: 30px 20px; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ===== UTILITY ===== */
.text-tutar     { font-weight: 600; color: var(--metin-ana); }
.text-tutar-yes { color: var(--renk-basari); font-weight: 600; }
.text-tutar-no  { color: var(--renk-tehlike); font-weight: 600; }
.cursor-pointer { cursor: pointer; }
