/**
 * TASKMATE - Responsive Styles
 * ============================
 * Mobile und Tablet Anpassungen
 */

/* ========================================
   GLOBALE RESPONSIVE ANPASSUNGEN
   ======================================== */

/* Verhindere horizontales Scrollen */
html {
  overflow-x: hidden;
  width: 100%;
}

body {
  overflow-x: hidden;
  width: 100%;
  margin: 0;
  padding: 0;
}

/* App Container */
.app {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* Hauptcontainer */
.main {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  position: relative;
}

/* Alle Views */
.view {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Verhindere Überlauf bei allen Elementen */
* {
  max-width: 100%;
}

/* Responsive Box-Sizing für alle Elemente */
* {
  box-sizing: border-box;
}

/* ========================================
   TABLET (max 1024px)
   ======================================== */

@media (max-width: 1024px) {
  :root {
    --column-width: 280px;
    --column-min-width: 260px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-row {
    grid-template-columns: 1fr;
  }

  .shortcuts-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   MEDIUM SCREENS (max 1200px)
   ======================================== */

@media (max-width: 1200px) {
  /* Header-Anpassungen für mittlere Bildschirme */
  .header {
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .header-left {
    gap: var(--spacing-sm);
  }

  .header-right {
    gap: var(--spacing-sm);
  }

  /* Project Selector schmaler */
  .project-select {
    max-width: 200px;
  }

  /* Search Container schmaler */
  .search-container {
    max-width: 200px;
  }

  /* Navigation tabs - kompakter und zentriert bei mittleren Bildschirmen */
  .view-tabs {
    gap: var(--spacing-xs);
    flex-wrap: nowrap;
    justify-content: center;
  }

  .view-tab {
    padding: 6px 8px;
    font-size: 11px;
    flex-shrink: 0;
  }

  /* Modals anpassen */
  .modal {
    margin: var(--spacing-md);
  }

  .modal-large {
    max-width: calc(100vw - 32px);
  }

  /* Tabellen responsiv */
  table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ========================================
   SMALL TABLET (max 768px)
   ======================================== */

@media (max-width: 768px) {
  .header {
    display: flex;
    align-items: center;
    height: 60px;
    padding: 0 var(--spacing-sm);
    gap: var(--spacing-xs);
    overflow: hidden;
  }

  .header-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
  }

  .view-tabs-bar {
    display: none; /* Navigation wird ins Mobile Menu verschoben */
  }

  .header-right {
    flex: 0 0 auto;
  }

  .logo {
    font-size: var(--text-base);
  }

  .project-selector {
    display: none;
  }

  .search-container {
    display: none;
  }

  /* Mobile Navigation wird über Hamburger Menu gesteuert */
  .mobile-menu {
    display: block;
  }
  
  /* Logo kleiner auf Mobile */
  .logo {
    font-size: var(--text-lg);
  }

  .filter-bar-actions {
    display: none;
  }

  .view-board {
    padding: var(--spacing-md);
    gap: var(--spacing-md);
  }

  /* Mobile Board - One column at a time */
  .board-container {
    overflow-x: hidden !important;
    scroll-snap-type: none !important;
    width: 100%;
    padding: 0;
  }

  .column {
    width: 100%;
    min-width: unset;
    max-width: 100%;
    max-height: calc(100vh - 200px);
    margin: 0;
    padding: var(--spacing-sm);
    box-sizing: border-box;
  }

  .column.mobile-active {
    display: flex !important;
  }

  .btn-add-column {
    width: 100%;
    min-width: unset;
    min-height: 100px;
    margin: 0;
    box-sizing: border-box;
  }

  /* Hide scrollbar in mobile board */
  .board-container::-webkit-scrollbar {
    display: none;
  }

  /* Fix for views in mobile */
  .view.active {
    display: flex !important;
  }

  /* List view mobile adjustments */
  .view-list.active {
    padding: var(--spacing-sm);
  }

  .list-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
  }

  .list-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .list-view-toggle {
    justify-content: center;
  }

  .list-sort {
    margin-left: 0;
    justify-content: space-between;
  }

  /* Table responsive */
  .list-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .list-table {
    min-width: 600px;
  }

  /* Calendar view mobile adjustments */
  .view-calendar {
    padding: var(--spacing-sm);
  }

  .calendar-header {
    flex-direction: column;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
  }

  .calendar-nav {
    width: 100%;
    justify-content: space-between;
  }

  .calendar-actions {
    width: 100%;
    justify-content: center;
  }

  .calendar-grid {
    font-size: var(--text-xs);
  }

  .calendar-day-header {
    padding: var(--spacing-sm);
  }

  .calendar-day {
    min-height: 60px;
    padding: var(--spacing-xs);
  }

  .calendar-task {
    font-size: 9px;
    padding: 1px 2px;
  }

  .modal {
    width: calc(100% - 16px);
    max-height: calc(100vh - 32px);
  }

  .modal-large {
    max-width: none;
  }

  .add-link-form {
    flex-direction: column;
  }

  .attachments-container {
    grid-template-columns: repeat(2, 1fr);
  }

  .task-table th,
  .task-table td {
    padding: var(--spacing-sm);
  }

  .col-labels {
    display: none;
  }

  .bulk-actions {
    flex-wrap: wrap;
  }

  .calendar-day {
    min-height: 80px;
  }

  .calendar-task {
    font-size: 10px;
    padding: 1px 4px;
  }
}

/* ========================================
   MOBILE (max 480px)
   ======================================== */

@media (max-width: 480px) {
  .header-right {
    gap: var(--spacing-xs);
  }

  .connection-status .status-text {
    display: none;
  }

  .user-dropdown {
    right: -50px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: var(--spacing-md);
  }

  .stat-icon {
    width: 48px;
    height: 48px;
  }

  .stat-icon svg {
    width: 24px;
    height: 24px;
  }

  .stat-value {
    font-size: var(--text-xl);
  }

  .view-calendar {
    padding: var(--spacing-sm);
  }

  .calendar-header {
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }

  .calendar-header h2 {
    flex: 1;
    min-width: auto;
    font-size: var(--text-base);
  }

  .calendar-weekday {
    padding: var(--spacing-xs);
    font-size: var(--text-xs);
  }

  .calendar-day {
    padding: var(--spacing-xs);
    min-height: 60px;
  }

  .calendar-day-number {
    width: 24px;
    height: 24px;
    font-size: var(--text-xs);
  }

  .calendar-day-tasks {
    display: none;
  }

  .calendar-day.has-tasks::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
    margin: var(--spacing-xs) auto 0;
  }

  .calendar-day.has-overdue::after {
    background: var(--error);
  }

  .modal-footer {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .modal-footer-left,
  .modal-footer-right {
    width: 100%;
    justify-content: center;
  }

  .time-estimate-inputs {
    flex-wrap: wrap;
  }

  .attachments-container {
    grid-template-columns: 1fr;
  }

  .toast-container {
    left: var(--spacing-md);
    right: var(--spacing-md);
    bottom: var(--spacing-md);
    bottom: calc(var(--spacing-md) + env(safe-area-inset-bottom, 0px));
  }

  .toast {
    width: 100%;
  }
}

/* ========================================
   REDUCED MOTION
   ======================================== */

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

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .header,
  .view-tabs-bar,
  .btn-add-column,
  .column-actions,
  .btn-add-task,
  .modal,
  .modal-overlay,
  .toast-container,
  .onboarding-overlay {
    display: none !important;
  }

  body {
    background: white;
    color: black;
  }

  .app {
    display: block;
  }

  .board {
    display: block;
  }

  .column {
    display: block;
    width: 100%;
    max-height: none;
    page-break-inside: avoid;
    margin-bottom: 20px;
    border: 1px solid #ccc;
  }

  .task-card {
    page-break-inside: avoid;
    border: 1px solid #ddd;
    margin-bottom: 10px;
  }
}

/* ========================================
   HIGH CONTRAST
   ======================================== */

@media (prefers-contrast: high) {
  :root {
    --border-default: rgba(255, 255, 255, 0.3);
  }

  .light-mode {
    --border-default: rgba(0, 0, 0, 0.3);
  }

  .task-card,
  .column,
  .modal,
  .dropdown-menu {
    border-width: 2px;
  }
}
