/* ═══════════════════════════════════════════════════
   PLATFORM MOBILE OPTIMIZATIONS
   Specific improvements for platform.css components
   ═══════════════════════════════════════════════════ */

/* ─────────────────────────────────────
   MOBILE SIDEBAR IMPROVEMENTS (≤640px)
───────────────────────────────────── */
@media (max-width: 640px) {
  /* Sidebar overflow handling */
  .sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .sb-brand {
    padding: 1rem 0.875rem;
  }

  .sb-logo {
    gap: 0.5rem;
  }

  .sb-logo span {
    font-size: 0.875rem;
  }

  .sb-wordmark {
    font-size: 1.1rem;
  }

  /* Navigation items */
  .sb-nav {
    padding: 0.5rem;
  }

  .sb-nav-item {
    padding: 0.625rem 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
  }

  .sb-nav-item i {
    width: 18px;
    height: 18px;
  }

  /* User section */
  .sb-user-section {
    padding: 0.75rem 0.5rem;
  }

  .sb-user-card {
    gap: 0.5rem;
    padding: 0.625rem;
  }

  .sb-av {
    width: 28px;
    height: 28px;
  }

  .sb-name {
    font-size: 0.75rem;
  }

  .sb-sub {
    font-size: 0.65rem;
  }

  /* Dividers */
  .sb-divider {
    margin: 0.375rem 0.5rem;
  }
}

/* ─────────────────────────────────────
   MOBILE TOPBAR IMPROVEMENTS (≤640px)
───────────────────────────────────── */
@media (max-width: 640px) {
  .top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 40;
    height: 52px;
    padding: 0 0.75rem;
    gap: 0.4rem;
  }

  .top-search {
    display: none;
  }

  /* Make top actions more compact */
  .top-actions {
    gap: 0.25rem;
    margin-left: auto;
  }

  .notif-btn,
  .top-av {
    width: 32px;
    height: 32px;
  }

  /* Language toggle - Responsive */
  .premium-lang-toggle {
    padding: 2px;
  }

  .pl-btn {
    font-size: 0.65rem;
    padding: 0.25rem 0.5rem;
  }

  /* Profile dropdown positioning */
  .profile-dropdown {
    right: 0;
    top: 52px;
  }
}

/* ─────────────────────────────────────
   MOBILE PAGE CONTENT (≤640px)
───────────────────────────────────── */
@media (max-width: 640px) {
  .page-wrapper {
    padding-top: 52px;
  }

  .page-content {
    padding: 1rem 0.875rem;
    width: 100%;
  }

  /* Heading section */
  .page-heading {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
  }

  .page-heading h1 {
    font-size: 1.5rem;
    margin: 0;
  }

  .page-heading-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .page-heading button {
    flex: 1;
    min-width: 100px;
  }

  /* Tables - Horizontal scroll on mobile */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -0.875rem;
    padding: 0 0.875rem;
  }

  table {
    font-size: 0.8125rem;
    width: 100%;
    min-width: 600px;
  }

  /* Filter section */
  .filter-section {
    padding: 1rem;
    background: var(--surface);
    border-radius: 8px;
    margin-bottom: 1rem;
  }

  .filter-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .filter-row input,
  .filter-row select {
    width: 100%;
  }

  /* Cards */
  .card {
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .card-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }

  /* Dashboard specific */
  .dash-shell,
  .mp-shell {
    grid-template-columns: 1fr !important;
    gap: 1rem;
  }

  .kpi-strip {
    grid-template-columns: 1fr !important;
    gap: 0.75rem;
  }

  .kpi-card {
    padding: 1rem;
  }

  .kpi-label {
    font-size: 0.75rem;
  }

  .kpi-value {
    font-size: 1.25rem;
  }

  /* Modal improvements */
  .modal {
    width: 100% !important;
    height: 100% !important;
    max-height: 100vh;
    border-radius: 12px 12px 0 0;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
  }

  .modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
  }

  .modal-content {
    padding: 1rem;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
  }

  .modal-footer button {
    flex: 1;
  }

  /* Forms on mobile */
  .form-group {
    margin-bottom: 1rem;
  }

  .form-label {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    display: block;
  }

  .form-control {
    width: 100%;
    padding: 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 16px; /* Prevent zoom */
  }

  .form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(35, 83, 71, 0.12);
  }

  .input-group {
    display: flex;
    gap: 0.5rem;
  }

  .input-group input {
    flex: 1;
  }

  /* Buttons */
  .btn {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 44px;
  }

  .btn-primary {
    background: var(--accent);
    color: white;
    width: 100%;
  }

  .btn-primary:active {
    opacity: 0.9;
  }

  .btn-secondary {
    background: var(--surface-2);
    color: var(--ink);
    width: 100%;
  }

  /* Dropdowns */
  .dropdown-panel {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: none !important;
    border-radius: 12px 12px 0 0 !important;
    bottom: 0 !important;
    top: auto !important;
    z-index: 100 !important;
  }
}

/* ─────────────────────────────────────
   TABLET OPTIMIZATIONS (641px - 1024px)
───────────────────────────────────── */
@media (641px <= width <= 1024px) {
  .top-bar {
    padding: 0 1rem;
  }

  .page-content {
    padding: 1.25rem;
  }

  .page-heading h1 {
    font-size: 1.75rem;
  }

  .card {
    padding: 1.25rem;
  }

  /* Grid adjustments */
  .dash-shell,
  .mp-shell {
    grid-template-columns: 1fr !important;
  }

  .kpi-strip {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Sidebar on tablet */
  .sidebar {
    width: 240px;
  }

  .sidebar.open {
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.2);
  }
}

/* ─────────────────────────────────────
   DESKTOP OPTIMIZATIONS (≥1025px)
───────────────────────────────────── */
@media (min-width: 1025px) {
  .page-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem 2rem;
  }

  /* Grid full width */
  .grid-3 {
    grid-template-columns: 1fr 1fr 1fr !important;
  }

  /* Modals - centered */
  .modal {
    max-width: 600px !important;
    margin: 0 auto !important;
    border-radius: 12px !important;
    top: 50% !important;
    bottom: auto !important;
    transform: translateY(-50%);
  }

  /* Dropdowns - positioned */
  .dropdown-panel {
    position: absolute !important;
    bottom: auto !important;
    top: 100% !important;
    width: auto !important;
    border-radius: 8px !important;
  }
}

/* ─────────────────────────────────────
   UNIVERSAL IMPROVEMENTS
───────────────────────────────────── */

/* Text overflow handling */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Images - Responsive */
.image-responsive {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Aspect ratio boxes */
.aspect-ratio {
  position: relative;
  overflow: hidden;
  width: 100%;
}

.aspect-ratio.ratio-square {
  aspect-ratio: 1;
}

.aspect-ratio.ratio-16-9 {
  aspect-ratio: 16 / 9;
}

.aspect-ratio > * {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Touch-friendly spacing */
@media (pointer: coarse) {
  .nav-link,
  .tab-item,
  .list-item {
    padding: 0.75rem 1rem;
    min-height: 44px;
  }
}

/* Smooth transitions */
* {
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}

/* Focus visible for accessibility */
button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
