/* =====================================================================
   Emin Yıldırım Sigorta — arayüz stilleri (Bootstrap 5 üzerine)
   ===================================================================== */

:root {
    --eys-navy: #0f2747;
    --eys-navy-2: #16345d;
    --eys-bg: #f3f5f9;
    --eys-border: #e7eaf0;
    --eys-radius: .8rem;

    /* Yenileme uyarı renkleri: koyu kırmızı (süresi geçti), kırmızı (≤15 gün), sarı (≤30 gün) */
    --eys-overdue: #991b1b;
    --eys-overdue-bg: #fbd5d5;
    --eys-danger: #dc2626;
    --eys-danger-bg: #fee2e2;
    --eys-warning: #e5a800;
    --eys-warning-bg: #fff8dc;
}

body.app-body {
    background: var(--eys-bg);
}

/* ---------------------------------------------------------------------
   Yerleşim: masaüstünde sabit kenar menü, mobilde üst çubuk + açılır menü
   --------------------------------------------------------------------- */

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: .5rem;
    height: 56px;
    padding: 0 .5rem;
    background: var(--eys-navy);
    color: #fff;
}

.topbar-brand {
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-sidebar {
    --bs-offcanvas-width: 280px;
    --bs-offcanvas-bg: var(--eys-navy);
    --bs-offcanvas-color: #fff;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 100%;
    padding: 1.25rem 1rem;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
    color: #fff;
    text-decoration: none;
}

.sidebar-brand .logo,
.auth-logo {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: linear-gradient(135deg, #3b82f6, #14b8a6);
    color: #fff;
    font-size: 1.3rem;
}

.sidebar-brand .title {
    display: block;
    font-weight: 700;
    line-height: 1.15;
}

.sidebar-brand .subtitle {
    display: block;
    font-size: .75rem;
    opacity: .6;
}

.sidebar-search {
    margin-bottom: 1rem;
}

.sidebar-search .input-group-text,
.sidebar-search .form-control {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(255, 255, 255, .08);
    color: #fff;
}

.sidebar-search .form-control::placeholder {
    color: rgba(255, 255, 255, .5);
}

.sidebar-search .form-control:focus {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .3);
    box-shadow: none;
}

/* iPhone / iPad: 16px'ten küçük yazılı kutuya dokununca Safari sayfayı yakınlaştırır */
@supports (-webkit-touch-callout: none) {
    .sidebar-search .form-control {
        font-size: 16px;
    }
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .55rem .75rem;
    border: 0;
    border-radius: .55rem;
    background: none;
    color: rgba(255, 255, 255, .72);
}

.sidebar-nav .nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, .06);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: rgba(59, 130, 246, .28);
    box-shadow: inset 3px 0 0 #60a5fa;
}

.sidebar-section-title {
    margin: 1.25rem .75rem .5rem;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, .45);
}

.btn-sidebar {
    --bs-btn-color: #fff;
    --bs-btn-bg: rgba(255, 255, 255, .08);
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(255, 255, 255, .16);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: rgba(255, 255, 255, .2);
    --bs-btn-active-color: #fff;
    text-align: left;
}

.btn-sidebar .bi {
    margin-right: .4rem;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, .1);
}

.sidebar-user {
    margin: 0 .75rem .5rem;
    font-size: .85rem;
    color: rgba(255, 255, 255, .55);
}

@media (min-width: 992px) {
    .app-shell {
        display: flex;
        min-height: 100vh;
    }

    .app-sidebar-wrap {
        position: sticky;
        top: 0;
        flex-shrink: 0;
        width: 260px;
        height: 100vh;
        overflow-y: auto;
        background: var(--eys-navy);
    }

    .app-main {
        flex: 1;
        min-width: 0;
    }
}

.app-content {
    max-width: 1400px;
    padding: 1.25rem .9rem 3rem;
}

@media (min-width: 768px) {
    .app-content {
        padding: 2rem 2rem 3rem;
    }
}

/* ---------------------------------------------------------------------
   Genel bileşenler
   --------------------------------------------------------------------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

.page-head h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.page-head .subtitle {
    margin: .15rem 0 0;
    color: var(--bs-secondary-color);
    font-size: .9rem;
}

.card {
    border: 0;
    border-radius: var(--eys-radius);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

.card > .card-header {
    padding: .9rem 1.25rem;
    background: transparent;
    border-bottom: 1px solid var(--eys-border);
    font-weight: 600;
}

.card > .card-header:first-child {
    border-radius: var(--eys-radius) var(--eys-radius) 0 0;
}

.table {
    margin-bottom: 0;
}

.table > thead th {
    padding-top: .7rem;
    padding-bottom: .7rem;
    background: #f8f9fb;
    color: var(--bs-secondary-color);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.table > :not(caption) > * > * {
    padding-left: 1rem;
    padding-right: 1rem;
    vertical-align: middle;
    border-color: var(--eys-border);
}

.form-label {
    font-size: .9rem;
    font-weight: 500;
}

.form-label.required::after {
    content: " *";
    color: var(--bs-danger);
}

.form-section-title {
    margin: 1.75rem 0 .9rem;
    padding-bottom: .4rem;
    border-bottom: 1px solid var(--eys-border);
    color: var(--bs-secondary-color);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.form-section-title:first-child {
    margin-top: 0;
}

/* Müşteri seçici (yazdıkça arama) */
.customer-picker {
    position: relative;
}

.customer-picker .picker-selected {
    display: none;
    align-items: center;
    gap: .6rem;
}

.customer-picker.has-value .picker-selected {
    display: flex;
}

.customer-picker.has-value .picker-search {
    display: none;
}

.customer-picker.is-invalid .form-control {
    border-color: var(--bs-form-invalid-border-color);
}

.picker-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.picker-name {
    font-weight: 600;
}

.picker-meta {
    margin-left: .4rem;
    color: var(--bs-secondary-color);
    font-size: .85rem;
}

.picker-results {
    position: absolute;
    z-index: 1060;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    max-height: 320px;
    overflow-y: auto;
    padding: .25rem;
    border: 1px solid var(--eys-border);
    border-radius: .6rem;
    background: #fff;
    box-shadow: 0 12px 28px rgba(16, 24, 40, .14);
}

.picker-header {
    padding: .4rem .6rem .2rem;
    color: var(--bs-secondary-color);
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.picker-item {
    display: flex;
    flex-direction: column;
    width: 100%;
    padding: .5rem .6rem;
    border: 0;
    border-radius: .45rem;
    background: none;
    text-align: left;
}

.picker-item:hover,
.picker-item.active {
    background: #eef4ff;
}

.picker-item-name {
    font-weight: 600;
}

.picker-item-meta {
    color: var(--bs-secondary-color);
    font-size: .8rem;
}

.picker-empty {
    padding: .6rem;
    color: var(--bs-secondary-color);
    font-size: .9rem;
}

.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--bs-secondary-color);
}

.empty-state .bi {
    display: block;
    margin-bottom: .5rem;
    font-size: 2.5rem;
    opacity: .45;
}

.min-w-0 {
    min-width: 0;
}

.dl-compact dt {
    color: var(--bs-secondary-color);
    font-size: .8rem;
    font-weight: 500;
}

.dl-compact dd {
    margin-bottom: .75rem;
}

/* Plaka görünümü: TR plakası gibi soldan mavi şerit */
.plate {
    display: inline-block;
    padding: .05rem .45rem .05rem .4rem;
    border: 1px solid #c9d0db;
    border-left: 6px solid #1d4ed8;
    border-radius: 4px;
    background: #fff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .85em;
    font-weight: 700;
    letter-spacing: .03em;
    white-space: nowrap;
    color: #111827;
}

/* Durum rozetleri */
.badge-status {
    font-weight: 600;
}

.badge-status.active      { background: #e7f6ec; color: #146c2e; }
.badge-status.renewed     { background: #e8f0fe; color: #1d4ed8; }
.badge-status.not_renewed { background: #eef0f3; color: #4b5563; }
.badge-status.cancelled   { background: #fde8e8; color: #9b1c1c; }
.badge-status.waiting     { background: #fff6dc; color: #8a6100; }
.badge-status.won         { background: #e7f6ec; color: #146c2e; }
.badge-status.lost        { background: #eef0f3; color: #4b5563; }

/* WhatsApp butonu */
.btn-whatsapp {
    --bs-btn-color: #fff;
    --bs-btn-bg: #25d366;
    --bs-btn-border-color: #25d366;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #1ebe5b;
    --bs-btn-hover-border-color: #1ebe5b;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #19a84f;
    --bs-btn-active-border-color: #19a84f;
}

.btn-icon {
    padding: .1rem .35rem;
    line-height: 1.2;
}

/* ---------------------------------------------------------------------
   Ana panel: özet kutuları ve uyarı renkleri
   (koyu kırmızı: süresi geçti, kırmızı: 15 gün içinde, sarı: 30 gün içinde)
   --------------------------------------------------------------------- */

.stat-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1rem;
    height: 100%;
    padding: 1.1rem 1.25rem;
    border-left: 5px solid transparent;
    color: inherit;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(16, 24, 40, .08);
    color: inherit;
}

.stat-card.is-selected {
    outline: 2px solid currentColor;
    outline-offset: -2px;
}

.stat-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    font-size: 1.45rem;
}

.stat-count {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-label {
    margin-top: .25rem;
    font-weight: 600;
}

.stat-hint {
    color: var(--bs-secondary-color);
    font-size: .8rem;
}

.stat-card.overdue  { border-left-color: var(--eys-overdue); }
.stat-card.danger     { border-left-color: var(--eys-danger); }
.stat-card.warning { border-left-color: var(--eys-warning); }
.stat-card.overdue.is-selected  { outline-color: var(--eys-overdue); }
.stat-card.danger.is-selected     { outline-color: var(--eys-danger); }
.stat-card.warning.is-selected { outline-color: var(--eys-warning); }
.stat-card.overdue .stat-icon  { background: var(--eys-overdue-bg);  color: var(--eys-overdue); }
.stat-card.danger .stat-icon     { background: var(--eys-danger-bg);     color: var(--eys-danger); }
.stat-card.warning .stat-icon { background: var(--eys-warning-bg); color: #b58500; }

/* Telefonda üç kutu yan yana, sıkışık düzen */
@media (max-width: 767.98px) {
    .stat-card {
        flex-direction: column;
        align-items: flex-start;
        gap: .4rem;
        padding: .75rem .7rem;
        border-left-width: 4px;
    }

    .stat-icon {
        width: 32px;
        height: 32px;
        border-radius: 9px;
        font-size: 1rem;
    }

    .stat-count {
        font-size: 1.5rem;
    }

    .stat-label {
        font-size: .78rem;
        line-height: 1.25;
    }

    .stat-hint {
        display: none;
    }
}

/* Tablo satırları */
.table tr.urgency-overdue  { --bs-table-bg: var(--eys-overdue-bg); }
.table tr.urgency-danger     { --bs-table-bg: var(--eys-danger-bg); }
.table tr.urgency-warning { --bs-table-bg: var(--eys-warning-bg); }
.table tr.urgency-overdue > td:first-child  { border-left: 4px solid var(--eys-overdue); }
.table tr.urgency-danger > td:first-child     { border-left: 4px solid var(--eys-danger); }
.table tr.urgency-warning > td:first-child { border-left: 4px solid var(--eys-warning); }

/* Kalan gün rozeti */
.days-badge {
    display: inline-block;
    padding: .3em .6em;
    border-radius: 999px;
    background: #eef0f3;
    color: #374151;
    font-size: .78rem;
    font-weight: 600;
    white-space: nowrap;
}

.days-badge.overdue { background: var(--eys-overdue); color: #fff; }
.days-badge.danger  { background: var(--eys-danger);  color: #fff; }
.days-badge.warning { background: var(--eys-warning); color: #3b2a00; }

/* Kırmızı rozetler dikkat çekmek için hafifçe "nabız" atar */
.days-badge.overdue,
.days-badge.danger {
    animation: eys-pulse 1.8s ease-in-out infinite;
}

@keyframes eys-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, .55); }
    50%      { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .days-badge.overdue,
    .days-badge.danger {
        animation: none;
    }
}

/* Panel üstündeki acil uyarı kutusu */
.alert-urgent {
    padding: .9rem 1.1rem;
    border-radius: var(--eys-radius);
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    color: #fff;
    box-shadow: 0 6px 18px rgba(220, 38, 38, .25);
}

.alert-urgent-icon {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 1.25rem;
    animation: eys-ring 2.4s ease-in-out infinite;
}

@keyframes eys-ring {
    0%, 70%, 100% { transform: rotate(0); }
    75% { transform: rotate(14deg); }
    85% { transform: rotate(-14deg); }
    95% { transform: rotate(6deg); }
}

@media (prefers-reduced-motion: reduce) {
    .alert-urgent-icon {
        animation: none;
    }
}

/* Mobil üst çubuktaki zil sayacı */
.alert-dot {
    position: absolute;
    top: 0;
    right: -4px;
    min-width: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}

/* ---------------------------------------------------------------------
   Belgeler (ruhsat fotoğrafları)
   --------------------------------------------------------------------- */

.doc-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.doc-thumbs:empty {
    display: none;
}

.doc-thumb {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    width: 104px;
}

.doc-thumb img,
.doc-file {
    display: grid;
    place-items: center;
    width: 104px;
    height: 76px;
    border: 1px solid var(--eys-border);
    border-radius: .5rem;
    background: #f8f9fb;
    object-fit: cover;
}

.doc-file {
    align-content: center;
    gap: .1rem;
    color: #b42318;
    font-size: .75rem;
    font-weight: 600;
}

.doc-file .bi {
    font-size: 1.5rem;
}

.doc-remove {
    display: flex;
    align-items: center;
    gap: .3rem;
    font-size: .8rem;
}

/* Mobil poliçe kartları */
.policy-cards {
    display: grid;
    gap: .75rem;
}

.policy-card {
    padding: .9rem 1rem;
    border-left: 5px solid #d0d5dd;
    border-radius: var(--eys-radius);
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .06);
}

.policy-card.urgency-overdue  { border-left-color: var(--eys-overdue);  background: var(--eys-overdue-bg); }
.policy-card.urgency-danger     { border-left-color: var(--eys-danger);     background: var(--eys-danger-bg); }
.policy-card.urgency-warning { border-left-color: var(--eys-warning); background: var(--eys-warning-bg); }

.policy-card .meta {
    color: var(--bs-secondary-color);
    font-size: .85rem;
}

/* ---------------------------------------------------------------------
   Giriş / kurulum sayfaları
   --------------------------------------------------------------------- */

body.auth-body {
    min-height: 100vh;
    background:
        radial-gradient(900px 500px at 15% -10%, rgba(59, 130, 246, .35), transparent 60%),
        radial-gradient(700px 400px at 100% 110%, rgba(20, 184, 166, .25), transparent 60%),
        linear-gradient(160deg, #0f2747 0%, #0a1a31 100%);
}

.auth-main {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 100vh;
    max-width: 440px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.auth-card {
    border-radius: 1rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}

.auth-logo {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    border-radius: 14px;
    font-size: 1.75rem;
}

.auth-footer {
    color: rgba(255, 255, 255, .5);
}

/* ---------------------------------------------------------------------
   Tablet ve küçük laptop
   --------------------------------------------------------------------- */

/* Poliçe kartları: tablette iki sütun (tablo sadece geniş ekranda) */
@media (min-width: 768px) {
    .policy-cards {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        padding: .75rem !important;
    }
}

/* 992–1199 px: kenar menü biraz daralır, içeriğe yer kalır */
@media (min-width: 992px) and (max-width: 1199.98px) {
    .app-sidebar-wrap {
        width: 232px;
    }

    .app-content {
        padding: 1.5rem 1.25rem 3rem;
    }
}

/* ---------------------------------------------------------------------
   Küçük parçalar: belge ataşı, yedekleme, rapor
   --------------------------------------------------------------------- */

.doc-link {
    margin-left: .15rem;
    color: var(--bs-secondary-color);
    font-size: .85rem;
    text-decoration: none;
}

.doc-link:hover {
    color: var(--bs-primary);
}

.backup-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fbbf24;
    box-shadow: 0 0 0 3px rgba(251, 191, 36, .25);
}

.feature-icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: #e8f0fe;
    color: #1d4ed8;
    font-size: 1.6rem;
}

.mini-stat {
    padding: .75rem .5rem;
    border: 1px solid var(--eys-border);
    border-radius: .6rem;
    color: var(--bs-secondary-color);
    font-size: .8rem;
}

.mini-stat span {
    display: block;
    color: var(--bs-body-color);
    font-size: 1.4rem;
    font-weight: 700;
}

.report-tile {
    height: 100%;
    padding: 1rem 1.1rem;
}

.report-tile-label {
    color: var(--bs-secondary-color);
    font-size: .8rem;
    font-weight: 500;
}

.report-tile-value {
    margin-top: .2rem;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.report-tile-value small {
    color: var(--bs-secondary-color);
    font-size: .8rem;
    font-weight: 500;
}

.report-tile-hint {
    margin-top: .2rem;
    color: var(--bs-secondary-color);
    font-size: .75rem;
}

.report-table > :not(caption) > * > * {
    padding-top: .55rem;
    padding-bottom: .55rem;
}

.report-bar-cell {
    width: 35%;
}

.report-bar {
    height: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #eef1f6;
}

.report-bar span {
    display: block;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #3b82f6, #14b8a6);
}

.report-bar span.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.upcoming-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .3rem 0;
    font-size: .875rem;
}

.upcoming-label {
    flex-shrink: 0;
    width: 105px;
}

.upcoming-count {
    flex-shrink: 0;
    width: 28px;
    font-weight: 600;
    text-align: right;
}

/* ---------------------------------------------------------------------
   Ana ekrana ekle (uygulama olarak yükle)
   --------------------------------------------------------------------- */

.install-banner {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1rem;
    padding: .8rem 1rem;
    border: 1px solid #c7d7fe;
    border-radius: var(--eys-radius);
    background: #eef4ff;
}

.install-banner .app-icon {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 10px;
}

/* ---------------------------------------------------------------------
   Yazdırma (raporlar vb.): menüler gizlenir
   --------------------------------------------------------------------- */

@media print {
    .app-sidebar-wrap,
    .app-topbar,
    .install-banner,
    .no-print,
    .alert-dismissible {
        display: none !important;
    }

    body.app-body {
        background: #fff;
    }

    .app-content {
        max-width: none;
        padding: 0;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
        break-inside: avoid;
    }
}
