/* =========================================================
   MG Forwarding — Uygulama teması
   Renkler mg-forwarding.com kurumsal kimliğinden alınmıştır.
   ========================================================= */

:root {
    --mg-primary: #214290;
    --mg-primary-dark: #12307a;
    --mg-primary-rgb: 33, 66, 144;
    --mg-navy: #1c2840;
    --mg-navy-2: #11285d;
    --mg-accent: #156fd6;
    --mg-gray: #676767;
    --mg-bg: #f5f7fa;
    --mg-border: #e2e8f0;
    --mg-yellow: #f4c300;
    --mg-green: #0ea52c;
    --mg-sidebar-w: 260px;

    --bs-primary: var(--mg-primary);
    --bs-primary-rgb: var(--mg-primary-rgb);
    --bs-link-color: var(--mg-primary);
    --bs-link-color-rgb: var(--mg-primary-rgb);
    --bs-link-hover-color: var(--mg-accent);
    --bs-body-font-family: 'Inter', 'Segoe UI', Tahoma, sans-serif;
    --bs-body-font-size: .9rem;
    --bs-body-color: #1f2937;
    --bs-border-color: var(--mg-border);
    --bs-success: var(--mg-green);
    --bs-success-rgb: 14, 165, 44;
}

body {
    background: var(--mg-bg);
    min-height: 100vh;
}

/* ---------- Butonlar ---------- */
.btn {
    border-radius: .5rem;
    font-weight: 500;
}
.btn-primary {
    --bs-btn-bg: var(--mg-primary);
    --bs-btn-border-color: var(--mg-primary);
    --bs-btn-hover-bg: var(--mg-primary-dark);
    --bs-btn-hover-border-color: var(--mg-primary-dark);
    --bs-btn-active-bg: var(--mg-navy-2);
    --bs-btn-active-border-color: var(--mg-navy-2);
    --bs-btn-disabled-bg: var(--mg-primary);
    --bs-btn-disabled-border-color: var(--mg-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--mg-primary);
    --bs-btn-border-color: var(--mg-primary);
    --bs-btn-hover-bg: var(--mg-primary);
    --bs-btn-hover-border-color: var(--mg-primary);
    --bs-btn-active-bg: var(--mg-primary-dark);
    --bs-btn-active-border-color: var(--mg-primary-dark);
}
.btn-accent {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--mg-accent);
    --bs-btn-border-color: var(--mg-accent);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #0f5bb3;
    --bs-btn-hover-border-color: #0f5bb3;
}
.btn-icon {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.text-primary { color: var(--mg-primary) !important; }
.bg-primary { background-color: var(--mg-primary) !important; }
.text-navy { color: var(--mg-navy) !important; }
.bg-navy { background-color: var(--mg-navy) !important; }
.text-accent { color: var(--mg-accent) !important; }

.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: rgba(var(--mg-primary-rgb), .5);
    box-shadow: 0 0 0 .2rem rgba(var(--mg-primary-rgb), .15);
}
.form-check-input:checked {
    background-color: var(--mg-primary);
    border-color: var(--mg-primary);
}
.form-label {
    font-weight: 500;
    font-size: .82rem;
    color: #4b5563;
    margin-bottom: .3rem;
}
.form-label .req { color: #dc3545; }

/* ---------- Kenar menü ---------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--mg-sidebar-w);
    background: linear-gradient(180deg, var(--mg-navy) 0%, var(--mg-navy-2) 100%);
    color: #c7d2fe;
    display: flex;
    flex-direction: column;
    z-index: 1040;
    transition: transform .25s ease;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand img { max-height: 46px; max-width: 190px; }
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: .75rem .75rem 1.5rem;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .15); border-radius: 3px; }
.sidebar-heading {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255, 255, 255, .4);
    padding: 1rem .75rem .4rem;
    font-weight: 600;
}
.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: 0;
    text-align: left;
    cursor: pointer;
    border-radius: .5rem;
}
.sidebar-toggle:hover { color: rgba(255, 255, 255, .75); }
.sidebar-toggle i { font-size: .8rem; transition: transform .2s; }
.sidebar-toggle.collapsed i { transform: rotate(-90deg); }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .75rem;
    color: rgba(255, 255, 255, .78);
    border-radius: .5rem;
    text-decoration: none;
    font-size: .875rem;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.sidebar-link i { font-size: 1.05rem; width: 1.25rem; text-align: center; opacity: .85; }
.sidebar-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.sidebar-link.active {
    background: var(--mg-accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(21, 111, 214, .35);
}
.sidebar-link.active i { opacity: 1; }
.sidebar-footer {
    padding: .75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .72rem;
    color: rgba(255, 255, 255, .4);
    text-align: center;
}
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: 1035;
}

/* ---------- Üst bar & içerik ---------- */
.main {
    margin-left: var(--mg-sidebar-w);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    height: 64px;
    background: #fff;
    border-bottom: 1px solid var(--mg-border);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.5rem;
}
.topbar-search { max-width: 380px; flex: 1; }
.topbar-search .form-control {
    background: var(--mg-bg);
    border-color: transparent;
    padding-left: 2.25rem;
    border-radius: .6rem;
}
.topbar-search .bi-search {
    position: absolute;
    left: .8rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--mg-primary);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .8rem;
    flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: .7rem; }
.content {
    padding: 1.5rem;
    flex: 1;
}

/* ---------- Sayfa başlığı ---------- */
.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.25rem;
}
.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--mg-navy);
    margin: 0;
}
.breadcrumb { font-size: .78rem; margin: 0; }
.breadcrumb a { text-decoration: none; color: var(--mg-gray); }

/* ---------- Kartlar ---------- */
.card {
    border: 1px solid var(--mg-border);
    border-radius: .85rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.card-header {
    background: #fff;
    border-bottom: 1px solid var(--mg-border);
    padding: .9rem 1.15rem;
    border-radius: .85rem .85rem 0 0 !important;
}
.card-title {
    font-size: .95rem;
    font-weight: 600;
    color: var(--mg-navy);
    margin: 0;
}
.card-title i { color: var(--mg-primary); }

.stat-card {
    padding: 1.15rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    height: 100%;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
}
.stat-icon.blue { background: rgba(var(--mg-primary-rgb), .1); color: var(--mg-primary); }
.stat-icon.sky { background: rgba(21, 111, 214, .1); color: var(--mg-accent); }
.stat-icon.green { background: rgba(14, 165, 44, .1); color: var(--mg-green); }
.stat-icon.yellow { background: rgba(244, 195, 0, .15); color: #b58f00; }
.stat-icon.red { background: rgba(220, 53, 69, .1); color: #dc3545; }
.stat-label { font-size: .78rem; color: var(--mg-gray); margin-bottom: .1rem; }
.stat-value { font-size: 1.35rem; font-weight: 700; color: var(--mg-navy); line-height: 1.2; }

/* ---------- Tablolar ---------- */
.table { --bs-table-hover-bg: rgba(var(--mg-primary-rgb), .03); margin-bottom: 0; }
.table > thead th {
    background: #f8fafc;
    font-size: .74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #64748b;
    border-bottom-width: 1px;
    white-space: nowrap;
    padding-top: .7rem;
    padding-bottom: .7rem;
}
.table td { vertical-align: middle; }
.table-sm td, .table-sm th { padding: .45rem .6rem; }
.table tfoot td, .table tfoot th { background: #f8fafc; font-weight: 600; }
.card > .table-responsive > .table tr:last-child td { border-bottom: 0; }
.row-link { cursor: pointer; }

.badge { font-weight: 500; padding: .38em .65em; border-radius: .4rem; }
.badge-soft-primary { background: rgba(var(--mg-primary-rgb), .1); color: var(--mg-primary); }
.badge-soft-success { background: rgba(14, 165, 44, .1); color: #0a7d21; }
.badge-soft-danger { background: rgba(220, 53, 69, .1); color: #b02a37; }
.badge-soft-warning { background: rgba(244, 195, 0, .18); color: #8a6d00; }
.badge-soft-secondary { background: #eef2f7; color: #475569; }
.badge-soft-info { background: rgba(13, 202, 240, .12); color: #087990; }
.badge-soft-dark { background: rgba(28, 40, 64, .1); color: var(--mg-navy); }

.amount-pos { color: var(--mg-green); font-weight: 600; }
.amount-neg { color: #dc3545; font-weight: 600; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Sekmeler ---------- */
.nav-tabs-mg {
    border-bottom: 1px solid var(--mg-border);
    gap: .25rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
}
.nav-tabs-mg .nav-link {
    border: 0;
    border-bottom: 2px solid transparent;
    color: var(--mg-gray);
    font-weight: 500;
    padding: .75rem 1rem;
    white-space: nowrap;
}
.nav-tabs-mg .nav-link:hover { color: var(--mg-primary); }
.nav-tabs-mg .nav-link.active {
    color: var(--mg-primary);
    border-bottom-color: var(--mg-primary);
    background: transparent;
}
.nav-tabs-mg .nav-link .badge { font-size: .68rem; }

/* Uyarı balonu (ör. faturalama seçimi) */
.popover-warn { --bs-popover-border-color: #f2c48d; --bs-popover-bg: #fff8ee; --bs-popover-body-color: #8a4b0f; --bs-popover-max-width: 300px; font-size: .82rem; box-shadow: 0 6px 18px rgba(16, 24, 40, .12); }
.popover-warn .popover-body { padding: .55rem .8rem; font-weight: 500; }

/* ---------- Teklif toplamları ---------- */
.quote-totals { max-width: 380px; }
.quote-totals .qt-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .3rem 0; font-size: .88rem; }
.quote-totals .qt-row > span:first-child, .quote-totals .qt-row > label { color: var(--mg-gray); }
.quote-totals .qt-currency { padding-bottom: .55rem; margin-bottom: .2rem; border-bottom: 1px dashed var(--mg-border); }
.quote-totals .qt-currency label { margin: 0; font-weight: 500; }
.quote-totals .qt-currency .form-select { width: 100px; }
.quote-totals .qt-grand { border-top: 1px solid var(--mg-border); margin-top: .2rem; padding-top: .5rem; font-weight: 700; font-size: .98rem; }
.quote-totals .qt-grand > span:first-child { color: var(--mg-navy); }
.quote-totals .qt-profit { margin-top: .6rem; padding: .35rem .75rem; border-radius: .6rem; background: #f8fafc; border: 1px solid var(--mg-border); }
.quote-totals .qt-rates:empty { display: none; }
.quote-totals .qt-rates { padding-top: .35rem; }

/* ---------- İş dosyası başlığı ---------- */
.job-hero {
    background: linear-gradient(120deg, var(--mg-navy) 0%, var(--mg-primary) 100%);
    color: #fff;
    border-radius: .85rem;
    padding: 1.25rem 1.5rem;
    position: relative;
    overflow: hidden;
}
.job-hero::after {
    content: "";
    position: absolute;
    right: -40px;
    top: -40px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .05);
}
.job-hero .file-no { font-size: 1.5rem; font-weight: 700; letter-spacing: .02em; }
.job-hero .meta { color: rgba(255, 255, 255, .75); font-size: .85rem; }
.job-hero .route {
    display: flex;
    align-items: center;
    gap: .75rem;
    font-weight: 600;
    font-size: 1rem;
}
.job-hero .route .line {
    flex: 1;
    min-width: 30px;
    border-top: 2px dashed rgba(255, 255, 255, .4);
    position: relative;
}
.route-chain { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; font-weight: 600; font-size: .95rem; }
.route-chain .stop { min-width: 0; }
.route-chain .hop { display: flex; align-items: center; gap: .35rem; color: rgba(255, 255, 255, .85); }
.route-chain .hop::before, .route-chain .hop::after { content: ""; width: 14px; border-top: 2px dashed rgba(255, 255, 255, .4); }
.hero-stat { font-size: .72rem; color: rgba(255, 255, 255, .65); text-transform: uppercase; letter-spacing: .05em; }
.hero-stat-value { font-weight: 600; font-size: .95rem; }

.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem 1.25rem; }
.dl-grid dt { font-size: .72rem; color: var(--mg-gray); font-weight: 500; text-transform: uppercase; letter-spacing: .03em; margin-bottom: .15rem; }
.dl-grid dd { margin: 0; font-weight: 500; color: #111827; word-break: break-word; }

/* Dosya durumu: üst kartta açılır liste */
.status-picker { position: relative; display: inline-flex; align-items: center; }
.status-picker > i { position: absolute; left: .7rem; font-size: .55rem; pointer-events: none; z-index: 1; }
.status-picker .form-select {
    width: auto; min-width: 150px; padding: .3rem 2rem .3rem 1.6rem; border-radius: 999px; border: 0;
    font-weight: 600; font-size: .8rem; color: var(--mg-navy); background-color: #fff; cursor: pointer;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .15);
}
.status-picker .form-select:focus { box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .45); }
.status-picker.is-saving { opacity: .6; pointer-events: none; }

/* Zaman çizelgesi */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: flex; gap: .75rem; padding-bottom: 1rem; position: relative; }
.timeline li:not(:last-child)::before {
    content: "";
    position: absolute;
    left: 15px;
    top: 32px;
    bottom: 0;
    width: 2px;
    background: var(--mg-border);
}
.timeline .t-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(var(--mg-primary-rgb), .1);
    color: var(--mg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ---------- Giriş ekranı ---------- */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-side {
    flex: 1.1;
    background: linear-gradient(140deg, var(--mg-navy) 0%, var(--mg-navy-2) 45%, var(--mg-primary) 100%);
    color: #fff;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.auth-side::before, .auth-side::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, .08);
}
.auth-side::before { width: 520px; height: 520px; right: -160px; bottom: -160px; }
.auth-side::after { width: 340px; height: 340px; right: -70px; bottom: -70px; }
.auth-side h1 { font-weight: 700; font-size: 2.1rem; line-height: 1.25; max-width: 460px; }
.auth-modes { display: flex; gap: .75rem; flex-wrap: wrap; }
.auth-modes span {
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .12);
    padding: .45rem .9rem;
    border-radius: 2rem;
    font-size: .85rem;
}
.auth-form {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #fff;
}
.auth-form .inner { width: 100%; max-width: 380px; }
.auth-form .form-control { padding: .7rem .9rem; border-radius: .6rem; }

/* ---------- Diğer ---------- */
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--mg-gray); }
.empty-state i { font-size: 2.5rem; color: #cbd5e1; display: block; margin-bottom: .5rem; }
.filter-bar { background: #fff; border: 1px solid var(--mg-border); border-radius: .85rem; padding: .9rem; margin-bottom: 1rem; }
.pagination { --bs-pagination-active-bg: var(--mg-primary); --bs-pagination-active-border-color: var(--mg-primary); --bs-pagination-color: var(--mg-primary); margin: 0; }
.dropdown-menu { border-color: var(--mg-border); box-shadow: 0 10px 30px rgba(16, 24, 40, .1); border-radius: .6rem; }
.dropdown-item { font-size: .875rem; padding: .45rem 1rem; }
.dropdown-item i { width: 1.25rem; color: var(--mg-gray); }
.ts-wrapper.form-select, .ts-wrapper.form-control { padding: 0; }
.ts-control { border-radius: .375rem; min-height: 38px; }
.ts-wrapper.form-select-sm .ts-control { min-height: 31px; font-size: .875rem; }
.alert { border-radius: .65rem; }

/* Yazdıkça öneren kutu (mgCombo) */
.mg-combo { position: relative; }
.mg-combo.is-linked .form-control { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23214290'%3e%3cpath d='M6.354 5.5H4a3 3 0 0 0 0 6h3a3 3 0 0 0 2.83-4H9c-.086 0-.17.01-.25.031A2 2 0 0 1 7 10.5H4a2 2 0 1 1 0-4h1.535c.218-.376.495-.714.82-1z'/%3e%3cpath d='M9 5.5a3 3 0 0 0-2.83 4h1.098A2 2 0 0 1 9 6.5h3a2 2 0 1 1 0 4h-1.535a4 4 0 0 1-.82 1H12a3 3 0 1 0 0-6z'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right .6rem center; background-size: 14px; padding-right: 2rem; }
.mg-combo-menu { display: none; position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 1060; background: #fff; border: 1px solid var(--mg-border); border-radius: .5rem; box-shadow: 0 10px 28px rgba(16, 24, 40, .14); max-height: 300px; overflow-y: auto; padding: .25rem; }
.mg-combo-menu.show { display: block; }
.mg-combo-item { display: flex; justify-content: space-between; gap: .75rem; padding: .45rem .6rem; border-radius: .35rem; cursor: pointer; font-size: .86rem; }
.mg-combo-item .t { font-weight: 500; color: #111827; min-width: 0; }
.mg-combo-item .s { color: var(--mg-gray); font-size: .76rem; white-space: nowrap; }
.mg-combo-item:hover { background: #f1f5f9; }
.mg-combo-item.active { background: var(--mg-primary); }
.mg-combo-item.active .t, .mg-combo-item.active .s { color: #fff; }

.charge-row input, .charge-row select { min-width: 80px; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--mg-primary); font-weight: 600; margin: .5rem 0 .9rem; padding-bottom: .4rem; border-bottom: 1px solid var(--mg-border); }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .main { margin-left: 0; }
    .topbar { padding: 0 1rem; }
    .content { padding: 1rem; }
    .auth-side { display: none; }
}

@media (max-width: 575.98px) {
    .page-title { font-size: 1.15rem; }
    .stat-value { font-size: 1.1rem; }
    .job-hero { padding: 1rem; }
    .job-hero .file-no { font-size: 1.2rem; }
}

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main { margin-left: 0; }
    body { background: #fff; }
}

/* ---------- Belge önizleme ---------- */
.doc-preview-body { height: 78vh; background: #eef1f6; display: flex; flex-direction: column; }
@media (max-width: 991.98px) { .doc-preview-body { height: auto; flex: 1 1 auto; } } /* tam ekran: kalan alanı doldurur */
.doc-preview-body iframe { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; display: block; background: #fff; }
.doc-preview-image { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; overflow: auto; padding: 1rem; }
.doc-preview-image img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 4px 20px rgba(16, 24, 40, .15); background: #fff; }
.doc-preview-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--mg-gray); padding: 2rem; text-align: center; }

/* ---------- Firma Ayarları: logolar ---------- */
.logo-slot { border: 1px solid var(--mg-border); border-radius: .75rem; padding: .75rem; background: #fff; }
.logo-preview { height: 110px; border-radius: .5rem; display: flex; align-items: center; justify-content: center; padding: 1rem; background: #fff; border: 1px dashed var(--mg-border); }
.logo-preview.is-dark { background: linear-gradient(135deg, #1c2840, #214290); border-color: transparent; }
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-preview.is-icon img { width: 48px; height: 48px; }

/* Ülke / il / ilçe tanımları: üç liste yan yana, kendi içinde kayar */
.geo-scroll { max-height: calc(100vh - 260px); min-height: 320px; overflow-y: auto; }
