/* ==========================================================================
   Pati Yonetim - ortak stiller
   Birincil hedef cihaz iPad. Buradaki kurallarin cogu dokunmatik kullanim
   icin var; degistirmeden once iPad'de test edin.
   ========================================================================== */

:root {
  --background: #fbf9f8;
  --surface: #ffffff;
  --surface-low: #f6f3f2;
  --surface-high: #eae8e7;
  --on-surface: #1b1c1c;
  --on-surface-variant: #444840;
  --outline-variant: #c4c8bd;
  --primary: #4f6144;
  --primary-container: #677a5c;
  --secondary: #9d422c;
  --error: #ba1a1a;
  --success: #3a6b3a;

  --rail-width: 88px;
  --sidebar-width: 280px;
  --header-height: 64px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* --------------------------------------------------------------------------
   Temel / iOS-iPadOS davranislari
   -------------------------------------------------------------------------- */

* {
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%; /* iPad yatay donusunde metin buyumesin */
  text-size-adjust: 100%;
}

body {
  background-color: var(--background);
  color: var(--on-surface);
  min-height: 100vh;
  min-height: 100dvh; /* Safari adres cubugu ile degisen yukseklik */
  overscroll-behavior-y: none; /* pull-to-refresh ve bounce kapali */
  touch-action: manipulation; /* cift dokunma zoom'u ve 300ms gecikme yok */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Ana ekrana eklendiginde (standalone) durum cubugu alani */
@media (display-mode: standalone) {
  body {
    padding-top: var(--safe-top);
  }
}

/* iOS Safari, 16px'ten kucuk yazi tipli bir alana odaklaninca sayfayi
   otomatik yakinlastirir ve duzeni bozar. Tum form alanlari en az 16px. */
input,
select,
textarea,
button {
  font-family: inherit;
  font-size: 16px;
}

input[type='date'],
input[type='time'],
input[type='datetime-local'] {
  min-height: 44px;
}

/* Safari'de date/time inputlari varsayilan olarak icerige gore daralir */
input[type='date']::-webkit-date-and-time-value {
  text-align: left;
}

textarea {
  resize: vertical;
}

/* --------------------------------------------------------------------------
   Dokunma hedefleri (Apple HIG: en az 44x44pt)
   -------------------------------------------------------------------------- */

button,
[role='button'],
a.nav-item,
.touch-target {
  min-height: 44px;
  min-width: 44px;
}

/* Satir ici kucuk metin baglantilari bu kuraldan muaf */
button.inline-link,
a.inline-link {
  min-height: 0;
  min-width: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: var(--on-surface-variant);
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.92);
  background-color: var(--surface-high);
}

/* --------------------------------------------------------------------------
   Hover yalnizca fare olan cihazlarda. iPad'de hover diye bir sey yok;
   hover'a bagli gizlenen aksiyonlar dokunmatikte hic gorunmez.
   -------------------------------------------------------------------------- */

@media (hover: hover) and (pointer: fine) {
  .hover-lift {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }
  .hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(60, 50, 40, 0.09);
  }
  .icon-btn:hover {
    background-color: var(--surface-high);
    color: var(--primary);
  }
  .row-actions {
    opacity: 0;
    transition: opacity 0.15s ease;
  }
  tr:hover .row-actions,
  .group:hover .row-actions,
  .row-actions:focus-within {
    opacity: 1;
  }
}

/* Dokunmatikte satir aksiyonlari her zaman gorunur ve buyuk */
@media (hover: none) {
  .row-actions {
    opacity: 1 !important;
  }
  .hover-lift:active {
    transform: scale(0.99);
  }
}

/* --------------------------------------------------------------------------
   Kartlar ve yuzeyler
   -------------------------------------------------------------------------- */

.card {
  background-color: #ffffff;
  border: 1px solid rgba(196, 200, 189, 0.35);
  border-radius: 1.5rem;
  box-shadow: 0 10px 30px rgba(60, 50, 40, 0.04);
}

.card-flat {
  background-color: #ffffff;
  border: 1px solid rgba(196, 200, 189, 0.35);
  border-radius: 1rem;
}

/* Cam efekti pahali; iPad GPU'sunda scroll takilmamasi icin sadece
   sabit duran (scroll ile hareket etmeyen) yuzeylerde kullaniliyor. */
.glass {
  background: rgba(251, 249, 248, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* --------------------------------------------------------------------------
   Butonlar
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
  cursor: pointer;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled,
.btn[aria-disabled='true'] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 97, 68, 0.2);
}

.btn-secondary {
  background-color: var(--secondary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(157, 66, 44, 0.2);
}

.btn-outline {
  background-color: #ffffff;
  color: var(--primary);
  border: 1px solid rgba(79, 97, 68, 0.4);
}

.btn-ghost {
  background-color: transparent;
  color: var(--on-surface-variant);
}

.btn-danger {
  background-color: var(--error);
  color: #ffffff;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background-color: #445437; }
  .btn-secondary:hover { background-color: #8a3826; }
  .btn-outline:hover { background-color: rgba(79, 97, 68, 0.08); }
  .btn-ghost:hover { background-color: var(--surface-high); }
  .btn-danger:hover { background-color: #a01616; }
}

/* --------------------------------------------------------------------------
   Form alanlari
   -------------------------------------------------------------------------- */

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--on-surface-variant);
  margin-bottom: 6px;
}

.input,
.select,
.textarea {
  width: 100%;
  background-color: #f9f9f9;
  border: 1px solid rgba(196, 200, 189, 0.6);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  color: var(--on-surface);
  min-height: 48px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: rgba(68, 72, 64, 0.45);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 97, 68, 0.12);
}

.input-invalid {
  border-color: var(--error) !important;
  box-shadow: 0 0 0 3px rgba(186, 26, 26, 0.1) !important;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23444840' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

/* Odak halkasi klavye kullanicilari icin gorunur, dokunmatikte gereksiz */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Rozetler
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background-color: currentColor;
  flex-shrink: 0;
}

.badge-bekliyor { background-color: #e4e2e1; color: #444840; }
.badge-onaylandi { background-color: #d4e9c4; color: #3a4c31; }
.badge-devam { background-color: #ffddb2; color: #594322; }
.badge-tamamlandi { background-color: #d7f0d4; color: #2c5c2c; }
.badge-iptal { background-color: #ffdad6; color: #93000a; }
.badge-gelmedi { background-color: #e4e2e1; color: #74786f; }

/* --------------------------------------------------------------------------
   Navigasyon: telefon (alt bar) / iPad portrait (ray) / genis (tam menu)
   -------------------------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  color: var(--on-surface-variant);
  font-size: 15px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.nav-item:active {
  transform: scale(0.97);
}

.nav-item.is-active {
  background-color: var(--primary-container);
  color: #f8ffee;
  font-weight: 700;
}

@media (hover: hover) and (pointer: fine) {
  .nav-item:not(.is-active):hover {
    background-color: rgba(228, 226, 225, 0.7);
    color: var(--primary);
  }
}

/* Ray modu (768-1023px): sadece ikon + kucuk etiket */
.sidebar-rail .nav-item {
  flex-direction: column;
  gap: 3px;
  padding: 10px 4px;
  font-size: 10px;
  font-weight: 600;
  text-align: center;
  letter-spacing: 0.01em;
}

.sidebar-rail .nav-label-full {
  display: none;
}

.sidebar-rail .nav-label-short {
  display: block;
}

.nav-label-short {
  display: none;
}

/* Ray uzerine acilan tam menu (drawer) */
.nav-drawer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
}

.nav-drawer.is-open {
  display: block;
}

.nav-drawer-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 280px;
  background-color: var(--background);
  box-shadow: 0 0 60px rgba(60, 50, 40, 0.25);
  padding-left: var(--safe-left);
  animation: drawer-in 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

@keyframes drawer-in {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.nav-drawer-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(27, 28, 28, 0.4);
  animation: fade-in 0.18s ease-out;
}

/* Alt navigasyon (telefon) */
.bottom-nav {
  padding-bottom: calc(12px + var(--safe-bottom));
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 60px;
  min-height: 48px;
  padding: 4px 12px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--on-surface-variant);
  transition: transform 0.12s ease, background-color 0.15s ease;
}

.bottom-nav-item:active {
  transform: scale(0.9);
}

.bottom-nav-item.is-active {
  background-color: #fd8c70;
  color: #742411;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   Modal / bottom sheet
   -------------------------------------------------------------------------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}

.modal-root.is-open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(27, 28, 28, 0.45);
  animation: fade-in 0.18s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(100% - 32px, 720px);
  max-height: min(90dvh, 900px);
  display: flex;
  flex-direction: column;
  background-color: #ffffff;
  border-radius: 24px;
  box-shadow: 0 24px 60px rgba(60, 50, 40, 0.22);
  animation: modal-in 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-panel-wide {
  width: min(100% - 48px, 1040px);
}

@keyframes modal-in {
  from { opacity: 0; transform: translate(-50%, -46%) scale(0.97); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1;
}

/* Telefonda modal alt sayfaya (bottom sheet) donusur */
@media (max-width: 743px) {
  .modal-panel,
  .modal-panel-wide {
    left: 0;
    top: auto;
    bottom: 0;
    transform: none;
    width: 100%;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    padding-bottom: var(--safe-bottom);
    animation: sheet-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  }
  @keyframes sheet-in {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* Modal aciklen arka planin kaymasini engelle */
body.modal-open {
  overflow: hidden;
}

/* Yan panel (randevu detayi) */
.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(100%, 460px);
  background-color: #ffffff;
  box-shadow: -12px 0 40px rgba(60, 50, 40, 0.16);
  z-index: 70;
  display: flex;
  flex-direction: column;
  animation: panel-in 0.26s cubic-bezier(0.16, 1, 0.3, 1);
  padding-right: var(--safe-right);
}

@keyframes panel-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@media (max-width: 743px) {
  .side-panel {
    top: auto;
    width: 100%;
    max-height: 92dvh;
    border-radius: 24px 24px 0 0;
    animation: sheet-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    padding-bottom: var(--safe-bottom);
  }
}

/* --------------------------------------------------------------------------
   Gorunum sekmeleri (takvim/liste, gelir/gider suzgeci, ayar sekmeleri)
   -------------------------------------------------------------------------- */

.view-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 8px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--on-surface-variant);
  transition: background-color 0.15s ease, color 0.15s ease;
}

.view-tab.is-active {
  background-color: #ffffff;
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(60, 50, 40, 0.08);
}

/* --------------------------------------------------------------------------
   Bildirim (toast)
   -------------------------------------------------------------------------- */

.toast-stack {
  position: fixed;
  z-index: 100;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(100% - 32px, 420px);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 16px;
  background-color: #303030;
  color: #f3f0f0;
  font-size: 15px;
  box-shadow: 0 12px 32px rgba(60, 50, 40, 0.28);
  animation: toast-in 0.24s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.toast-success { background-color: #33562f; }
.toast-error { background-color: #8c1d18; }
.toast-warning { background-color: #6b4a00; }

.toast.is-leaving {
  animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px); }
}

/* --------------------------------------------------------------------------
   Tablolar
   -------------------------------------------------------------------------- */

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 14px 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(68, 72, 64, 0.7);
  background-color: var(--surface-low);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 20px;
  font-size: 14px;
  border-top: 1px solid rgba(196, 200, 189, 0.25);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background-color 0.12s ease;
}

.data-table tbody tr:active {
  background-color: rgba(246, 243, 242, 0.9);
}

/* Analiz tablolarinda ilk sutun yapiskan kalir; iPad portrait'te
   yatay kaydirirken hangi satirda oldugunuzu kaybetmemek icin. */
.sticky-first-col th:first-child,
.sticky-first-col td:first-child {
  position: sticky;
  left: 0;
  background-color: #ffffff;
  z-index: 2;
  box-shadow: 1px 0 0 rgba(196, 200, 189, 0.3);
}

.sticky-first-col thead th:first-child {
  background-color: var(--surface-low);
  z-index: 3;
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

/* --------------------------------------------------------------------------
   Yukleniyor durumlari
   -------------------------------------------------------------------------- */

.skeleton {
  background: linear-gradient(90deg, #eeebea 25%, #f6f3f2 50%, #eeebea 75%);
  background-size: 800px 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 12px;
}

@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-dark {
  border-color: rgba(79, 97, 68, 0.25);
  border-top-color: var(--primary);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Yardimci siniflar
   -------------------------------------------------------------------------- */

.scroll-y {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { scrollbar-width: none; }

.scroll-y::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-y::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb {
  background-color: rgba(116, 120, 111, 0.3);
  border-radius: 8px;
}
.scroll-y::-webkit-scrollbar-track,
.table-scroll::-webkit-scrollbar-track { background: transparent; }

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  user-select: none;
  flex-shrink: 0;
}

.icon-filled {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* Sayisal degerlerde rakam genisligi sabit kalsin (tablolar oynamasin) */
.tabular {
  font-variant-numeric: tabular-nums;
}

/* Yazdirma: menuler ve butonlar cikmasin */
@media print {
  .no-print,
  aside,
  header,
  nav {
    display: none !important;
  }
  main {
    margin: 0 !important;
    padding: 0 !important;
  }
  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* Hareket azaltma tercihi */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
