/* ==============================================
   NIST CSF Assessment - Responsive Mobile Styles
   ============================================== */

/* Mobile-first approach with progressive enhancement */

/* Base mobile styles (< 640px) */
@media (max-width: 640px) {
  /* Container adjustments */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* Typography scaling */
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  h3 {
    font-size: 1.25rem;
  }
  
  /* Navigation */
  nav {
    padding: 0.75rem 1rem;
  }
  
  nav .nav-item {
    font-size: 0.875rem;
    padding: 0.5rem 0.75rem;
  }
  
  /* Cards */
  .card,
  .assessment-card {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  /* Buttons */
  button,
  .btn {
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  button.btn-sm,
  .btn-sm {
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
  }
  
  /* Tables */
  table {
    font-size: 0.875rem;
  }
  
  table th,
  table td {
    padding: 0.5rem;
  }
  
  /* Make tables horizontally scrollable */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  /* Forms */
  input,
  select,
  textarea {
    font-size: 16px; /* Prevents zoom on iOS */
    padding: 0.75rem;
  }
  
  label {
    font-size: 0.875rem;
  }
  
  /* Modals */
  .modal-content {
    width: 95%;
    max-width: 95%;
    margin: 1rem;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .modal-content.large {
    width: 95%;
  }
  
  /* Dashboard grid */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Stats cards */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  /* Assessment list */
  .assessments-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  /* Hide on mobile */
  .hide-mobile {
    display: none !important;
  }
  
  /* Show only on mobile */
  .show-mobile {
    display: block !important;
  }
  
  /* Framework cards */
  .frameworks-grid {
    grid-template-columns: 1fr;
  }
  
  /* Charts */
  .chart-container {
    height: 250px;
    overflow-x: auto;
  }
  
  canvas {
    max-width: 100%;
    height: auto !important;
  }
  
  /* Assessment detail header */
  .assessment-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .assessment-header .button-group {
    width: 100%;
    margin-top: 1rem;
  }
  
  /* Executive Dashboard modal on mobile */
  #executiveDashboardModal .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
  
  /* Score gauge smaller on mobile */
  #scoreGauge {
    max-width: 200px;
    max-height: 200px;
  }
  
  /* Stacked layout for framework breakdown */
  .framework-breakdown {
    flex-direction: column;
  }
  
  /* Touch-friendly spacing */
  .touch-target {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Pagination */
  .pagination {
    font-size: 0.875rem;
  }
  
  .pagination button {
    padding: 0.5rem;
    width: auto;
    margin: 0 0.25rem;
  }
}

/* Tablet styles (641px - 1024px) */
@media (min-width: 641px) and (max-width: 1024px) {
  /* Two-column layout for cards */
  .assessments-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }
  
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }
  
  .frameworks-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  /* Adjust modal size */
  .modal-content {
    width: 85%;
    max-width: 700px;
  }
  
  /* Charts */
  .chart-container {
    height: 300px;
  }
}

/* Landscape phone adjustments */
@media (max-width: 896px) and (orientation: landscape) {
  /* Reduce vertical spacing in landscape */
  .py-8 {
    padding-top: 1rem;
    padding-bottom: 1rem;
  }
  
  .py-6 {
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
  }
  
  /* Modals take full screen in landscape */
  .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    margin: 0;
    border-radius: 0;
  }
}

/* Specific component responsive adjustments */

/* Assessment detail panel on mobile */
@media (max-width: 640px) {
  #assessment-detail {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: white;
    overflow-y: auto;
  }
  
  .assessment-detail-header {
    position: sticky;
    top: 0;
    background: white;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 1rem;
  }
}

/* NIST 800-53 assessment interface mobile */
@media (max-width: 640px) {
  .control-card {
    padding: 0.75rem;
  }
  
  .control-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .control-actions {
    width: 100%;
    margin-top: 0.5rem;
  }
  
  .maturity-slider {
    width: 100%;
  }
  
  .baseline-badges {
    flex-wrap: wrap;
    gap: 0.25rem;
  }
}

/* Dashboard charts responsive */
@media (max-width: 768px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
  
  .chart-card {
    margin-bottom: 1rem;
  }
}

/* Score display responsive */
@media (max-width: 640px) {
  .score-display {
    font-size: 2rem;
  }
  
  .score-label {
    font-size: 0.875rem;
  }
  
  .rating-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
  }
}

/* Navigation responsive */
@media (max-width: 768px) {
  .main-nav {
    flex-direction: column;
  }
  
  .nav-links {
    width: 100%;
    flex-direction: column;
  }
  
  .nav-links a {
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #e5e7eb;
  }
}

/* Print styles */
@media print {
  /* Hide navigation and actions */
  nav,
  .btn,
  button,
  .no-print {
    display: none !important;
  }
  
  /* Expand content */
  .container {
    max-width: 100%;
    padding: 0;
  }
  
  /* Ensure charts print well */
  canvas {
    max-width: 100%;
    height: auto;
  }
  
  /* Page breaks */
  .page-break {
    page-break-after: always;
  }
  
  /* Prevent orphans */
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  /* Black and white optimization */
  * {
    color: #000 !important;
    background: #fff !important;
  }
  
  .card,
  .assessment-card {
    border: 1px solid #000;
    box-shadow: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  * {
    border-width: 2px;
  }
  
  button,
  .btn {
    border: 2px solid currentColor;
  }
  
  .card,
  .assessment-card {
    border: 2px solid #000;
  }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --border-color: #404040;
  }
  
  /* Apply dark mode styles when implemented */
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
  /* Larger tap targets */
  button,
  .btn,
  a {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* Remove hover effects on touch devices */
  *:hover {
    transform: none;
  }
  
  /* Better touch feedback */
  button:active,
  .btn:active {
    opacity: 0.7;
  }
}

/* Responsive utilities */
.mobile-only {
  display: none;
}

@media (max-width: 640px) {
  .mobile-only {
    display: block;
  }
  
  .desktop-only {
    display: none;
  }
}

/* Flex utilities for mobile */
@media (max-width: 640px) {
  .mobile-flex-col {
    flex-direction: column;
  }
  
  .mobile-full-width {
    width: 100%;
  }
  
  .mobile-text-center {
    text-align: center;
  }
}
