/**
 * 📱 Mobile Experience Enhancements
 * Time Tracker v2 - Fancy UI
 */

/* ========================================
   Mobile Base Optimizations
   ======================================== */
@media (max-width: 639px) {
  /* Größere Touch-Targets */
  .btn {
    min-height: 48px;
    padding: var(--space-3) var(--space-5);
  }

  .btn--icon {
    min-width: 48px;
    min-height: 48px;
  }

  /* Timer-Module Mobile Optimierung */
  .timer-module {
    margin: var(--space-3);
    padding: var(--space-5);
    border-radius: var(--radius-xl);
  }

  /* Timer Ring für Mobile anpassen */
  .timer-ring-container {
    margin: var(--space-2) auto;
  }

  .timer-ring {
    width: 200px;
    height: 200px;
  }

  .timer-ring-content__time {
    font-size: 2rem;
  }

  .timer-ring-content__percent {
    font-size: 0.875rem;
  }

  .timer-ring-content__label {
    font-size: 0.625rem;
  }

  /* Stats kompakter auf Mobile */
  .timer-stats {
    padding: var(--space-3);
    gap: var(--space-2);
  }

  .timer-stat__value {
    font-size: 1rem;
  }

  .timer-stat__label {
    font-size: 0.625rem;
  }

  /* Buttons auf Mobile */
  .timer-actions {
    gap: var(--space-2);
  }

  .timer-btn {
    padding: var(--space-4);
    font-size: 0.9375rem;
  }

  /* Progress Bar schlanker */
  .timer-progress__bar {
    height: 8px;
  }

  .timer-progress__text {
    font-size: 0.75rem;
  }
}

/* ========================================
   Bottom Navigation Enhancement
   ======================================== */
@media (max-width: 639px) {
  .bottom-nav {
    /* 💎 Glassmorphism Bottom Nav */
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.1);
  }

  [data-theme="dark"] .bottom-nav {
    background: rgba(20, 27, 45, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }

  .bottom-nav__item {
    min-height: 60px;
    padding: var(--space-2);
    transition: all var(--transition-fast);
  }

  .bottom-nav__item:active {
    transform: scale(0.95);
  }

  .bottom-nav__item--active {
    position: relative;
  }

  /* Aktiver Indikator */
  .bottom-nav__item--active::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
  }

  .bottom-nav__icon {
    font-size: 1.5rem;
  }

  .bottom-nav__label {
    font-size: 0.6875rem;
    margin-top: 2px;
  }
}

/* ========================================
   Mobile Header
   ======================================== */
@media (max-width: 639px) {
  .app-header {
    padding: var(--space-2) var(--space-3);
  }

  .app-header__title {
    font-size: 1.125rem;
  }

  /* Mini Timer kompakter */
  .mini-timer {
    padding: var(--space-1) var(--space-2);
    font-size: var(--text-xs);
  }

  .mini-timer__time {
    font-size: var(--text-sm);
    min-width: 60px;
  }

  .mini-timer__btn {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }
}

/* ========================================
   Mobile Cards & Lists
   ======================================== */
@media (max-width: 639px) {
  /* Dashboard Cards */
  .dashboard {
    gap: var(--space-3);
  }

  .dashboard__header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .dashboard__title {
    font-size: 1.25rem;
  }

  .dashboard__total-overtime {
    width: 100%;
    justify-content: center;
  }

  /* Entry Cards */
  .entry-card {
    padding: var(--space-3);
  }

  /* Settings */
  .settings-section {
    padding: var(--space-4);
  }
}

/* ========================================
   Pull to Refresh Enhancement
   ======================================== */
.pull-refresh {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1001;
  display: flex;
  justify-content: center;
  padding: var(--space-4);
  background: var(--gradient-primary);
  color: var(--text-inverse);
  transform: translateY(-100%);
  transition: transform var(--transition-smooth);
}

.pull-refresh--visible {
  transform: translateY(0);
}

.pull-refresh__content {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 500;
}

.pull-refresh__icon {
  animation: bounce 1s ease infinite;
}

@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* ========================================
   Swipe Actions (für Entry Cards)
   ======================================== */
.swipe-container {
  position: relative;
  overflow: hidden;
}

.swipe-actions {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.swipe-container.swiped .swipe-actions {
  opacity: 1;
}

.swipe-action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 70px;
  color: var(--text-inverse);
  font-size: 1.25rem;
}

.swipe-action--edit {
  background: var(--color-primary);
}

.swipe-action--delete {
  background: var(--color-danger);
}

/* ========================================
   Mobile Modal Adjustments
   ======================================== */
@media (max-width: 639px) {
  .modal__container {
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    border-radius: 0;
    border-top-left-radius: var(--radius-xl);
    border-top-right-radius: var(--radius-xl);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    transform: translateY(100%);
    transition: transform var(--transition-smooth);
  }

  .modal--open .modal__container {
    transform: translateY(0);
  }

  .modal__header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--surface-border);
  }

  /* Drag Handle für Bottom Sheet */
  .modal__container::before {
    content: "";
    position: absolute;
    top: var(--space-2);
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--surface-border);
    border-radius: var(--radius-full);
  }

  .modal__body {
    padding: var(--space-4);
    padding-top: var(--space-6);
    max-height: 70vh;
    overflow-y: auto;
  }

  .modal__footer {
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  }
}

/* ========================================
   Touch Feedback
   ======================================== */
@media (max-width: 639px) {
  /* Aktive States für Touch */
  .btn:active,
  .card:active,
  .bottom-nav__item:active {
    opacity: 0.9;
  }

  /* Disable hover on touch devices */
  @media (hover: none) {
    .btn:hover {
      transform: none;
      box-shadow: inherit;
    }

    .card--glass:hover {
      transform: none;
    }

    .timer-module:hover {
      box-shadow: 0 10px 40px rgba(var(--color-primary-rgb), 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.8);
    }
  }
}

/* ========================================
   Safe Area Padding
   ======================================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .app-main {
    padding-bottom: calc(70px + env(safe-area-inset-bottom));
  }

  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ========================================
   Landscape Mode Adjustments
   ======================================== */
@media (max-width: 639px) and (orientation: landscape) {
  .timer-ring {
    width: 160px;
    height: 160px;
  }

  .timer-ring-content__time {
    font-size: 1.5rem;
  }

  .timer-stats {
    display: flex;
    flex-direction: row;
  }

  .timer-stat {
    flex: 1;
  }
}
