/* ========================================
   Meu AC4 - Responsive Styles
   Mobile-first responsive design
   ======================================== */

/* ==================== Smartphones (default) ==================== */
/* Already optimized for mobile in style.css */

/* ==================== Extra Small Devices ==================== */
@media (max-width: 320px) {
  .page-title {
    font-size: 18px;
  }
  
  .card-value {
    font-size: 15px;
  }
  
  .card-icon {
    width: 40px;
    height: 40px;
    font-size: 22px;
  }
  
  .dashboard-cards {
    gap: 8px;
  }
  
  .calendar-cell {
    min-height: 56px;
    padding: 4px 2px;
  }
  
  .calendar-day-number {
    font-size: 12px;
    width: 20px;
    height: 20px;
    line-height: 20px;
  }
  
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  
  .type-selector {
    grid-template-columns: 1fr;
  }
  
  .type-indicator {
    flex-direction: row;
    padding: var(--space-sm) var(--space-md);
  }
  
  .login-features {
    grid-template-columns: 1fr;
  }
  
  .sim-results-summary {
    grid-template-columns: 1fr;
  }
  
  .sim-results-actions {
    flex-direction: column;
  }
}

/* ==================== Small to Medium Phones ==================== */
@media (min-width: 321px) and (max-width: 375px) {
  .dashboard-cards {
    gap: 10px;
  }
  
  .calendar-cell {
    min-height: 65px;
  }
  
  .sim-results-summary {
    gap: var(--space-sm);
  }
}

/* ==================== Tablets ==================== */
@media (min-width: 481px) and (max-width: 768px) {
  :root {
    --max-width: 100%;
  }
  
  .dashboard-cards {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .calendar-cell {
    min-height: 90px;
    padding: 8px;
  }
  
  .calendar-day-value {
    font-size: 12px;
  }
  
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
  
  .type-selector {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ==================== Desktops ==================== */
@media (min-width: 769px) {
  :root {
    --max-width: 420px;
  }
  
  .app-shell {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
  }
  
  .app-header {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  
  .bottom-nav {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
  
  .nav-item:hover {
    color: var(--primary);
  }
  
  .card:hover {
    transform: translateY(-2px);
  }
  
  .scale-item:hover {
    transform: translateX(4px);
  }
  
  .report-card:hover {
    transform: translateX(8px);
  }
}

/* ==================== Large Desktops ==================== */
@media (min-width: 1024px) {
  :root {
    --max-width: 460px;
  }
  
  body::before {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 40%, #0f0a14 100%);
  }
  
  .app-shell {
    background: transparent;
  }
}

/* ==================== Landscape Orientation ==================== */
@media (orientation: landscape) and (max-height: 500px) {
  :root {
    --header-height: 48px;
    --nav-height: 56px;
  }
  
  .page-header {
    margin-bottom: var(--space-md);
  }
  
  .page-title {
    font-size: 18px;
  }
  
  .dashboard-cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  
  .card {
    padding: var(--space-sm);
  }
  
  .card-icon {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
  
  .card-value {
    font-size: 15px;
  }
  
  .calendar-cell {
    min-height: 48px;
    padding: 4px;
  }
  
  .login-page {
    min-height: auto;
    padding: var(--space-md);
  }
  
  .login-header {
    margin-bottom: var(--space-md);
  }
  
  .login-logo {
    margin-bottom: var(--space-sm);
  }
  
  .logo-icon {
    font-size: 36px;
  }
  
  .login-title {
    font-size: 22px;
  }
  
  .login-features {
    display: none;
  }
  
  .form-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==================== Notch / Dynamic Island ==================== */
@supports (padding-top: env(safe-area-inset-top)) {
  .app-header {
    padding-top: calc(var(--space-sm) + env(safe-area-inset-top));
  }
  
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ==================== Reduced Motion ==================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  html {
    scroll-behavior: auto;
  }
}

/* ==================== High Contrast ==================== */
@media (prefers-contrast: high) {
  :root {
    --border: #64748b;
    --text-muted: #475569;
  }
  
  .card,
  .scale-item,
  .form-input {
    border-width: 2px;
  }
}

/* ==================== Print ==================== */
@media print {
  .app-header,
  .bottom-nav,
  .btn,
  .fab {
    display: none !important;
  }
  
  .app-shell {
    padding-top: 0;
    padding-bottom: 0;
    max-width: 100%;
  }
  
  #main-content {
    padding: 0;
  }
  
  .card,
  .static-content,
  .form-card {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
  
  .calendar-cell {
    break-inside: avoid;
  }
}

/* ==================== Touch Optimization ==================== */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .nav-item,
  .scale-item,
  .report-card {
    cursor: default;
    -webkit-tap-highlight-color: transparent;
  }
  
  .btn:active,
  .nav-item:active,
  .scale-item:active {
    transform: scale(0.97);
  }
  
  .form-input,
  .search-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }
}

/* ==================== Dark Mode Specific Overrides ==================== */
body.dark-mode .card:hover {
  border-color: var(--primary-dark);
}

body.dark-mode .btn-google {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}

body.dark-mode .btn-google:hover {
  background: var(--bg);
}

body.dark-mode .static-content {
  background: var(--bg-elevated);
}

body.dark-mode .calendar-cell.today {
  background: rgba(59, 130, 246, 0.15);
}

body.dark-mode .sim-stat {
  background: var(--bg);
}

body.dark-mode .login-card {
  background: var(--bg-elevated);
}

/* ==================== Loading States ==================== */
.loading-shimmer {
  background: linear-gradient(
    90deg,
    var(--border) 0%,
    var(--bg) 50%,
    var(--border) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ==================== Scrollbar Styling ==================== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ==================== Selection ==================== */
::selection {
  background: var(--primary);
  color: white;
}

/* ==================== Focus Visible ==================== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}
