/* ═══════════════════════════════════════════
   SOCIALYN MOBILE STYLES v3
   Aktiv <= 768px - Redesign
   ═══════════════════════════════════════════ */

:root {
  --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);
  --bottom-nav-height: 62px;
  --mobile-header-height: 52px;
  --mobile-radius: 14px;
  --mobile-radius-sm: 10px;
}

@media all and (display-mode: standalone) {
  body { overscroll-behavior-y: contain; }
}

/* ═══════════════════════════════════════════
   MOBILE LAYOUT (<= 768px)
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {

  html, body {
    font-size: 15px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
  }
  * { -webkit-tap-highlight-color: transparent; }

  /* ─────────────────────────────
     MOBILE HEADER-BALKEN oben
     Hamburger + Client-Name + Monat-Nav
     ───────────────────────────── */
  #mobileHeader {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--safe-top) + var(--mobile-header-height));
    padding: var(--safe-top) 10px 0 10px;
    background: var(--bg-elevated, #1a1c21);
    border-bottom: 1px solid var(--border, #3a3c41);
    z-index: 9996;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  }

  /* Hamburger im Header integriert (nicht mehr floating) */
  #mobileHamburger {
    position: static !important;
    width: 36px !important;
    height: 36px !important;
    flex-shrink: 0;
    box-shadow: none !important;
    background: transparent !important;
    border: none !important;
    font-size: 22px !important;
  }

  #mobileHeaderCenter {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
  }
  .mh-client {
    font-size: 15px;
    font-weight: 700;
    color: var(--ink, #fff);
    letter-spacing: -0.01em;
    max-width: 130px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .mh-month {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg, #2a2c31);
    border-radius: 8px;
    padding: 4px 6px;
    border: 1px solid var(--border, #3a3c41);
  }
  .mh-month button {
    background: none;
    border: none;
    color: var(--ink-sec, #999);
    padding: 2px 6px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    min-height: 26px;
    display: flex;
    align-items: center;
  }
  .mh-month-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink, #fff);
    min-width: 65px;
    text-align: center;
  }

  #mobileHeaderRight {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-sec, #999);
    font-size: 20px;
    cursor: pointer;
    background: transparent;
    border: none;
  }

  /* ─────────────────────────────
     APP-CONTAINER
     ───────────────────────────── */
  .app, .layout, .main-layout, body > div:first-child {
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
  }

  #mainContent, main, .main-content, .content-area {
    margin-left: 0 !important;
    padding: calc(var(--safe-top) + var(--mobile-header-height) + 12px) 12px calc(var(--bottom-nav-height) + var(--safe-bottom) + 12px) 12px !important;
    width: 100% !important;
    min-height: 100vh;
  }

  /* ─────────────────────────────
     SIDEBAR (off-canvas)
     ───────────────────────────── */
  .sidebar, .s-nav, aside, [class*="sidebar"] {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 9998;
    padding-top: calc(var(--safe-top) + 60px);
    padding-bottom: calc(var(--safe-bottom) + 12px);
    overflow-y: auto;
    box-shadow: 4px 0 30px rgba(0,0,0,0.4);
  }
  .sidebar.open, .s-nav.open, aside.open {
    transform: translateX(0);
  }

  #mobileSidebarClose {
    display: flex !important;
    position: absolute;
    top: calc(var(--safe-top) + 14px);
    right: 14px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated, #2a2c31);
    color: var(--ink-sec, #999);
    border-radius: 50%;
    border: 1px solid var(--border, #3a3c41);
    font-size: 20px;
    cursor: pointer;
    z-index: 9999;
    line-height: 1;
  }
  #mobileSidebarClose:active { background: var(--border, #3a3c41); }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.55);
    z-index: 9997;
    animation: fadeIn 0.2s ease;
  }
  .sidebar-backdrop.open { display: block; }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

  /* ─────────────────────────────
     BOTTOM-NAV
     ───────────────────────────── */
  #mobileBottomNav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-elevated, #1a1c21);
    border-top: 1px solid var(--border, #3a3c41);
    z-index: 9995;
    justify-content: space-around;
    align-items: stretch;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.3);
  }
  #mobileBottomNav .mnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--ink-sec, #999);
    font-size: 10px;
    font-weight: 500;
    padding: 6px 4px;
    min-height: 44px;
    background: transparent;
    border: none;
  }
  #mobileBottomNav .mnav-item:active { transform: scale(0.92); }
  #mobileBottomNav .mnav-item.active { color: var(--accent, #f5c063); }
  #mobileBottomNav .mnav-icon { font-size: 22px; line-height: 1; }

  /* ─────────────────────────────
     PAGE-HEADER kompakt
     ───────────────────────────── */
  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 10px;
    padding: 0 !important;
    margin-bottom: 14px;
  }
  .page-header > div:first-child {
    display: block;
  }
  .page-header > div:last-child {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }
  .page-title {
    font-size: 22px !important;
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -0.02em;
  }
  .page-sub {
    font-size: 12px;
    color: var(--ink-sec, #999);
    margin-top: 2px;
  }

  /* AGENCYHOME-Label ausblenden auf Mobile (das ist der oberste Client-Selector-Text) */
  .agencyhome-label,
  [class*="agency-label"] {
    display: none !important;
  }

  /* Alte Client-Selector-Bar (die wir durch mobileHeader ersetzt haben) verstecken */
  .client-selector-bar,
  [class*="client-bar"],
  #clientSelectorBar {
    display: none !important;
  }

  /* ─────────────────────────────
     BUTTONS
     ───────────────────────────── */
  .btn {
    min-height: 40px;
    padding: 10px 16px;
    font-size: 14px;
    border-radius: 10px;
    font-weight: 600;
  }
  .btn:active { transform: scale(0.97); }
  .btn.btn-sm {
    min-height: 36px;
    padding: 8px 14px;
    font-size: 13px;
    border-radius: 8px;
  }

  /* ─────────────────────────────
     INPUTS
     ───────────────────────────── */
  input, textarea, select, .form-input {
    font-size: 16px !important;
    min-height: 46px;
    padding: 12px 14px;
    border-radius: 10px;
  }
  textarea.form-input { min-height: 100px; }
  .form-label {
    font-size: 11px !important;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink-sec, #999);
    text-transform: uppercase;
    letter-spacing: 0.03em;
  }

  /* ─────────────────────────────
     CARDS
     ───────────────────────────── */
  .card {
    border-radius: var(--mobile-radius);
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
    overflow: hidden;
  }
  .card-header {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .card-title {
    font-size: 14px;
    font-weight: 700;
  }

  /* ─────────────────────────────
     KPI-KACHELN in 2-Spalten-Grid (auch wenn agency-home ohne class rendert)
     ───────────────────────────── */
  .kpi-grid-auto, .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    padding: 0 !important;
    margin-bottom: 12px !important;
  }
  .kpi {
    padding: 14px 12px !important;
    border-radius: 12px;
    background: var(--bg-elevated, #2a2c31);
    border: 1px solid var(--border, #3a3c41);
    min-height: 84px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    justify-content: center;
  }
  .kpi-label {
    font-size: 10px !important;
    font-weight: 600;
    color: var(--ink-sec, #999);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }
  .kpi-val {
    font-size: 22px !important;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
  }

  /* AGENCY-HOME: Stat-Cards (inline styles) auch als 2er-Grid */
  #agencyHomeContent > div[style*="grid-template-columns:repeat(auto-fit"],
  #agencyHomeContent > div[style*="grid-template-columns: repeat(auto-fit"] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
  /* Agency stat-cards kompakter */
  #agencyHomeContent .card[style*="padding:14px"] {
    padding: 12px !important;
  }
  #agencyHomeContent .card[style*="padding:14px"] > div[style*="font-size:24px"] {
    font-size: 22px !important;
  }

  /* AGENCY-HOME Grid-Layout (Kalender + Todos) → vertikal */
  #agencyHomeContent > div[style*="minmax(0,2fr)"],
  #agencyHomeContent > div[style*="minmax(0, 2fr)"] {
    grid-template-columns: 1fr !important;
    min-height: unset !important;
  }
  #agencyHomeContent {
    height: auto !important;
    min-height: unset !important;
    padding: 0 !important;
  }
  /* Karten in agency-home flexen nicht mehr auf volle Höhe */
  #agencyHomeContent .card[style*="height:100%"] {
    height: auto !important;
  }
  #agencyHomeContent .card > div[style*="flex:1"][style*="min-height:0"] {
    flex: none !important;
    min-height: unset !important;
    overflow: visible !important;
  }

  /* ─────────────────────────────
     MODAL Fullscreen
     ───────────────────────────── */
  .modal-overlay, .modal-backdrop {
    padding: 0 !important;
    align-items: stretch !important;
  }
  .modal, .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    padding: calc(var(--safe-top) + 20px) 16px calc(var(--safe-bottom) + 20px) 16px !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 16px;
    padding-right: 40px;
  }
  .modal-actions {
    flex-direction: column-reverse;
    gap: 10px;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border, #3a3c41);
  }
  .modal-actions .btn { width: 100%; }

  /* ─────────────────────────────
     TABELLEN scrollbar
     ───────────────────────────── */
  .tbl, table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 13px;
  }

  /* ─────────────────────────────
     SUB-TABS
     ───────────────────────────── */
  .sub-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    gap: 6px;
  }
  .sub-tabs::-webkit-scrollbar { display: none; }
  .sub-tab {
    flex-shrink: 0;
    padding: 8px 14px;
    font-size: 13px;
    min-height: 36px;
    border-radius: 8px;
  }

  /* ─────────────────────────────
     GRIDS single column
     ───────────────────────────── */
  div[style*="grid-template-columns:1fr 1fr"]:not(#agencyHomeContent > div),
  div[style*="grid-template-columns: 1fr 1fr"]:not(#agencyHomeContent > div) {
    grid-template-columns: 1fr !important;
  }

  /* Top-Videos-Card mobil */
  .card > div[onclick*="showContentDetail"] {
    padding: 12px !important;
    gap: 10px !important;
    flex-wrap: wrap;
  }
  .card > div[onclick*="showContentDetail"] > div:last-child {
    flex-basis: 100%;
    justify-content: space-between !important;
    padding-top: 8px;
    border-top: 1px dashed var(--border, #3a3c41);
    margin-top: 4px;
    gap: 8px !important;
  }
  .card > div[onclick*="showContentDetail"] > div:last-child > div {
    min-width: auto !important;
    flex: 1;
    text-align: center;
  }
  .card > div[onclick*="showContentDetail"] > div:last-child > div > div:first-child {
    font-size: 18px !important;
  }

  /* Empty-States */
  .empty {
    padding: 24px 20px !important;
    text-align: center;
  }
  .empty-text {
    font-size: 13px;
    color: var(--ink-sec, #999);
  }
}

/* ═══════════════════════════════════════════
   DESKTOP: Mobile-Elemente verstecken
   ═══════════════════════════════════════════ */
@media (min-width: 769px) {
  #mobileBottomNav,
  #mobileHamburger,
  #mobileSidebarClose,
  #mobileHeader,
  .sidebar-backdrop {
    display: none !important;
  }
}


/* ═══════════════════════════════════════════
   MOBILE MONTH CALENDAR WIDGET (unverändert)
   ═══════════════════════════════════════════ */

.mcal {
  width: 100%;
  background: var(--bg-elevated, #2a2c31);
  border-radius: var(--mobile-radius, 14px);
  padding: 12px 12px 16px 12px;
  border: 1px solid var(--border, #3a3c41);
  margin-bottom: 16px;
}

.mcal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 4px 4px 12px 4px;
}
.mcal-title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink, #fff);
}
.mcal-nav {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink, #fff);
  border: 1px solid var(--border, #3a3c41);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mcal-nav:active {
  background: var(--border, #3a3c41);
  transform: scale(0.94);
}
.mcal-add {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent, #f5c063);
  color: #000;
  border: none;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  margin-left: 4px;
}

.mcal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 4px;
}
.mcal-weekday {
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-sec, #999);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 6px 0;
}

.mcal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-bottom: 12px;
}
.mcal-cell {
  aspect-ratio: 1 / 1;
  border: none;
  background: transparent;
  color: var(--ink, #fff);
  border-radius: 10px;
  padding: 4px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  min-height: 42px;
}
.mcal-cell:active { transform: scale(0.94); }
.mcal-cell.mcal-out { color: var(--ink-faint, #555); }
.mcal-cell.mcal-today .mcal-day-num {
  color: var(--accent, #f5c063);
  font-weight: 700;
}
.mcal-cell.mcal-selected {
  background: var(--accent, #f5c063);
  color: #000 !important;
}
.mcal-cell.mcal-selected .mcal-day-num { color: #000 !important; }
.mcal-cell.mcal-selected .mcal-dots { filter: brightness(0.5); }

.mcal-day-num { font-size: 14px; line-height: 1; }
.mcal-dots {
  display: flex;
  gap: 3px;
  align-items: center;
  justify-content: center;
  min-height: 6px;
}
.mcal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.mcal-daylist {
  border-top: 1px solid var(--border, #3a3c41);
  padding-top: 14px;
  margin-top: 8px;
}
.mcal-daylist-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink, #fff);
  margin-bottom: 12px;
}
.mcal-item {
  background: var(--bg, #1a1c21);
  border-left: 3px solid var(--accent, #f5c063);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  cursor: pointer;
}
.mcal-item:active { transform: scale(0.98); }
.mcal-item-client {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.mcal-item-topic {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink, #fff);
  margin-bottom: 6px;
}
.mcal-item-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.mcal-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-elevated, #2a2c31);
  color: var(--ink-sec, #999);
  border: 1px solid var(--border, #3a3c41);
}
.mcal-plats, .mcal-status {
  font-size: 11px;
  color: var(--ink-sec, #999);
}
.mcal-empty {
  padding: 24px 12px;
  text-align: center;
  color: var(--ink-sec, #999);
  font-size: 13px;
  font-style: italic;
}
