/* ═══════════════════════════════════════════════════════════════
   Planski – Mobile App CSS
   ═══════════════════════════════════════════════════════════════ */

:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-h: 64px;
  --header-h: 54px;
}

@media (min-width: 769px) {
  .hamburger { display: none !important; }
  #mobile-header { display: none !important; }
  #bottom-nav { display: none !important; }
  #more-drawer { display: none !important; }
  #more-overlay { display: none !important; }
}

@media (max-width: 768px) {
  input, select, textarea { font-size: 16px !important; }
  body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }

  #sidebar { display: none !important; }
  .hamburger { display: none !important; }

  /* MOBILE HEADER */
  #mobile-header {
    display: flex;
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    padding-top: var(--safe-top);
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    align-items: center;
    padding-left: 18px;
    padding-right: 18px;
    z-index: 100;
    gap: 12px;
  }
  #mobile-header .mh-logo {
    display: flex; align-items: center; gap: 8px;
    font-size: 17px; font-weight: 800; color: #0f172a;
    text-decoration: none; flex: 1;
  }
  #mobile-header .mh-lm {
    width: 28px; height: 28px; background: #1d4ed8;
    border-radius: 7px; display: flex;
    align-items: center; justify-content: center; flex-shrink: 0;
  }
  #mobile-header .mh-lm svg { width: 14px; height: 14px; }
  #mobile-header .mh-title { font-size: 15px; font-weight: 700; color: #0f172a; }
  #mobile-header .mh-action {
    width: 36px; height: 36px; border-radius: 9px; border: none;
    background: #f1f5f9; display: flex; align-items: center;
    justify-content: center; cursor: pointer; flex-shrink: 0;
  }
  #mobile-header .mh-action svg { width: 18px; height: 18px; fill: none; stroke: #334155; stroke-width: 2; }

  /* MAIN */
  #main {
    margin-left: 0 !important;
    padding-top: calc(var(--header-h) + var(--safe-top) + 8px) !important;
    padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 16px) !important;
    min-height: 100dvh;
  }
  #content { padding: 0 !important; }
  .section { padding: 14px 14px 6px !important; }

  /* BOTTOM NAV */
  #bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #fff;
    border-top: 1px solid #e2e8f0;
    z-index: 200;
    box-shadow: 0 -4px 20px rgba(0,0,0,.07);
  }
  .bn-item {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    cursor: pointer; border: none; background: transparent; padding: 0;
    color: #94a3b8; font-family: inherit;
    transition: color .15s; -webkit-tap-highlight-color: transparent;
    position: relative;
  }
  .bn-item.active { color: #1d4ed8; }
  .bn-item.active::before {
    content: ''; position: absolute; top: 7px;
    width: 4px; height: 4px; border-radius: 50%; background: #1d4ed8;
  }
  .bn-item svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }
  .bn-item.active svg { stroke-width: 2.3; }
  .bn-item span { font-size: 10px; font-weight: 600; letter-spacing: -.01em; }
  .bn-item:active { opacity: .55; transform: scale(.9); transition: none; }

  /* MORE DRAWER */
  #more-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,.4); z-index: 198; backdrop-filter: blur(2px);
  }
  #more-overlay.open { display: block; }
  #more-drawer {
    display: none; position: fixed;
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
    left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    border-radius: 20px 20px 0 0;
    z-index: 199;
    padding: 10px 10px 16px;
    box-shadow: 0 -8px 32px rgba(0,0,0,.1);
  }
  #more-drawer.open { display: block; }
  #more-drawer .drawer-handle {
    width: 36px; height: 4px; background: #e2e8f0;
    border-radius: 2px; margin: 0 auto 14px;
  }
  #more-drawer .drawer-section-title {
    font-size: 10.5px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .08em; color: #94a3b8; padding: 0 4px; margin-bottom: 6px;
  }
  .drawer-grid {
    display: grid; grid-template-columns: repeat(4,1fr); gap: 4px;
    margin-bottom: 8px;
  }
  .dg-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 12px 6px; border-radius: 12px; cursor: pointer;
    border: none; background: transparent; font-family: inherit;
    -webkit-tap-highlight-color: transparent; transition: background .12s;
  }
  .dg-item:active { background: #f1f5f9; transform: scale(.94); }
  .dg-icon {
    width: 46px; height: 46px; border-radius: 13px;
    background: #f1f5f9; display: flex; align-items: center;
    justify-content: center; font-size: 22px;
  }
  .dg-item span { font-size: 11px; font-weight: 600; color: #374151; text-align: center; line-height: 1.3; }

  /* CARDS */
  .card { border-radius: 14px !important; margin-bottom: 12px !important; }

  /* STATS */
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .stat-card { padding: 13px !important; border-radius: 12px !important; }
  .stat-value { font-size: 21px !important; }
  .stat-label { font-size: 11.5px !important; }
  .stat-sub { font-size: 11px !important; }

  /* SECTION HEADER */
  .section-header {
    flex-direction: column !important; align-items: flex-start !important;
    gap: 10px !important; margin-bottom: 14px !important;
  }
  .section-header h2 { font-size: 20px !important; }
  .section-header > div:last-child { width: 100%; display: flex; flex-wrap: wrap; gap: 6px; }
  .section-header .btn { flex: 1; min-width: 0; justify-content: center; text-align: center; }

  /* TABLES */
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .data-table { font-size: 13px !important; }

  /* MODALS: bottom sheet style */
  #modal-overlay { align-items: flex-end !important; padding: 0 !important; }
  .modal-box {
    width: 100% !important; max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    max-height: 92dvh !important; overflow-y: auto !important;
    margin: 0 !important;
    padding-bottom: calc(var(--safe-bottom) + 8px) !important;
  }

  /* FORMS */
  .form-grid-2 { grid-template-columns: 1fr !important; }
  .form-group { margin-bottom: 14px !important; }
  .input { height: 46px !important; font-size: 16px !important; border-radius: 10px !important; }
  textarea.input { height: auto !important; min-height: 80px !important; }

  /* BUTTONS */
  .btn { min-height: 40px; border-radius: 9px !important; }
  .btn-primary { min-height: 46px !important; font-size: 15px !important; }
  .modal-footer {
    flex-direction: column-reverse !important; gap: 8px !important; padding: 16px !important;
  }
  .modal-footer .btn { width: 100% !important; justify-content: center; }

  /* TOAST: boven bottom nav */
  #toast-container {
    bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 12px) !important;
    left: 14px !important; right: 14px !important;
  }
  .toast { border-radius: 12px !important; }

  /* TABLE TOOLBAR */
  .table-toolbar { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
  .table-toolbar > div { flex-wrap: wrap !important; }

  /* QUICK ACTION BUTTONS */
  .dash-greeting { font-size: 21px !important; }

  /* TOUCH STATES */
  @media (hover: none) {
    .stat-card:hover { transform: none !important; }
  }
}

@media (max-width: 380px) {
  .drawer-grid { grid-template-columns: repeat(3,1fr) !important; }
  .stat-value { font-size: 18px !important; }
  .section { padding: 12px 12px 4px !important; }
}
