/**
 * Responsive Design Styles - FFXP-51
 *
 * Mobile-first responsive design for FXBook.
 *
 * Breakpoints:
 * - Mobile: < 640px
 * - Tablet: 640px - 1024px
 * - Desktop: > 1024px
 */

/* ============================================
   CSS Custom Properties for Responsive
   ============================================ */
:root {
  --mobile-padding: 12px;
  --tablet-padding: 16px;
  --desktop-padding: 20px;

  --mobile-font-size: 14px;
  --tablet-font-size: 14px;
  --desktop-font-size: 14px;
}

/* ============================================
   Mobile First Base Styles (< 640px)
   ============================================ */

/* Body adjustments for mobile */
@media (max-width: 640px) {
  body {
    font-size: var(--mobile-font-size);
  }

  /* Menu Bar - Compact */
  #menubar {
    height: 44px;
    padding: 0 10px;
  }

  .menu-left,
  .menu-center,
  .menu-right {
    gap: 8px;
  }

  .menu-item {
    padding: 6px 10px;
    font-size: 13px;
  }

  .app-title {
    font-size: 14px;
  }

  /* Hide some menu items on mobile */
  .menu-center {
    display: none;
  }

  /* Start Menu - Full Width */
  .start-menu {
    left: 10px;
    right: 10px;
    width: auto;
    max-width: none;
    top: 44px;
  }

  .start-menu-item {
    padding: 14px 16px;
  }

  /* User Menu - Full Width */
  .user-menu {
    right: 10px;
    left: 10px;
    width: auto;
  }

  /* Windows - Full Screen on Mobile */
  .window {
    position: fixed !important;
    top: 44px !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 40px !important;
    width: 100% !important;
    height: auto !important;
    min-width: 100%;
    min-height: auto;
    border-radius: 0;
    z-index: 100;
  }

  .window.active {
    z-index: 200;
  }

  .window-header {
    padding: 10px 12px;
    border-radius: 0;
  }

  .window-title {
    font-size: 13px;
    max-width: 60%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .window-controls {
    gap: 4px;
  }

  .window-control {
    width: 32px;
    height: 32px;
  }

  /* Hide minimize/maximize on mobile - windows are always fullscreen */
  .window-control.minimize,
  .window-control.maximize {
    display: none;
  }

  .window-content {
    padding: var(--mobile-padding);
    overflow-x: hidden;
  }

  /* Hide resize handle on mobile */
  .window-resize-handle {
    display: none;
  }

  /* Taskbar - Compact */
  #taskbar {
    height: 40px;
    padding: 0 8px;
  }

  #taskbar-items {
    gap: 4px;
  }

  .taskbar-item {
    padding: 6px 10px;
    font-size: 12px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .taskbar-right {
    gap: 8px;
  }

  .taskbar-status {
    font-size: 11px;
  }

  /* Forms - Full Width */
  .form-group {
    margin-bottom: 16px;
  }

  .form-input,
  .form-select {
    padding: 12px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Tables - Horizontal Scroll */
  .table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(-1 * var(--mobile-padding));
    padding: 0 var(--mobile-padding);
  }

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

  .data-table th,
  .data-table td {
    padding: 10px 8px;
    font-size: 12px;
  }

  /* Cards/Panels - Full Width */
  .card,
  .panel {
    margin: 0 0 12px 0;
    border-radius: 8px;
  }

  /* Buttons - Larger Touch Targets */
  .btn,
  button {
    min-height: 44px;
    padding: 10px 16px;
  }

  /* Grid - Single Column */
  .grid,
  .dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  /* Login Screen - Adjusted */
  .login-box {
    padding: 24px;
    margin: 10px;
    max-width: none;
  }

  .login-box h2 {
    font-size: 22px;
  }

  /* Notifications - Full Width */
  #notifications {
    left: 10px;
    right: 10px;
    width: auto;
  }

  .notification {
    width: 100%;
  }
}

/* ============================================
   Tablet Styles (640px - 1024px)
   ============================================ */

@media (min-width: 641px) and (max-width: 1024px) {
  body {
    font-size: var(--tablet-font-size);
  }

  /* Menu Bar */
  #menubar {
    height: 46px;
    padding: 0 15px;
  }

  /* Start Menu - Wider */
  .start-menu {
    width: 320px;
  }

  /* Windows - Resizable but with constraints */
  .window {
    min-width: 350px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 120px);
  }

  .window-content {
    padding: var(--tablet-padding);
  }

  /* Taskbar */
  #taskbar {
    height: 42px;
  }

  .taskbar-item {
    max-width: 150px;
  }

  /* Tables */
  .table-container {
    overflow-x: auto;
  }

  .data-table {
    min-width: 500px;
  }

  /* Grid - 2 Columns */
  .grid,
  .dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }

  /* Login Box */
  .login-box {
    padding: 36px;
    max-width: 420px;
  }
}

/* ============================================
   Desktop Styles (> 1024px)
   ============================================ */

@media (min-width: 1025px) {
  body {
    font-size: var(--desktop-font-size);
  }

  .window-content {
    padding: var(--desktop-padding);
  }

  /* Grid - Auto-fit columns */
  .grid,
  .dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
  }
}

/* ============================================
   Large Desktop Styles (> 1440px)
   ============================================ */

@media (min-width: 1441px) {
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */

@media (pointer: coarse) {
  /* Larger touch targets */
  .menu-item,
  .start-menu-item,
  .user-menu-item,
  .taskbar-item {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  .window-control {
    min-width: 44px;
    min-height: 44px;
  }

  /* Disable hover effects on touch */
  .menu-item:hover,
  .start-menu-item:hover,
  .taskbar-item:hover {
    background: inherit;
  }

  .menu-item:active,
  .start-menu-item:active,
  .taskbar-item:active {
    background: rgba(255, 255, 255, 0.2);
  }
}

/* ============================================
   Landscape Mobile Adjustments
   ============================================ */

@media (max-width: 900px) and (orientation: landscape) {
  #menubar {
    height: 40px;
  }

  .window {
    top: 40px !important;
    bottom: 36px !important;
  }

  #taskbar {
    height: 36px;
  }
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
  #menubar,
  #taskbar,
  .start-menu,
  .user-menu,
  .window-controls,
  .window-resize-handle {
    display: none !important;
  }

  .window {
    position: static !important;
    width: 100% !important;
    height: auto !important;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    page-break-inside: avoid;
  }

  .window-header {
    background: #f0f0f0 !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body {
    background: white !important;
  }
}

/* ============================================
   Utility Classes
   ============================================ */

/* Hide on specific breakpoints */
.hide-mobile {
  display: none;
}

.hide-tablet {
  display: block;
}

.hide-desktop {
  display: block;
}

@media (min-width: 641px) {
  .hide-mobile {
    display: block;
  }

  .hide-tablet {
    display: none;
  }
}

@media (min-width: 1025px) {
  .hide-tablet {
    display: block;
  }

  .hide-desktop {
    display: none;
  }
}

/* Show only on specific breakpoints */
.show-mobile {
  display: block;
}

.show-tablet {
  display: none;
}

.show-desktop {
  display: none;
}

@media (min-width: 641px) and (max-width: 1024px) {
  .show-mobile {
    display: none;
  }

  .show-tablet {
    display: block;
  }
}

@media (min-width: 1025px) {
  .show-mobile {
    display: none;
  }

  .show-desktop {
    display: block;
  }
}

/* Responsive text alignment */
.text-center-mobile {
  text-align: center;
}

@media (min-width: 641px) {
  .text-center-mobile {
    text-align: inherit;
  }
}

/* Stack elements on mobile */
.stack-mobile {
  display: flex;
  flex-direction: column;
}

@media (min-width: 641px) {
  .stack-mobile {
    flex-direction: row;
  }
}

/* Full width on mobile */
.full-width-mobile {
  width: 100%;
}

@media (min-width: 641px) {
  .full-width-mobile {
    width: auto;
  }
}

/* Container with responsive padding */
.container-responsive {
  padding: var(--mobile-padding);
}

@media (min-width: 641px) {
  .container-responsive {
    padding: var(--tablet-padding);
  }
}

@media (min-width: 1025px) {
  .container-responsive {
    padding: var(--desktop-padding);
  }
}
