/* ============================================================
   Stok Takip Uygulaması — Ana Stil Dosyası
   Koyu lacivert / beyaz tonlarda sade iş uygulaması tasarımı
   ============================================================ */

/* --- CSS Değişkenleri --- */
:root {
    /* Renk paleti */
    --bg-primary: #0b1426;          /* Ana arka plan — derin lacivert */
    --bg-secondary: #111d35;        /* Kart / panel arka planı */
    --bg-tertiary: #182744;         /* Hover / aktif arka plan */
    --bg-surface: #1e3055;          /* Tablo satır arka planı */

    --text-primary: #e8ecf4;        /* Ana metin */
    --text-secondary: #8fa3c4;      /* İkincil metin */
    --text-muted: #5a7096;          /* Soluk metin */

    --accent: #3b82f6;              /* Vurgu mavi */
    --accent-hover: #2563eb;        /* Vurgu hover */
    --accent-light: rgba(59, 130, 246, 0.12);

    --success: #22c55e;             /* Yeşil — giriş / başarı */
    --danger: #ef4444;              /* Kırmızı — çıkış / hata */
    --warning: #f59e0b;             /* Sarı — uyarı / bekliyor */

    --border: #253553;              /* Kenarlık rengi */
    --border-light: #2d4268;        /* Açık kenarlık */

    --radius: 10px;                 /* Köşe yuvarlaklığı */
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);

    --transition: 0.2s ease;
}

/* --- Reset & Temel --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--accent-hover);
}

/* --- Üst Menü (Navbar) --- */
.navbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    display: flex;
    align-items: center;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-right: 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

.navbar-brand .brand-icon {
    font-size: 1.5rem;
}

.navbar-nav {
    list-style: none;
    display: flex;
    gap: 0.25rem;
    align-items: center;
}

.navbar-nav a {
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.navbar-nav a:hover,
.navbar-nav a.active {
    color: var(--text-primary);
    background: var(--accent-light);
}

.navbar-nav a.active {
    color: var(--accent);
}

/* --- Ana İçerik --- */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem;
}

/* --- Sayfa Başlığı --- */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.page-header p {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-size: 0.95rem;
}

/* --- İstatistik Kartları --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    border-radius: var(--radius) var(--radius) 0 0;
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.stat-card .stat-icon {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    font-size: 1.75rem;
    opacity: 0.15;
}

/* Kart renk varyasyonları */
.stat-card.accent::before   { background: var(--accent); opacity: 1; }
.stat-card.success::before  { background: var(--success); opacity: 1; }
.stat-card.warning::before  { background: var(--warning); opacity: 1; }
.stat-card.danger::before   { background: var(--danger); opacity: 1; }

/* --- Panel (Kart) --- */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-body {
    padding: 1.5rem;
}

/* --- Tablolar --- */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table thead th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.85rem 1rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

table tbody tr {
    transition: background var(--transition);
}

table tbody tr:hover {
    background: var(--accent-light);
}

table tbody tr:last-child td {
    border-bottom: none;
}

/* --- Hücre Varyasyonları --- */
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-muted); }
.text-accent  { color: var(--accent); }

.text-right    { text-align: right; }
.text-center   { text-align: center; }

.font-mono {
    font-family: 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
}

/* --- Badge (Etiket) --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.badge-success {
    background: rgba(34, 197, 94, 0.12);
    color: var(--success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.12);
    color: var(--danger);
}

.badge-warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.12);
    color: var(--accent);
}

/* --- Butonlar --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    line-height: 1.4;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-light);
}
.btn-secondary:hover {
    background: var(--bg-surface);
    border-color: var(--accent);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover {
    background: #dc2626;
    transform: translateY(-1px);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
}

/* --- Form Elemanları --- */
input[type="text"],
input[type="number"],
input[type="search"],
input[type="date"],
input[list],
select,
textarea {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 0.55rem 0.85rem;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all var(--transition);
    width: 100%;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input::placeholder {
    color: var(--text-muted);
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
    display: block;
}

/* --- Boş Durum Mesajı --- */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.95rem;
}

/* --- Footer --- */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 3rem;
}

/* --- Yardımcı sınıflar --- */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* --- Animasyonlar --- */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.animate-in {
    animation: fadeIn 0.4s ease forwards;
}

/* Her kart sırayla animasyonla gelsin */
.stats-grid .stat-card:nth-child(1) { animation: fadeIn 0.4s ease 0.05s both; }
.stats-grid .stat-card:nth-child(2) { animation: fadeIn 0.4s ease 0.10s both; }
.stats-grid .stat-card:nth-child(3) { animation: fadeIn 0.4s ease 0.15s both; }
.stats-grid .stat-card:nth-child(4) { animation: fadeIn 0.4s ease 0.20s both; }

.panel {
    animation: fadeIn 0.4s ease 0.25s both;
}

/* --- Scrollbar özelleştirme --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Form Grid Düzeni --- */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    align-items: start;
}

.form-group {
    display: flex;
    flex-direction: column;
}

/* --- Checkbox Stili --- */
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-primary);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* --- Dosya Input Stili --- */
input[type="file"] {
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
    color: var(--text-primary);
    padding: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition);
}

input[type="file"]:hover {
    border-color: var(--accent);
}

/* --- Ürün Tablosu Tıklanabilir Satır --- */
table tbody tr[onclick] {
    cursor: pointer;
}

table tbody tr[onclick]:hover {
    background: var(--accent-light);
}

/* --- Badge Ek Varyasyonlar --- */
.badge-secondary {
    background: rgba(138, 163, 196, 0.12);
    color: var(--text-secondary);
}

/* --- Modal / Diyalog --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.2s ease;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    padding: 1.5rem 2rem;
    width: 100%;
    max-width: 450px;
    animation: fadeIn 0.25s ease;
}

.modal-card h3 {
    font-size: 1.15rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

/* --- Buton Warning --- */
.btn-warning {
    background: var(--warning);
    color: #1a1a2e;
    border-color: var(--warning);
    font-weight: 700;
}
.btn-warning:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.btn-success:hover {
    background: #16a34a;
    transform: translateY(-1px);
}


/* --- Kanal Kutu (Dashboard) --- */
.kanal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}
.kanal-kutu {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.kanal-kutu:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}
.kanal-kutu-ikon {
    font-size: 1.5rem;
}
.kanal-kutu-detay {
    display: flex;
    flex-direction: column;
}
.kanal-kutu-isim {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 600;
}
.kanal-kutu-deger {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* --- Responsive Settings --- */
.navbar-toggler {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
}

@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px;
        height: auto;
    }
    
    .navbar-brand {
        margin-bottom: 10px;
    }

    .navbar-toggler {
        display: block;
        position: absolute;
        right: 15px;
        top: 15px;
    }

    .navbar-nav {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 5px;
    }

    .navbar-nav.active {
        display: flex;
    }

    .navbar-nav li {
        width: 100%;
    }

    .navbar-nav a {
        display: block;
        padding: 10px;
        border-radius: 6px;
    }
    
    /* Make all tables scrollable on mobile */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    /* Touch-friendly forms */
    input[type="text"], input[type="number"], input[type="date"], select, .btn, .form-control {
        width: 100%;
        min-height: 44px;
        box-sizing: border-box;
    }
    
    .select2-container .select2-selection--single { height: 44px !important; }
    .select2-container--default .select2-selection--single .select2-selection__rendered { line-height: 44px !important; }
    .select2-container--default .select2-selection--single .select2-selection__arrow { height: 42px !important; }
    
    /* Stack grid columns */
    .row {
        display: flex;
        flex-direction: column;
        width: 100%;
    }
    .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-10, .col-md-12 {
        width: 100%;
        margin-bottom: 10px;
    }

    /* Card style tables for Perakende Sepet */
    table.card-style-mobile {
        border: 0;
    }
    table.card-style-mobile thead {
        display: none;
    }
    table.card-style-mobile tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 15px;
        background: var(--bg-primary);
        padding: 5px;
    }
    table.card-style-mobile td {
        display: block;
        text-align: right;
        border-bottom: 1px solid var(--border-light);
        min-height: 44px;
        position: relative;
        padding-left: 50%;
    }
    table.card-style-mobile td:last-child {
        border-bottom: 0;
    }
    table.card-style-mobile td::before {
        content: attr(data-label);
        position: absolute;
        left: 10px;
        width: 45%;
        text-align: left;
        font-weight: bold;
        color: var(--text-secondary);
    }
}

@media (max-width: 768px) {
    /* Prevent buttons in card-style tables from expanding to 100% width and overflowing */
    .card-style-mobile td .btn {
        width: auto !important;
        display: inline-block !important;
        min-height: auto !important;
        padding: 8px 12px !important;
    }
}

@media (max-width: 768px) {
    /* Include search input in touch-friendly rule */
    input[type="search"] {
        width: 100%;
        min-height: 44px;
        box-sizing: border-box;
        margin-bottom: 10px;
    }
    
    /* Make checkboxes touch-friendly */
    .checkbox-label {
        display: flex;
        align-items: center;
        min-height: 44px;
        padding: 5px 0;
        width: 100%;
    }
    
    /* Sticky first column for large tables */
    .table-wrapper table th:first-child,
    .table-wrapper table td:first-child,
    .table-responsive table th:first-child,
    .table-responsive table td:first-child {
        position: sticky;
        left: 0;
        background: #fff; /* Fallback for var(--bg-primary) if needed, but var is better */
        background: var(--bg-primary, #fff);
        z-index: 2;
        border-right: 2px solid var(--border);
    }
    
    .table-wrapper table thead th:first-child,
    .table-responsive table thead th:first-child {
        z-index: 3;
        background: var(--bg-tertiary, #f8f9fa);
    }
}
