/* ============================================================
   TANNEGG MOBILE CSS v1.0
   Sadece mobil cihazları etkiler (@media max-width: 768px)
   Desktop'a SIFIR etki!
   Geri dönüş: Bu dosyayı silmek yeterli.
   ============================================================ */

/* ==================== BOTTOM NAVIGATION ==================== */
/* Sadece mobilde görünür */
.mobile-bottom-nav {
  display: none;
}

@media (max-width: 768px) {

  /* ---- BODY: modal-open durumu ---- */
  body.modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
  }

  /* ---- BOTTOM NAVIGATION ---- */
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
    z-index: 9000;
    padding-bottom: env(safe-area-inset-bottom);
    align-items: center;
    justify-content: space-around;
  }

  .mobile-bottom-nav .bnav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 6px 0;
    cursor: pointer;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 700;
    transition: color 0.2s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    min-height: 44px;
  }

  .mobile-bottom-nav .bnav-item .bnav-icon {
    font-size: 22px;
    margin-bottom: 2px;
    line-height: 1;
  }

  .mobile-bottom-nav .bnav-item.active {
    color: #7c3aed;
  }

  .mobile-bottom-nav .bnav-item:active {
    transform: scale(0.92);
  }

  /* ---- MAIN CONTENT: bottom nav için padding ---- */
  .main-content {
    padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
  }

  #contentArea {
    padding-bottom: 130px !important;
  }

  /* ---- HAMBURGER MENÜ BUTONU: GIZLE (bottom nav var) ---- */
  #mobileMenuBtn,
  .mobile-menu-btn {
    display: none !important;
  }

  /* ---- CONTENT AREA: üst padding (hamburger yok) ---- */
  #contentArea {
    padding-top: 16px !important;
  }

  /* ---- CONTENT TITLE: hamburger yok, sola hizala ---- */
  .content-title {
    padding-left: 12px !important;
    font-size: 20px !important;
  }

  /* ==================== MODAL → TAM EKRAN SHEET ==================== */

  /* Standard modal-content: tam ekran sheet */
  .modal-content,
  [id*="Modal"] > div:first-child,
  .gv-modal-card {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 100vh !important;
    height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding-top: env(safe-area-inset-top) !important;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }

  /* Modal overlay tam ekran */
  .gv-modal-overlay,
  [style*="position:fixed"][style*="z-index:10000"],
  [style*="position: fixed"][style*="z-index: 10000"],
  #modal {
    padding: 0 !important;
    align-items: stretch !important;
  }

  /* Modal inner scroll */
  .gv-modal-inner {
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom)) !important;
    padding: 16px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* Modal header sticky */
  .modal-header,
  .gv-modal-top {
    position: sticky !important;
    top: 0 !important;
    background: white !important;
    z-index: 10 !important;
    padding: 16px !important;
    border-bottom: 1px solid #f1f5f9 !important;
  }

  /* ==================== STUNDEN MODAL (inline style override) ==================== */

  /* Admin Stunden Modal → tam ekran */
  #adminAddStundenModal > div:first-child {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 100vh !important;
    height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    padding: 16px !important;
    padding-top: calc(16px + env(safe-area-inset-top)) !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  }

  /* Stunden tabloları: tablo yerine dikey kart */
  #adminAddStundenModal table {
    display: block !important;
    overflow-x: visible !important;
    white-space: normal !important;
  }

  #adminAddStundenModal thead {
    display: none !important;
  }

  #adminAddStundenModal tbody,
  #adminAddStundenModal tr {
    display: block !important;
    width: 100% !important;
  }

  #adminAddStundenModal td {
    display: flex !important;
    align-items: center !important;
    padding: 8px 4px !important;
    text-align: left !important;
    width: 100% !important;
    gap: 8px !important;
  }

  /* Label'sız td'leri gizle (boş shift label hücreleri) */
  #adminAddStundenModal td[data-label="🌅 Vormittag"],
  #adminAddStundenModal td[data-label="🌙 Abend"] {
    background: linear-gradient(135deg, #dbeafe, #eff6ff) !important;
    border-radius: 10px !important;
    padding: 12px !important;
    margin: 8px 0 4px !important;
    justify-content: center !important;
  }

  /* Shift başlıkları büyük göster */
  #adminAddStundenModal td[data-label="🌅 Vormittag"]::before {
    content: attr(data-label);
    font-size: 18px !important;
    font-weight: 900 !important;
    color: #1e40af !important;
  }

  #adminAddStundenModal td[data-label="🌙 Abend"]::before {
    content: attr(data-label);
    font-size: 18px !important;
    font-weight: 900 !important;
    color: #9a3412 !important;
  }

  #adminAddStundenModal td[data-label="🌙 Abend"] {
    background: linear-gradient(135deg, #fed7aa, #fff7ed) !important;
  }

  /* Input label'ları göster (Beginn, Pause, Ende) */
  #adminAddStundenModal td[data-label="Beginn"]::before,
  #adminAddStundenModal td[data-label="Pause (Min)"]::before,
  #adminAddStundenModal td[data-label="Ende"]::before {
    content: attr(data-label);
    font-weight: 800;
    font-size: 14px;
    color: #334155;
    min-width: 90px;
    flex-shrink: 0;
  }

  /* Stunden input'lar tam genişlik */
  #adminAddStundenModal input[type="time"],
  #adminAddStundenModal input[type="number"] {
    flex: 1 !important;
    width: 100% !important;
    max-width: none !important;
    padding: 12px !important;
    font-size: 16px !important;
    border-radius: 10px !important;
    min-height: 48px !important;
  }

  /* Ergebnis grid: mobilde yatay sığsın */
  #adminAddStundenModal [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: 1fr 1fr 1fr !important;
    gap: 6px !important;
  }

  #adminAddStundenModal [style*="grid-template-columns:repeat(3"] > div {
    padding: 4px !important;
  }

  #adminAddStundenModal [style*="font-size:20px"][style*="font-weight:900"] {
    font-size: 16px !important;
  }

  /* ==================== DASHBOARD KARTLARI ==================== */

  .dashboard-grid,
  .stat-cards-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
  }

  .dashboard-card,
  .stat-card {
    padding: 14px !important;
    border-radius: 14px !important;
    min-height: auto !important;
  }

  .stat-card-value,
  .dashboard-card .card-value {
    font-size: 24px !important;
  }

  .stat-card-label,
  .dashboard-card .card-label {
    font-size: 11px !important;
  }

  /* Büyük gradient kartları küçült (Employee Dashboard) */
  #contentArea [style*="min-height:200px"][style*="border-radius:20px"] {
    min-height: 80px !important;
    padding: 16px !important;
    border-radius: 14px !important;
  }

  /* Dashboard kart grid - 2 sütun */
  #contentArea [style*="grid-template-columns:repeat(auto-fit"][style*="minmax(220px"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
  }

  /* İkon küçült */
  #contentArea [style*="min-height:200px"][style*="border-radius:20px"] [style*="font-size:56px"] {
    font-size: 32px !important;
    margin-bottom: 8px !important;
  }

  /* Kart başlıkları */
  #contentArea [style*="min-height:200px"][style*="border-radius:20px"] [style*="font-size:26px"] {
    font-size: 16px !important;
    margin-bottom: 4px !important;
  }

  /* Alt metin */
  #contentArea [style*="min-height:200px"][style*="border-radius:20px"] [style*="font-size:14px"][style*="rgba(255"] {
    font-size: 11px !important;
  }

  /* Eski 48px/40px ikonları da küçült */
  #contentArea [style*="min-height:200px"][style*="border-radius:20px"] [style*="font-size:48px"],
  #contentArea [style*="min-height:200px"][style*="border-radius:20px"] [style*="font-size:40px"] {
    font-size: 32px !important;
  }

  #contentArea [style*="min-height:200px"][style*="border-radius:20px"] [style*="font-size:16px"] {
    font-size: 11px !important;
  }

  /* ==================== TABLOLAR → MOBİL KART ==================== */

  /* Genel tablolar: yatay scroll */
  table:not(#adminAddStundenModal table) {
    display: block !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    border-radius: 12px !important;
    font-size: 13px !important;
  }

  table:not(#adminAddStundenModal table) th,
  table:not(#adminAddStundenModal table) td {
    padding: 10px 8px !important;
    white-space: nowrap !important;
  }

  /* ==================== BUTONLAR ==================== */

  /* Tüm butonlar dokunmatik uyumlu */
  .btn,
  button:not(#mobileMenuBtn):not(.bnav-item) {
    min-height: 44px !important;
    font-size: 14px !important;
    border-radius: 12px !important;
  }

  /* Btn group: dikey sıralama */
  .btn-group,
  [style*="display:flex"][style*="gap"] > .btn,
  [style*="display: flex"][style*="gap"] > .btn {
    flex-wrap: wrap !important;
  }

  /* ==================== FORM ELEMENTLERI ==================== */

  input[type="text"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  input[type="password"],
  input[type="email"],
  select,
  textarea {
    font-size: 16px !important; /* iOS zoom engelleme */
    min-height: 48px !important;
    border-radius: 10px !important;
    padding: 12px !important;
  }

  /* ==================== REQUEST / ANFRAGEN KARTLARI ==================== */

  .request-card {
    padding: 14px !important;
    border-radius: 14px !important;
  }

  .request-header {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .request-actions {
    width: 100% !important;
    display: flex !important;
    gap: 8px !important;
  }

  .request-actions .btn {
    flex: 1 !important;
  }

  /* ==================== DOKUMENTE PANEL ==================== */

  .dokumente-panels {
    flex-direction: column !important;
    height: auto !important;
  }

  .dokumente-employee-list {
    width: 100% !important;
    max-height: none !important;
    overflow-y: visible !important;
  }

  .dokumente-employee-list .accordion-toggle {
    display: flex !important;
  }

  .dokumente-employee-list.collapsed .accordion-content {
    display: none !important;
  }

  .dokumente-employee-list.collapsed {
    max-height: none !important;
    overflow: hidden !important;
  }

  .accordion-arrow.rotated {
    transform: rotate(180deg) !important;
  }

  .dokumente-detail-panel {
    width: 100% !important;
  }

  /* ==================== EINKAUF SAYFASI ==================== */

  /* Einkauf grid */
  [style*="grid-template-columns: repeat(auto-fill"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* ==================== MITARBEITER LİSTE ==================== */

  /* Employee kart grid */
  [style*="grid-template-columns"][style*="minmax(280"] {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  /* ==================== TOAST BİLDİRİMLERİ ==================== */

  .gv-toast {
    bottom: calc(76px + env(safe-area-inset-bottom)) !important;
    max-width: 90vw !important;
    font-size: 13px !important;
  }

  /* ==================== PWA INSTALL BANNER ==================== */

  #pwaInstallBanner {
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
  }

  /* ==================== SIDEBAR OVERLAY İYİLEŞTİRME ==================== */

  .sidebar-overlay.active {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 999 !important;
  }

  /* ==================== GENİŞ MODAL'LAR (Admin Employee Detail vb.) ==================== */

  /* Inline style ile max-width verilen div'ler */
  [style*="max-width:900px"],
  [style*="max-width: 900px"],
  [style*="max-width:800px"],
  [style*="max-width: 800px"],
  [style*="max-width:700px"],
  [style*="max-width: 700px"],
  [style*="max-width:600px"],
  [style*="max-width: 600px"],
  [style*="max-width:500px"],
  [style*="max-width: 500px"] {
    max-width: 100% !important;
    width: 100% !important;
  }

  /* Fixed overlay olan modal container'lar → tam ekran */
  [style*="position:fixed"][style*="background:rgba"] > div,
  [style*="position: fixed"][style*="background: rgba"] > div {
    max-width: 100% !important;
    width: 100% !important;
    max-height: 100vh !important;
    height: 100vh !important;
    margin: 0 !important;
    border-radius: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* ==================== SCROLLİNG İYİLEŞTİRME ==================== */

  /* Smooth scroll */
  * {
    -webkit-overflow-scrolling: touch;
  }

  /* Scroll yapılan alanlar */
  [style*="overflow-y:auto"],
  [style*="overflow-y: auto"],
  [style*="overflow:auto"],
  [style*="overflow: auto"] {
    -webkit-overflow-scrolling: touch !important;
  }

  /* ==================== TYPOGRAPHY ==================== */

  h2 {
    font-size: 20px !important;
  }

  h3 {
    font-size: 17px !important;
  }

  /* ==================== LOADING OVERLAY ==================== */

  #loadingOverlay > div {
    width: 90% !important;
    max-width: 300px !important;
  }

  /* ==================== NOTIFICATION PANEL ==================== */

  [id*="notification"] {
    max-width: 100% !important;
    width: 100% !important;
    left: 0 !important;
    right: 0 !important;
  }

  /* ==================== LOGIN SCREEN MOBILE ==================== */
  
  /* Login ekranındaki "Erfolgreich" notification */
  .login-container .notification,
  .notification {
    position: fixed !important;
    top: auto !important;
    bottom: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    right: auto !important;
    z-index: 10000 !important;
    max-width: 90vw !important;
    border-radius: 12px !important;
    text-align: center !important;
  }
  
  /* Login toast overlay fix */
  .gv-toast {
    z-index: 100001 !important;
  }

  /* ==================== LIEFERANTEN PRODUKTE (Resim 1 Fix) ==================== */

  /* Product rows in Lieferanten panel: 2-row layout on mobile */
  #liefProductsList [style*="display:flex"][style*="border:1px"],
  #liefProductsList .lief-prod-row {
    flex-wrap: wrap !important;
    gap: 6px !important;
    padding: 10px 12px !important;
  }

  /* Product name: MUST show on full line */
  #liefProductsList [style*="flex:1"][style*="overflow:hidden"],
  #liefProductsList div[style*="flex:1;font-weight:600"],
  #liefProductsList div[style*="flex:1;font-weight:700"] {
    flex: 1 0 60% !important;
    min-width: 0 !important;
    font-size: 14px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Action buttons row: smaller */
  #liefProductsList button[title],
  #liefProductsList button[onclick*="showEdit"],
  #liefProductsList button[onclick*="moveProduct"],
  #liefProductsList button[onclick*="deleteLief"] {
    min-height: 32px !important;
    min-width: 32px !important;
    padding: 4px 6px !important;
    font-size: 13px !important;
    flex-shrink: 0 !important;
  }

  /* Supplier dropdown in product row: compact */
  #liefProductsList select[onchange*="moveProductToSupplier"] {
    font-size: 11px !important;
    padding: 4px 6px !important;
    min-height: 32px !important;
    max-width: 90px !important;
    flex-shrink: 0 !important;
  }

  /* Category rename button: keep small */
  #liefProductsList button[onclick*="showRenameCategory"] {
    min-height: 28px !important;
    padding: 2px 4px !important;
  }

  /* Lieferant detail panel: make scrollable */
  #lieferantDetailPanel {
    max-height: none !important;
    overflow-y: visible !important;
  }

  #lieferantDetailPanel [style*="max-height:calc"] {
    max-height: none !important;
    overflow-y: visible !important;
  }

  /* Lieferant header buttons: wrap */
  #lieferantDetailPanel [style*="display:flex"][style*="gap:8px"][style*="flex-wrap:wrap"] button {
    font-size: 12px !important;
    padding: 6px 10px !important;
  }

  /* ==================== DOKUMENTE (Resim 4 Fix) ==================== */

  /* Document file rows: prevent text overflow */
  #contentArea [style*="lohnabrechnung"],
  [style*="overflow:hidden"][style*="text-overflow:ellipsis"] {
    white-space: normal !important;
    word-break: break-all !important;
  }

  /* Document rows: ensure button visible */
  #contentArea div[style*="display:flex"][style*="border-bottom"] {
    flex-wrap: wrap !important;
    gap: 8px !important;
  }

  /* Öffnen button: ensure full visibility */
  #contentArea a[style*="background:linear-gradient"][style*="border-radius"],
  #contentArea button[style*="background:linear-gradient"][style*="Öffnen"],
  #contentArea [onclick*="openDoc"],
  #contentArea [onclick*="showPdf"] {
    min-width: 70px !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
  }

  /* ==================== KALENDER (Resim 2 Fix) ==================== */

  /* Calendar grid: fit within screen */
  [style*="grid-template-columns: repeat(7"] {
    font-size: 11px !important;
    gap: 2px !important;
    overflow-x: hidden !important;
  }

  /* Calendar cells */
  [style*="grid-template-columns: repeat(7"] > div {
    min-width: 0 !important;
    padding: 4px 2px !important;
    font-size: 12px !important;
  }

  /* Calendar container */
  [style*="overflow-x:auto"][style*="grid-template-columns: repeat(7"] {
    overflow-x: hidden !important;
    width: 100% !important;
  }

  /* ==================== ZURÜCK BUTTON (All screens Fix) ==================== */

  /* Global back button: better positioning */
  #globalBackBtn {
    left: 12px !important;
    top: auto !important;
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    padding: 10px 20px !important;
    font-size: 14px !important;
    border-radius: 50px !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15) !important;
    z-index: 8999 !important;
    background: white !important;
    opacity: 0.95 !important;
  }

  /* ==================== STUNDEN KORREKTUREN (Resim 3 Fix) ==================== */

  /* AZ-Nr badges: wrap if too long */
  [style*="background:#ddd6fe"][style*="border-radius"],
  [style*="background:#ede9fe"][style*="border-radius"] {
    word-break: break-all !important;
    white-space: normal !important;
    font-size: 11px !important;
    max-width: 140px !important;
  }

  /* Stunden request cards */
  [style*="border-left:4px solid"][style*="border-radius:16px"] {
    padding: 14px !important;
  }

  /* ==================== LOHN MANAGEMENT ==================== */

  /* Lohn kartları */
  [style*="grid-template-columns"][style*="minmax(200"] {
    grid-template-columns: 1fr !important;
  }

}

/* ==================== KÜÇÜK TELEFONLAR ==================== */
@media (max-width: 380px) {

  .mobile-bottom-nav .bnav-item .bnav-icon {
    font-size: 20px !important;
  }

  .mobile-bottom-nav .bnav-item {
    font-size: 9px !important;
  }

  .dashboard-grid,
  .stat-cards-grid {
    grid-template-columns: 1fr !important;
  }

  #adminAddStundenModal [style*="grid-template-columns:repeat(3"] {
    grid-template-columns: 1fr !important;
    gap: 4px !important;
  }

  /* ==================== NOTIFICATION MOBILE FIX ==================== */
  .notification {
    top: auto !important;
    bottom: 80px !important;
    right: 12px !important;
    left: 12px !important;
    text-align: center !important;
    font-size: 14px !important;
    padding: 12px 16px !important;
    border-radius: 12px !important;
  }

  /* ==================== ANFRAGEN TABS MOBILE ==================== */
  .request-tabs {
    flex-wrap: wrap !important;
    gap: 4px !important;
  }

  .request-tab {
    padding: 8px 12px !important;
    font-size: 13px !important;
  }

  /* ==================== ADMIN EINKAUF TABS MOBILE ==================== */
  #contentArea [style*="display:flex"][style*="gap:12px"][style*="margin-bottom:24px"] {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }

  #contentArea [style*="display:flex"][style*="gap:12px"][style*="margin-bottom:24px"] button {
    font-size: 13px !important;
    padding: 10px 8px !important;
  }

  /* ==================== CONTENT HEADER MOBILE ==================== */
  .content-header .content-title {
    font-size: 22px !important;
  }

  .content-header .content-subtitle {
    font-size: 13px !important;
  }

  /* ==================== GLOBAL BACK BUTTON ==================== */
  #globalBackBtn {
    left: 12px !important;
    top: auto !important;
    bottom: calc(72px + env(safe-area-inset-bottom)) !important;
    padding: 10px 20px !important;
    font-size: 14px !important;
    border-radius: 50px !important;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
    z-index: 8999 !important;
  }
}
