/* =========================================================
   ENTARE CRM - SINGLE SOURCE UI LAYER
   Tema: Mürdüm / Erik
   ========================================================= */

/* -------------------- Base / Reset -------------------- */
html {
    font-size: 14px;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

html {
    position: relative;
    min-height: 100%;
}

body {
    margin-bottom: 0;
}

* {
    -webkit-tap-highlight-color: transparent;
}

:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,.9), 0 0 0 6px rgba(74,32,96,.2);
    border-radius: 14px;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 2px rgba(255,255,255,.9), 0 0 0 6px rgba(74,32,96,.2);
}

/* -------------------- Tokens -------------------- */
:root {
    --crm-primary: 74 32 96; /* #4A2060 mürdüm */
    --crm-primary-2: 58 22 78; /* #3A164E koyu mürdüm */
    --crm-primary-3: 96 46 124; /* #602E7C açık mürdüm */
    --crm-bg: 247 243 251; /* leylak beyazı */
    --crm-surface: 255 255 255;
    --crm-text: 30 10 42;
    --crm-muted: 120 90 140;
    --crm-border: 224 208 238;
    --crm-border-2: 205 182 224;
    --crm-shadow: 30 10 42;
}

/* -------------------- Page Shell -------------------- */
.crm-shell {
    min-height: 100vh;
    color: rgb(var(--crm-text));
    background: radial-gradient(1200px 600px at 10% 0%, rgba(74,32,96,.07), transparent 60%), radial-gradient(900px 500px at 90% 10%, rgba(157,78,110,.05), transparent 55%), rgb(var(--crm-bg));
}

.crm-main {
    padding: 16px;
}

@media (min-width: 1024px) {
    .crm-main {
        padding: 24px;
    }
}

.drawer-overlay {
    background: rgba(30,10,42,.45) !important;
}

/* -------------------- Topbar -------------------- */
.crm-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,.80);
    border-bottom: 1px solid rgb(var(--crm-border));
}

.crm-input {
    border-radius: 14px !important;
    border: 1px solid rgb(var(--crm-border)) !important;
    background: rgba(255,255,255,.92) !important;
}

    .crm-input::placeholder {
        color: rgba(120,90,140,.75);
    }

    .crm-input:focus {
        outline: none;
        box-shadow: 0 0 0 4px rgba(74,32,96,.12);
        border-color: rgba(74,32,96,.3) !important;
    }

/* -------------------- Sidebar -------------------- */
.crm-sidebar {
    position: sticky;
    top: 0;
    z-index: 50; /* her zaman üstte */
    height: 100vh;
    overflow-y: auto;
    background: linear-gradient(180deg, #ffffff 0%, #faf6fd 100%);
    border-right: 1px solid rgb(var(--crm-border));
}

    .crm-sidebar .crm-brand {
        padding: 18px 18px 10px 18px;
    }

        .crm-sidebar .crm-brand .title {
            font-weight: 800;
            letter-spacing: -0.02em;
            font-size: 1.15rem;
        }

        .crm-sidebar .crm-brand .sub {
            margin-top: 2px;
            font-size: .75rem;
            color: rgb(var(--crm-muted));
        }

/* Menu */
.crm-menu a {
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 500;
    transition: all .18s ease;
    line-height: 1.15;
    color: rgb(var(--crm-text));
}

    .crm-menu a:hover {
        background: rgba(74,32,96,.08);
        transform: translateX(2px);
        color: rgb(var(--crm-primary));
    }

    .crm-menu a.active,
    .crm-menu a[aria-current="page"] {
        background: rgba(74,32,96,.12);
        outline: 1px solid rgba(74,32,96,.18);
        color: rgb(var(--crm-primary));
        font-weight: 650;
    }

.crm-menu details > summary {
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 650;
    color: rgb(var(--crm-text));
}

    .crm-menu details > summary:hover {
        background: rgba(74,32,96,.08);
        color: rgb(var(--crm-primary));
    }

/* Aktif menü öğesi */
.crm-menu-active {
    background: rgba(74,32,96,.11) !important;
    color: rgb(74,32,96) !important;
    font-weight: 700;
    border-radius: 0.75rem;
}

    .crm-menu-active svg {
        opacity: 1 !important;
        color: rgb(74,32,96) !important;
    }

/* Sidebar ayraç */
li.crm-menu-divider {
    margin: 0.375rem 0.5rem;
    height: 1px;
    background: rgba(74,32,96,.12);
    padding: 0;
    list-style: none;
}

/* -------------------- Cards -------------------- */
.crm-card {
    background: rgb(var(--crm-surface));
    border: 1px solid rgba(224,208,238,.95);
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(30,10,42,.06);
}

.crm-stat {
    border-radius: 16px !important;
    border: 1px solid rgba(224,208,238,.95);
    box-shadow: 0 8px 24px rgba(30,10,42,.05);
}

    .crm-stat .stat-title {
        color: rgb(var(--crm-muted));
    }

    .crm-stat .stat-value {
        letter-spacing: -0.02em;
        color: rgb(var(--crm-primary));
    }

/* -------------------- Buttons -------------------- */
.crm-btn-primary {
    background: rgb(var(--crm-primary)) !important;
    border-color: rgba(0,0,0,0) !important;
    color: #fff !important;
    border-radius: 14px !important;
}

    .crm-btn-primary:hover {
        background: rgb(var(--crm-primary-2)) !important;
    }

.crm-btn-soft {
    background: rgba(74,32,96,.10) !important;
    border-color: rgba(74,32,96,.14) !important;
    color: rgb(var(--crm-primary)) !important;
    border-radius: 14px !important;
}

    .crm-btn-soft:hover {
        background: rgba(74,32,96,.16) !important;
    }

.crm-btn-ghost {
    border-radius: 14px !important;
}

.crm-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 14px !important;
}

/* -------------------- Tables -------------------- */
.crm-table-wrap {
    border: 1px solid rgba(224,208,238,.95);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 8px 24px rgba(30,10,42,.05);
}

.crm-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

    .crm-table thead th {
        position: sticky;
        top: 0;
        z-index: 1;
        background: rgba(247,243,251,.97);
        color: rgb(var(--crm-muted));
        font-weight: 650;
        font-size: .85rem;
        letter-spacing: .01em;
        border-bottom: 1px solid rgb(var(--crm-border));
        padding: 12px 14px;
    }

    .crm-table tbody td {
        padding: 12px 14px;
        border-bottom: 1px solid rgba(224,208,238,.7);
    }

    .crm-table tbody tr:hover td {
        background: rgba(74,32,96,.04);
    }

    .crm-table tbody tr:last-child td {
        border-bottom: none;
    }

.crm-table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* -------------------- Forms -------------------- */
.crm-form {
    display: grid;
    gap: 14px;
}

.crm-label {
    display: block;
    font-weight: 650;
    font-size: .9rem;
    margin-bottom: 6px;
    color: rgb(var(--crm-text));
}

.crm-help {
    margin-top: 6px;
    font-size: .8rem;
    color: rgb(var(--crm-muted));
}

.crm-field,
.crm-select,
.crm-textarea {
    border-radius: 14px !important;
    border: 1px solid rgb(var(--crm-border)) !important;
    background: rgba(255,255,255,.92) !important;
}

    .crm-field:focus,
    .crm-select:focus,
    .crm-textarea:focus {
        outline: none;
        box-shadow: 0 0 0 4px rgba(74,32,96,.12);
        border-color: rgba(74,32,96,.3) !important;
    }

.crm-error {
    background: rgba(220,38,38,.08);
    border: 1px solid rgba(220,38,38,.16);
    color: rgb(153 27 27);
    padding: 10px 12px;
    border-radius: 14px;
}

.crm-success {
    background: rgba(74,32,96,.08);
    border: 1px solid rgba(74,32,96,.16);
    color: rgb(var(--crm-primary));
    padding: 10px 12px;
    border-radius: 14px;
}

/* -------------------- Badges -------------------- */
.crm-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    padding: 6px 10px;
    font-weight: 650;
    font-size: .78rem;
    border: 1px solid rgba(224,208,238,.95);
    background: rgba(247,243,251,.9);
    color: rgb(var(--crm-muted));
}

    .crm-badge.primary {
        border-color: rgba(74,32,96,.18);
        background: rgba(74,32,96,.10);
        color: rgb(var(--crm-primary));
    }

    .crm-badge.danger {
        border-color: rgba(220,38,38,.18);
        background: rgba(220,38,38,.10);
        color: rgb(153 27 27);
    }

    .crm-badge.warning {
        border-color: rgba(234,179,8,.20);
        background: rgba(234,179,8,.12);
        color: rgb(133 77 14);
    }

/* -------------------- Modals -------------------- */
.crm-modal {
    border-radius: 18px !important;
    border: 1px solid rgba(224,208,238,.95);
    box-shadow: 0 20px 60px rgba(30,10,42,.18);
}

/* -------------------- Pagination -------------------- */
.crm-pagination {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.crm-page {
    min-width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    border: 1px solid rgba(224,208,238,.95);
    background: rgba(255,255,255,.9);
    font-weight: 650;
}

    .crm-page:hover {
        background: rgba(74,32,96,.08);
        border-color: rgba(74,32,96,.16);
        color: rgb(var(--crm-primary));
    }

    .crm-page.active {
        background: rgba(74,32,96,.12);
        border-color: rgba(74,32,96,.24);
        color: rgb(var(--crm-primary));
    }

/* -------------------- Alerts -------------------- */
.crm-alert {
    border-radius: 16px !important;
    border: 1px solid rgba(224,208,238,.95) !important;
    box-shadow: 0 8px 24px rgba(30,10,42,.08) !important;
}

/* -------------------- Scrollbar -------------------- */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(224,208,238,.4);
}

::-webkit-scrollbar-thumb {
    background: rgba(74,32,96,.25);
    border-radius: 999px;
    border: 2px solid rgba(224,208,238,.4);
}

    ::-webkit-scrollbar-thumb:hover {
        background: rgba(74,32,96,.40);
    }

/* -------------------- Utilities -------------------- */
.crm-section-title {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.crm-muted {
    color: rgb(var(--crm-muted));
}

.crm-divider {
    height: 1px;
    background: rgba(224,208,238,.95);
}

/* -------------------- Responsive -------------------- */
@media (max-width: 1023px) {
    .drawer-content {
        min-height: 100vh;
    }
}

/* -------------------- Drawer overlay fix -------------------- */
@media (max-width: 1023.98px) {
    #crm-drawer:not(:checked) ~ .drawer-side > .drawer-overlay {
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    #crm-drawer:checked ~ .drawer-side > .drawer-overlay {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
}

/* -------------------- Sidebar z-index fix -------------------- */
.drawer-side {
    z-index: 50 !important;
}

.crm-sidebar {
    z-index: 50;
}

/* -------------------- Reduce motion -------------------- */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        scroll-behavior: auto !important;
    }
}
