/* =====================================================
   CRM Pro - Ana Stil Dosyası
   ===================================================== */

:root {
    --sidebar-width: 250px;
    --sidebar-collapsed: 60px;
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --secondary: #6c757d;
    --success: #2ec4b6;
    --info: #4cc9f0;
    --warning: #ff9f1c;
    --danger: #e63946;
    --dark: #1d2939;
    --light: #f8f9fa;
    --body-bg: #f0f2f5;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--body-bg);
    font-size: 0.875rem;
    color: #344054;
}

/* ===================== SIDEBAR ===================== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.4);
}

.sidebar-nav .nav-link {
    border-radius: 6px;
    margin: 1px 8px;
    transition: all 0.2s ease;
    font-size: 0.875rem;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
    background-color: rgba(255,255,255,0.1);
    color: #fff !important;
}

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

.main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

/* Sidebar Collapsed */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sidebar .sidebar-text {
    display: none;
}

body.sidebar-collapsed .main-content {
    margin-left: var(--sidebar-collapsed);
}

body.sidebar-collapsed .sidebar-header a span {
    display: none;
}

/* ===================== NAVBAR ===================== */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
}

/* ===================== CARDS ===================== */
.stat-card {
    border: none;
    border-radius: 12px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

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

.card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e9ecef;
    border-radius: 12px 12px 0 0 !important;
    padding: 1rem 1.25rem;
}

/* ===================== TABLES ===================== */
.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #667085;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    padding: 0.75rem;
}

.table-hover tbody tr:hover {
    background-color: rgba(67, 97, 238, 0.04);
}

/* DataTables overrides */
.dataTables_wrapper .dataTables_filter input {
    border-radius: 8px;
    border: 1px solid #d0d5dd;
    padding: 0.4rem 0.8rem;
}

.dataTables_wrapper .dataTables_length select {
    border-radius: 8px;
    border: 1px solid #d0d5dd;
}

/* ===================== FORMS ===================== */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #d0d5dd;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67,97,238,0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.8125rem;
    color: #344054;
    margin-bottom: 0.375rem;
}

/* ===================== BUTTONS ===================== */
.btn {
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
}

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

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

/* ===================== BADGES ===================== */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

/* ===================== LOGIN PAGE ===================== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, #7209b7 100%);
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

/* ===================== PAGINATION ===================== */
.page-link {
    border-radius: 8px !important;
    margin: 0 2px;
    color: var(--primary);
    border: 1px solid #d0d5dd;
}

.page-item.active .page-link {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ===================== KANBAN ===================== */
.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    min-width: 280px;
    max-width: 320px;
    flex-shrink: 0;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 1rem;
}

.kanban-column-header {
    font-weight: 600;
    font-size: 0.875rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid;
    margin-bottom: 0.75rem;
}

.kanban-card {
    background: #fff;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    cursor: grab;
    transition: box-shadow 0.2s;
}

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

.kanban-card.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

/* ===================== SELECT2 ===================== */
.select2-container--bootstrap-5 .select2-selection {
    border-radius: 8px;
    border: 1px solid #d0d5dd;
    min-height: 38px;
}

/* ===================== MISC ===================== */
.avatar-sm {
    font-size: 0.75rem;
    font-weight: 600;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

/* Activity Timeline */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e9ecef;
}

.timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -1.625rem;
    top: 0.25rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
}

/* Quick Actions */
.quick-action-btn {
    border: 2px dashed #d0d5dd;
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    transition: all 0.2s;
    color: #667085;
    text-decoration: none;
    display: block;
}

.quick-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(67,97,238,0.04);
}

/* Print */
@media print {
    .sidebar, .navbar, .no-print {
        display: none !important;
    }
    .main-content {
        margin-left: 0 !important;
    }
}

/* Mobile */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    body.sidebar-collapsed .main-content {
        margin-left: 0;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #c1c7cd;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #98a2b3;
}

/* =====================================================
   RESPONSIVE - Mobile & Tablet
   ===================================================== */

/* Sidebar Backdrop (mobil) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1039;
}

body.sidebar-open .sidebar-backdrop {
    display: block;
}

body.sidebar-open {
    overflow: hidden;
}

/* Tablo yatay kaydırma */
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

.table th {
    white-space: nowrap;
}

/* Dokunmatik cihazlar — buton/form minimum boyut */
@media (pointer: coarse) {
    .btn-group-sm .btn {
        min-width: 36px;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .page-link {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .form-control, .form-select {
        min-height: 42px;
    }

    .form-control-sm, .form-select-sm {
        min-height: 38px;
    }
}

/* ============ TELEFON (max-width: 575.98px) ============ */
@media (max-width: 575.98px) {

    /* ★ SAYFA TAŞMA ÖNLEMESİ — kök neden düzeltmesi */
    .main-content {
        overflow-x: hidden;
        max-width: 100vw;
    }

    .main-content .p-4 {
        padding: 0.5rem !important;
        overflow-x: hidden;
    }

    /* Row taşma düzeltme (Bootstrap gutter kayması) */
    .row {
        margin-left: 0;
        margin-right: 0;
    }
    .row > [class*="col-"] {
        padding-left: 6px;
        padding-right: 6px;
    }
    .row.g-3 {
        --bs-gutter-x: 0.5rem;
        --bs-gutter-y: 0.5rem;
    }

    /* Başlık + buton satırı dikeye dönsün */
    .d-flex.justify-content-between.align-items-start.mb-4,
    .d-flex.justify-content-between.align-items-center.mb-4 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .d-flex.justify-content-between.align-items-center.mb-4 .btn,
    .d-flex.justify-content-between.align-items-center.mb-4 .btn-group {
        width: 100%;
        text-align: center;
    }

    /* ★ İSTATİSTİK KARTLARI — taşma önleme */
    .card-body .fs-4,
    .card-body .fs-5,
    .card-body .fs-md-4 {
        font-size: 0.9rem !important;
        word-break: break-all;
        overflow-wrap: anywhere;
    }

    .card-body.text-center {
        padding: 0.5rem 0.25rem !important;
    }

    .card-body.text-center small {
        font-size: 0.65rem;
    }

    .stat-card .stat-icon,
    .stat-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
        flex-shrink: 0;
    }

    /* ★ TÜM TABLOLAR — ultra compact mobil */
    .table {
        font-size: 0.72rem;
        width: 100% !important;
        table-layout: fixed;
    }

    .table td,
    .table th {
        padding: 0.3rem 0.2rem;
        vertical-align: middle;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .table th {
        font-size: 0.68rem;
        white-space: nowrap;
    }

    /* Tablo hücre sarma */
    .table td {
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .table .text-nowrap {
        white-space: normal !important;
        word-break: break-word;
    }

    /* Badge küçült */
    .table .badge {
        font-size: 0.6rem;
        padding: 0.2rem 0.35rem;
    }

    /* Mobil dropdown menü */
    .dropdown .btn-outline-secondary.dropdown-toggle {
        padding: 0.15rem 0.35rem;
        font-size: 0.72rem;
    }

    /* ★ DataTables sarma düzeltme */
    .dataTables_wrapper {
        overflow-x: hidden;
    }

    .dataTables_wrapper .dataTables_info,
    .dataTables_wrapper .dataTables_paginate {
        text-align: center !important;
        float: none !important;
        padding-top: 0.5rem;
    }

    .dataTables_wrapper .dataTables_paginate .pagination {
        justify-content: center;
        flex-wrap: wrap;
        gap: 2px;
    }

    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        text-align: center !important;
        float: none !important;
        margin-bottom: 0.5rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 0.25rem;
    }

    .dataTables_wrapper .dataTables_info {
        font-size: 0.65rem;
    }

    .dataTables_wrapper .dataTables_paginate .paginate_button {
        padding: 0.25rem 0.4rem !important;
        font-size: 0.7rem;
    }

    /* Tablo aksiyon butonları */
    .table .btn-group.btn-group-sm {
        flex-wrap: wrap;
        gap: 2px;
    }

    .table .btn-group.btn-group-sm .btn {
        border-radius: 6px !important;
        padding: 0.2rem 0.4rem;
        font-size: 0.7rem;
    }

    /* Grafik yüksekliği */
    .card-body [style*="height: 320px"],
    .card-body [style*="height:320px"] {
        height: 200px !important;
    }

    /* Bildirim dropdown */
    .dropdown-menu[style*="width:320px"],
    .dropdown-menu[style*="width: 320px"] {
        width: calc(100vw - 2rem) !important;
        max-width: 320px;
        right: -0.5rem !important;
    }

    /* Form kaydet butonları */
    .d-flex.justify-content-end.gap-2 {
        flex-direction: column;
    }

    .d-flex.justify-content-end.gap-2 .btn {
        width: 100%;
    }

    /* Card header flex sarma */
    .card-header.d-flex {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* Breadcrumb */
    .breadcrumb {
        font-size: 0.75rem;
    }

    /* Navbar sıkıştır */
    .navbar.px-4 {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    .navbar .gap-3 {
        gap: 0.5rem !important;
    }

    /* Login kart */
    .login-card {
        padding: 1.5rem;
        margin: 1rem;
    }

    /* Kanban sütunları */
    .kanban-column {
        min-width: 260px;
    }

    /* Filtre butonları tam genişlik */
    .card-body form .col-md-3 .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }

    /* Alert mesajları */
    .alert.m-3 {
        margin: 0.5rem !important;
    }

    /* Fatura view — buton grubu sarma */
    .d-flex.gap-2.flex-wrap .btn {
        font-size: 0.8rem;
        padding: 0.35rem 0.6rem;
    }
}

/* ============ TABLET DİKEY (max-width: 767.98px) ============ */
@media (max-width: 767.98px) {

    .main-content .p-4 {
        padding: 1rem !important;
    }

    /* Fatura/teklif kalem tablosu */
    #itemsTable th,
    #itemsTable td {
        white-space: nowrap;
        font-size: 0.8rem;
    }

    #itemsTable .form-control-sm,
    #itemsTable .form-select-sm {
        min-width: 70px;
        font-size: 0.8rem;
        padding: 0.25rem 0.4rem;
    }

    /* Filtre sütunları 50% */
    .card-body form .col-md-2 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    /* Kanban dokunmatik kaydırma */
    .kanban-board {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 1.5rem;
    }

    .kanban-column {
        scroll-snap-align: start;
    }

    /* Tablo width attribute sıfırla */
    .table th[width],
    .table td[width] {
        width: auto !important;
    }

    /* Select2 tam genişlik */
    .select2-container {
        width: 100% !important;
    }
}

/* ============ TABLET YATAY (max-width: 991.98px) ============ */
@media (max-width: 991.98px) {

    /* Sidebar gölge (mevcut toggle kurallarına ek) */
    .sidebar {
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.2);
    }

    .sidebar.show {
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.3);
    }

    /* Sayfa başlıkları daha küçük */
    h1.h3, .h3 {
        font-size: 1.25rem;
    }
}
