/*
 * MOBILE RESPONSIVENESS CSS - APPLE-LEVEL DESIGN
 * Complete mobile optimization with Apple HIG standards
 */

/* Base mobile optimizations */
@media (max-width: 1024px) {
  /* Tablet optimizations */
  .kanban-column {
    min-width: 280px;
    padding: 16px;
  }

  .kanban-column h3 {
    font-size: 18px;
    margin-bottom: 12px;
  }

  [data-task-id] {
    padding: 14px 16px;
    margin-bottom: 12px;
  }

  .task-title {
    font-size: 15px;
    line-height: 1.4;
  }

  .task-description {
    font-size: 13px;
    line-height: 1.4;
  }

  /* Form adjustments */
  .modal {
    width: 90%;
    max-width: 600px;
    margin: 5% auto;
  }

  input, textarea, select {
    font-size: 16px; /* Prevent zoom on iOS */
    padding: 14px 16px;
    border-radius: 12px;
  }

  button {
    min-height: 44px;
    padding: 12px 20px;
    font-size: 15px;
  }
}

@media (max-width: 768px) {
  /* Small tablet / large mobile */
  .container {
    padding: 16px 12px;
  }

  .kanban-board {
    gap: 12px;
    padding: 16px 0;
  }

  .kanban-column {
    min-width: 260px;
    padding: 14px;
    border-radius: 16px;
  }

  .kanban-column h3 {
    font-size: 16px;
    margin-bottom: 10px;
  }

  [data-task-id] {
    padding: 12px 14px;
    margin-bottom: 10px;
    border-radius: 12px;
  }

  .task-title {
    font-size: 14px;
    margin-bottom: 6px;
  }

  .task-description {
    font-size: 12px;
    line-height: 1.3;
  }

  /* Navigation adjustments */
  .nav-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav-title {
    font-size: 20px;
  }

  .nav-actions {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* Modal improvements */
  .modal {
    width: 95%;
    max-width: none;
    margin: 2% auto;
    border-radius: 20px;
  }

  .modal-content {
    padding: 20px;
  }

  .modal-header h2 {
    font-size: 20px;
  }

  .modal-footer {
    flex-direction: column;
    gap: 12px;
  }

  .modal-footer button {
    width: 100%;
    order: 1;
  }

  .modal-footer .btn-secondary {
    order: 2;
  }

  /* Form improvements */
  .form-group {
    margin-bottom: 16px;
  }

  label {
    font-size: 14px;
    margin-bottom: 6px;
  }

  input, textarea, select {
    font-size: 16px;
    padding: 14px 16px;
    border-radius: 12px;
    width: 100%;
  }

  textarea {
    min-height: 120px;
    resize: vertical;
  }

  /* Button improvements */
  button {
    min-height: 48px;
    padding: 14px 20px;
    font-size: 16px;
    border-radius: 12px;
    font-weight: 600;
  }

  .btn-small {
    min-height: 40px;
    padding: 10px 16px;
    font-size: 14px;
  }

  /* Filter and sort controls */
  .filters-container {
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: rgba(248, 250, 252, 0.8);
    border-radius: 16px;
    margin-bottom: 16px;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .filter-group label {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 4px;
  }

  /* Export controls */
  .export-controls {
    flex-direction: column;
    gap: 12px;
  }

  .export-format-selection {
    flex-direction: column;
    gap: 8px;
  }

  .export-format-option {
    padding: 12px 16px;
    border-radius: 12px;
    text-align: center;
  }
}

@media (max-width: 480px) {
  /* Mobile phone optimizations */
  body {
    font-size: 14px;
  }

  .container {
    padding: 12px 8px;
  }

  /* Kanban adjustments for mobile */
  .kanban-board {
    flex-direction: column;
    gap: 16px;
    padding: 12px 0;
  }

  .kanban-column {
    width: 100%;
    min-width: auto;
    padding: 16px;
    border-radius: 20px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  }

  .kanban-column h3 {
    font-size: 18px;
    margin-bottom: 12px;
    text-align: center;
    font-weight: 700;
  }

  .kanban-column-count {
    font-size: 13px;
    background: rgba(59, 130, 246, 0.1);
    color: #3b82f6;
    padding: 4px 8px;
    border-radius: 8px;
    margin-left: 8px;
    font-weight: 600;
  }

  /* Task cards for mobile */
  [data-task-id] {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
    transition: all 0.2s ease;
  }

  [data-task-id]:hover,
  [data-task-id]:focus {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    border-color: rgba(59, 130, 246, 0.3);
  }

  .task-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
    color: #1f2937;
  }

  .task-description {
    font-size: 14px;
    line-height: 1.4;
    color: #6b7280;
    margin-bottom: 12px;
  }

  .task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-size: 12px;
  }

  .task-priority {
    padding: 4px 8px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .task-priority.high {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
  }

  .task-priority.medium {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
  }

  .task-priority.low {
    background: rgba(34, 197, 94, 0.1);
    color: #059669;
  }

  .task-deadline {
    color: #6b7280;
    font-size: 12px;
  }

  .task-deadline.overdue {
    color: #dc2626;
    font-weight: 600;
  }

  .task-deadline.due-soon {
    color: #d97706;
    font-weight: 600;
  }

  /* Navigation for mobile */
  .nav-header {
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
  }

  .nav-title {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    color: #1f2937;
  }

  .nav-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
  }

  .nav-actions button {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
  }

  /* Modal for mobile */
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  .modal-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
  }

  .modal-header {
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
  }

  .modal-header h2 {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
  }

  .modal-body {
    flex: 1;
    overflow-y: auto;
  }

  .modal-footer {
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-top: 20px;
    flex-direction: column;
    gap: 12px;
  }

  .modal-footer button {
    width: 100%;
    min-height: 52px;
  }

  .modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
  }

  /* Form improvements for mobile */
  .form-group {
    margin-bottom: 20px;
  }

  label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
  }

  input, textarea, select {
    width: 100%;
    font-size: 16px;
    padding: 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    transition: all 0.2s ease;
  }

  input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }

  textarea {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
  }

  /* Button improvements for mobile */
  .btn-primary {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    font-weight: 600;
    text-transform: none;
    letter-spacing: 0.025em;
  }

  .btn-primary:hover {
    background: linear-gradient(135deg, #2563eb, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  }

  .btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    font-weight: 600;
  }

  .btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
  }

  .btn-danger {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    border: none;
    font-weight: 600;
  }

  .btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  }

  /* Filter controls for mobile */
  .filters-container {
    background: rgba(248, 250, 252, 0.9);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(0, 0, 0, 0.06);
  }

  .filter-group {
    margin-bottom: 16px;
  }

  .filter-group:last-child {
    margin-bottom: 0;
  }

  .filter-group label {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 6px;
  }

  .filter-select {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid #d1d5db;
    background: white;
    font-size: 15px;
  }

  /* Search input for mobile */
  .search-input {
    width: 100%;
    padding: 14px 16px 14px 44px;
    border-radius: 20px;
    border: 2px solid #e5e7eb;
    background: white;
    font-size: 16px;
    position: relative;
  }

  .search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }

  .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 18px;
  }

  /* Floating action button for mobile */
  .fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    z-index: 1000;
    transition: all 0.2s ease;
  }

  .fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  }

  .fab:active {
    transform: scale(0.95);
  }

  /* Swipe actions for mobile */
  .swipe-actions {
    position: absolute;
    top: 0;
    right: -100px;
    height: 100%;
    width: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ef4444;
    border-radius: 0 16px 16px 0;
    opacity: 0;
    transition: all 0.3s ease;
  }

  .swipe-actions.active {
    opacity: 1;
    right: 0;
  }

  .swipe-actions button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Progress indicators for mobile */
  .progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    margin: 12px 0;
  }

  .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    border-radius: 3px;
    transition: width 0.3s ease;
  }

  /* Status indicators */
  .status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 8px;
  }

  .status-indicator.todo {
    background: #9ca3af;
  }

  .status-indicator.in-progress {
    background: #3b82f6;
  }

  .status-indicator.under-review {
    background: #f59e0b;
  }

  .status-indicator.completed {
    background: #10b981;
  }

  /* Notification adjustments for mobile */
  .notification-container {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
  }

  .notification {
    margin-bottom: 8px;
    border-radius: 12px;
    padding: 16px;
  }

  /* Analytics charts for mobile */
  .chart-container {
    width: 100%;
    height: 250px;
    margin-bottom: 20px;
    border-radius: 16px;
    background: white;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }

  /* Template cards for mobile */
  .template-card {
    background: white;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }

  .template-card h4 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
  }

  .template-card p {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 12px;
  }

  .template-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #9ca3af;
  }
}

/* Landscape phone optimizations */
@media (max-width: 767px) and (orientation: landscape) {
  .kanban-board {
    flex-direction: row;
    overflow-x: auto;
    padding: 16px;
  }

  .kanban-column {
    flex: 0 0 280px;
    width: 280px;
    height: calc(100vh - 120px);
    overflow-y: auto;
  }

  .modal {
    width: 90%;
    height: 85%;
    border-radius: 20px;
    margin: auto;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
  }
}

/* Touch-specific optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger touch targets */
  button,
  [role="button"],
  a,
  input[type="checkbox"],
  input[type="radio"],
  [data-task-id] {
    min-height: 44px;
    min-width: 44px;
  }

  /* Hover states for touch */
  [data-task-id]:active,
  button:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  /* Disable hover animations */
  * {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
  }

  .kanban-column li[data-task-id]:hover {
    transform: none;
    box-shadow: inherit;
  }

  /* Touch-friendly scrollbars */
  .kanban-column {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .kanban-column::-webkit-scrollbar {
    width: 4px;
  }

  .kanban-column::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 2px;
  }
}

/* High DPI / Retina display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  /* Sharper borders and shadows */
  [data-task-id],
  .modal,
  .kanban-column {
    border-width: 0.5px;
  }

  .kanban-column {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }

  [data-task-id] {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  }
}

/* Safe area optimizations for newer iPhones */
@supports (padding: max(0px)) {
  .nav-header {
    padding-top: max(16px, env(safe-area-inset-top));
  }

  .fab {
    bottom: max(24px, env(safe-area-inset-bottom) + 24px);
    right: max(24px, env(safe-area-inset-right) + 24px);
  }

  .modal {
    padding-top: max(0px, env(safe-area-inset-top));
    padding-bottom: max(0px, env(safe-area-inset-bottom));
  }
}

/* Dark mode mobile optimizations */
@media (prefers-color-scheme: dark) {
  @media (max-width: 480px) {
    .kanban-column {
      background: rgba(31, 41, 55, 0.95);
      border: 1px solid rgba(75, 85, 99, 0.3);
    }

    [data-task-id] {
      background: rgba(17, 24, 39, 0.95);
      border: 1px solid rgba(55, 65, 81, 0.3);
      color: #f9fafb;
    }

    .task-title {
      color: #f9fafb;
    }

    .task-description {
      color: #d1d5db;
    }

    .nav-header {
      background: rgba(17, 24, 39, 0.95);
      border-bottom-color: rgba(75, 85, 99, 0.3);
    }

    .modal {
      background: rgba(17, 24, 39, 0.98);
      color: #f9fafb;
    }

    .filters-container {
      background: rgba(31, 41, 55, 0.9);
      border-color: rgba(75, 85, 99, 0.3);
    }

    input, textarea, select {
      background: rgba(31, 41, 55, 0.8);
      border-color: rgba(75, 85, 99, 0.5);
      color: #f9fafb;
    }

    input:focus, textarea:focus, select:focus {
      border-color: #60a5fa;
    }
  }
}