@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; scroll-behavior: smooth; }
@media (min-width: 768px) { html { font-size: 15px; } }

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: #f0f2f5;
    color: #1a1d23;
    margin: 0;
    min-height: 100vh;
}

/* ─── CSS Variables ─── */
:root {
    --primary: #4f46e5;
    --primary-dark: #3730a3;
    --primary-light: #e0e7ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255,255,255,.07);
    --sidebar-active: rgba(79,70,229,.25);
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #e2e8f0;
    --card-radius: 12px;
    --card-shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.04);
    --card-shadow-hover: 0 4px 12px rgba(0,0,0,.1), 0 8px 32px rgba(0,0,0,.07);
    --transition: all .2s cubic-bezier(.4,0,.2,1);
}

/* ─── Topbar ─── */
.topbar {
    height: 60px;
    background: #fff;
    border-bottom: 1px solid #e8eaed;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 1030;
    box-shadow: 0 1px 8px rgba(0,0,0,.05);
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
    width: 240px;
    flex-shrink: 0;
}

.topbar-brand .brand-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: .95rem;
    flex-shrink: 0;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.topbar-btn {
    width: 36px; height: 36px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #64748b;
    background: transparent;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: var(--transition);
    font-size: .9rem;
}
.topbar-btn:hover { background: #f1f5f9; color: var(--primary); border-color: #c7d2fe; }

.sidebar-toggle { display: none; }
@media (max-width: 767px) { .sidebar-toggle { display: flex; } }

/* ─── Sidebar ─── */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    min-height: 100vh;
    position: fixed;
    top: 60px; left: 0;
    overflow-y: auto;
    padding: 1.25rem .75rem;
    transition: transform .25s ease;
    z-index: 1020;
}

.sidebar-section-label {
    color: #475569;
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: .75rem .75rem .35rem;
    display: block;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: var(--sidebar-text);
    padding: .55rem .75rem;
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
}

.sidebar .nav-link .nav-icon {
    width: 20px; height: 20px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.sidebar .nav-link:hover {
    color: var(--sidebar-text-active);
    background: var(--sidebar-hover);
}

.sidebar .nav-link.active {
    color: #a5b4fc;
    background: var(--sidebar-active);
    font-weight: 600;
}

.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: 0; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 60%;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-divider {
    border-top: 1px solid rgba(255,255,255,.06);
    margin: .75rem 0;
}

/* ─── Main Layout ─── */
.main-wrapper {
    margin-left: 240px;
    margin-top: 60px;
    padding: 1.75rem 2rem;
    min-height: calc(100vh - 60px);
    transition: margin-left .25s ease;
}

@media (max-width: 767px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
}

/* ─── Page Header ─── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: .75rem;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0f172a;
    margin: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.page-title .title-icon {
    width: 36px; height: 36px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
}

.page-subtitle {
    color: #64748b;
    font-size: .85rem;
    margin-top: .15rem;
}

/* ─── Cards ─── */
.card {
    background: #fff;
    border: 1px solid #f1f5f9;
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover { box-shadow: var(--card-shadow-hover); }

.card-header {
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    padding: .9rem 1.25rem;
    font-weight: 600;
    font-size: .9rem;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 1.25rem; }
.card-footer { background: #fafbfc; border-top: 1px solid #f1f5f9; padding: .85rem 1.25rem; }

/* ─── Stat Cards ─── */
.stat-card {
    border-radius: var(--card-radius);
    padding: 1.35rem 1.5rem;
    background: #fff;
    border: 1px solid #f1f5f9;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

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

.stat-card::after {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: currentColor;
    opacity: .05;
    transform: translate(20px, -20px);
}

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

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: .25rem;
}

.stat-label {
    font-size: .8rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-trend {
    font-size: .78rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: .2rem;
    margin-top: .5rem;
}

/* ─── Buttons ─── */
.btn {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: .875rem;
    border-radius: 8px;
    padding: .45rem 1rem;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    border: 1.5px solid transparent;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(79,70,229,.25);
}
.btn-primary:hover, .btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 4px 16px rgba(79,70,229,.35);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.btn-outline-primary {
    color: var(--primary);
    border-color: #c7d2fe;
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-outline-secondary {
    color: #475569;
    border-color: #e2e8f0;
    background: #fff;
}
.btn-outline-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #334155;
}

.btn-outline-danger {
    color: var(--danger);
    border-color: #fecaca;
    background: transparent;
}
.btn-outline-danger:hover {
    background: #fef2f2;
    border-color: var(--danger);
}

.btn-lg { padding: .65rem 1.5rem; font-size: .95rem; border-radius: 10px; }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; border-radius: 7px; }

.btn:focus, .btn:active:focus { box-shadow: 0 0 0 3px rgba(79,70,229,.18); }

/* ─── Forms ─── */
.form-control, .form-select {
    font-family: 'Inter', sans-serif;
    font-size: .875rem;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: .5rem .85rem;
    color: #1a1d23;
    background-color: #fff;
    transition: var(--transition);
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
    outline: none;
}

.form-control::placeholder { color: #94a3b8; }

.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: .4rem;
    display: block;
}

.input-group .input-group-text {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    color: #64748b;
    font-size: .875rem;
    border-radius: 0 8px 8px 0;
}

.input-group .form-control { border-radius: 8px 0 0 8px; }

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

.form-check-input:focus { box-shadow: 0 0 0 3px rgba(79,70,229,.15); }

/* ─── Tables ─── */
.table {
    font-size: .875rem;
    color: #334155;
    margin: 0;
}

.table thead th {
    font-size: .72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #64748b;
    background: #f8fafc;
    border-bottom: 1px solid #e8edf2;
    padding: .75rem 1rem;
    white-space: nowrap;
}

.table tbody td {
    padding: .8rem 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

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

.table-hover tbody tr { transition: background .12s; }
.table-hover tbody tr:hover { background: #fafbff; }

/* ─── Badges ─── */
.badge {
    font-size: .72rem;
    font-weight: 600;
    border-radius: 6px;
    padding: .3em .65em;
    letter-spacing: .02em;
}

.badge-durum-Taslak    { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-durum-Gonderildi{ background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.badge-durum-Onaylandi { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }
.badge-durum-Reddedildi{ background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.badge-durum-Iptal     { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.badge-durum-ImzayaHazir { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.badge-durum-Imzalandi   { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }

/* ─── Alerts ─── */
.alert {
    border-radius: 10px;
    font-size: .875rem;
    border: 1.5px solid transparent;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    padding: .85rem 1.1rem;
}

.alert-success {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #065f46;
}

.alert-danger {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.alert-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e40af;
}

/* ─── Breadcrumb ─── */
.breadcrumb {
    font-size: .8rem;
    margin-bottom: .4rem;
    gap: .4rem;
}
.breadcrumb-item + .breadcrumb-item::before { color: #94a3b8; }
.breadcrumb-item a { color: #64748b; text-decoration: none; }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: #1a1d23; font-weight: 500; }

/* ─── Rich Text Editor ─── */
.rich-editor-wrap {
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    transition: var(--transition);
}
.rich-editor-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }

.rich-editor-toolbar {
    background: #f8fafc;
    border-bottom: 1px solid #e8edf2;
    padding: .5rem .75rem;
    display: flex;
    gap: .3rem;
    flex-wrap: wrap;
    align-items: center;
}

.editor-btn {
    width: 30px; height: 30px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: .85rem;
    color: #475569;
    transition: var(--transition);
    padding: 0;
}
.editor-btn:hover { background: var(--primary-light); border-color: #a5b4fc; color: var(--primary); }

.editor-var-btn {
    height: 28px;
    padding: 0 .6rem;
    border: 1px solid #c7d2fe;
    background: var(--primary-light);
    border-radius: 6px;
    cursor: pointer;
    font-size: .75rem;
    font-weight: 600;
    color: var(--primary);
    transition: var(--transition);
}
.editor-var-btn:hover { background: var(--primary); color: #fff; }

.editor-divider { width: 1px; height: 20px; background: #e2e8f0; margin: 0 .2rem; }

.rich-editor-content {
    min-height: 220px;
    padding: 1rem;
    outline: none;
    font-size: .875rem;
    line-height: 1.7;
    color: #1a1d23;
}

/* ─── Teklif Kalemleri (Tablo) ─── */
.kalem-tablo-wrap {
    overflow-x: auto;
}

.kalem-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
}

.kalem-table thead th {
    padding: .4rem .45rem;
    background: #f1f5f9;
    font-size: .68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #64748b;
    white-space: nowrap;
    border-bottom: 1.5px solid #e2e8f0;
}

.kalem-satir td {
    padding: .28rem .4rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
}

.kalem-satir:last-child td {
    border-bottom: none;
}

.kalem-satir:hover td {
    background: #fafbff;
}

.kalem-td-no {
    width: 22px;
    text-align: center;
    color: #94a3b8;
    font-size: .72rem;
    font-weight: 600;
}

.kalem-td-urun {
    min-width: 160px;
}

.kalem-td-aciklama {
    min-width: 110px;
}

.kalem-td-num {
    width: 74px;
}

.kalem-td-birim {
    width: 68px;
}

.kalem-td-kdv {
    width: 66px;
}

.kalem-td-tutar {
    width: 88px;
    text-align: right;
    white-space: nowrap;
}

.kalem-td-sil {
    width: 30px;
    text-align: center;
}

.kalem-table.kdv-gizli .kalem-td-kdv,
.kalem-table.kdv-gizli .kalem-kdv-col {
    display: none;
}

.kalem-satir .form-control,
.kalem-satir .form-select {
    padding: .22rem .38rem;
    font-size: .82rem;
    border-color: #e2e8f0;
    background: transparent;
    transition: border-color .12s, background .12s;
}

.kalem-satir .form-control:hover,
.kalem-satir .form-select:hover {
    border-color: #a5b4fc;
    background: #fff;
}

.kalem-satir .form-control:focus,
.kalem-satir .form-select:focus {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 2px rgba(99,102,241,.12);
}

.kalem-tutar {
    font-size: .88rem;
    font-weight: 700;
    color: #0f172a;
}

.kalem-sil-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: 1px solid #fecaca;
    background: #fff;
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: .72rem;
    padding: 0;
}

.kalem-sil-btn:hover {
    background: #fef2f2;
    border-color: #ef4444;
}

/* Inline ürün arama dropdown */
.kalem-urun-wrap {
    position: relative;
}

.kalem-urun-dropdown {
    background: #fff;
    border: 1px solid #dbe4f0;
    border-radius: 10px;
    box-shadow: 0 16px 40px rgba(15,23,42,.14);
    overflow: hidden;
    max-height: 240px;
    overflow-y: auto;
    min-width: 280px;
}

.kalem-dd-item {
    display: flex;
    align-items: center;
    gap: .45rem;
    padding: .5rem .7rem;
    cursor: pointer;
    transition: background .1s;
}

.kalem-dd-item:hover,
.kalem-dd-item.is-active {
    background: #eef2ff;
}

.kalem-dd-ad {
    flex: 1;
    min-width: 0;
    font-size: .82rem;
    font-weight: 600;
    color: #0f172a;
    word-break: break-word;
}

.kalem-dd-meta {
    font-size: .7rem;
    color: #94a3b8;
    white-space: nowrap;
}

.kalem-dd-fiyat {
    font-size: .76rem;
    font-weight: 700;
    color: #4f46e5;
    white-space: nowrap;
}

.kalem-dd-bos {
    padding: .75rem;
    text-align: center;
    color: #94a3b8;
    font-size: .8rem;
}

.firma-picker {
    position: relative;
}

.firma-picker.is-open .form-control {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.firma-picker-suggestions {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 35;
    display: none;
    background: #fff;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    box-shadow: 0 20px 48px rgba(15,23,42,.14);
    overflow: hidden;
}

.firma-picker-suggestions.show {
    display: block;
}

.firma-picker-option {
    width: 100%;
    display: block;
    padding: .75rem .9rem;
    border: none;
    border-bottom: 1px solid #f1f5f9;
    background: #fff;
    text-align: left;
    cursor: pointer;
}

.firma-picker-option:last-child {
    border-bottom: none;
}

.firma-picker-option:hover,
.firma-picker-option.is-active {
    background: #f5f7ff;
}

.firma-picker-option-title {
    display: block;
    font-size: .84rem;
    font-weight: 700;
    color: #0f172a;
}

.firma-picker-option-meta {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .35rem;
}

.firma-picker-mini,
.firma-picker-chip,
.firma-picker-placeholder {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    font-size: .72rem;
    line-height: 1;
}

.firma-picker-mini,
.firma-picker-chip {
    padding: .24rem .52rem;
    background: #eef2ff;
    color: #4f46e5;
    border: 1px solid #dbe4ff;
}

.firma-picker-placeholder {
    color: #94a3b8;
    padding: .1rem 0;
}

.firma-picker-info {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    margin-top: .5rem;
    min-height: 1rem;
}

.firma-picker-empty {
    padding: .9rem;
    color: #94a3b8;
    font-size: .8rem;
}


/* ─── Özet Kutusu ─── */
.ozet-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .45rem 0;
    font-size: .875rem;
    border-bottom: 1px dashed #f1f5f9;
}
.ozet-row:last-child { border-bottom: none; }
.ozet-row.total {
    font-size: 1.05rem;
    font-weight: 700;
    padding-top: .65rem;
    color: var(--primary);
}
.ozet-label { color: #64748b; }

/* ─── Durum Dropdown ─── */
.durum-select-wrap select {
    border-radius: 8px;
    font-size: .875rem;
    font-weight: 500;
}

/* ─── Detay Yazdırma ─── */
@media print {
    .sidebar, .topbar, .no-print, .btn, form:not(.print-form) { display: none !important; }
    .main-wrapper { margin: 0 !important; padding: 0 !important; }
    .col-lg-4 { display: none !important; }
    .col-lg-8 { width: 100% !important; max-width: 100% !important; flex: 0 0 100% !important; }
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    /* Kalem satırları sayfa kırımında bölünmesin */
    .kalem-satir { break-inside: avoid; page-break-inside: avoid; }
    /* Toplamlar ve notlar bölünmesin */
    .card:last-child { break-inside: avoid; page-break-inside: avoid; }
    /* Sayfa kenar boşlukları */
    @page { margin: 15mm 12mm; size: A4 portrait; }
    /* Her kart arasında boşluk */
    .card { margin-bottom: .5rem !important; }
    body { font-size: 11pt !important; }
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ─── Utilities ─── */
.text-primary { color: var(--primary) !important; }
.bg-primary-soft { background: var(--primary-light); }
.rounded-xl { border-radius: 12px; }
.fw-600 { font-weight: 600; }
.text-xs { font-size: .75rem; }
.text-sm { font-size: .82rem; }
.gap-xs { gap: .35rem; }
.empty-state { text-align: center; padding: 3.5rem 1rem; color: #94a3b8; }
.empty-state i { font-size: 2.5rem; opacity: .35; margin-bottom: .75rem; display: block; }
.empty-state p { font-size: .9rem; margin: 0; }

/* ─── Tooltip / hover info ─── */
code {
    background: #f1f5f9;
    color: var(--primary);
    padding: .15em .45em;
    border-radius: 5px;
    font-size: .82rem;
    font-weight: 600;
}

/* ─── Transitions ─── */
.fade-in { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ─── Kategori Tag Checkbox ─── */
.kategori-tag {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .85rem;
    border-radius: 999px;
    border: 1.5px solid color-mix(in srgb, var(--tag-color) 40%, transparent);
    background: color-mix(in srgb, var(--tag-color) 10%, transparent);
    color: #1e293b;
    font-size: .82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}
.kategori-tag input[type="checkbox"] { display: none; }
.kategori-tag:has(input:checked) {
    background: var(--tag-color);
    border-color: var(--tag-color);
    color: #fff;
}
.kategori-tag:hover { opacity: .85; }

@media (max-width: 767px) {
    .kalem-table { min-width: 620px; }
    .kalem-td-aciklama { display: none; }
}
