﻿/**
 * TrackTms - Global Responsive Styles
 * Responsywność dla wszystkich stron i komponentów
 */

/* ========================================
   GLOBAL TOUCH TARGETS & BUTTONS
   ======================================== */

/* Minimalna wielkość dotykowa - 44x44px dla mobile */
.btn,
.nav-item,
.sidebar-toggle,
.dropdown-item,
.card-action,
.table-action,
.action-btn,
.icon-btn,
.mobile-back-btn,
button[onclick],
a.nav-item,
.tab,
.tab-btn,
.filter-btn,
[role="button"],
input[type="submit"],
input[type="button"] {
  min-height: 44px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Aktywny stan dla touch */
.btn:active,
.nav-item:active,
.card:active,
.dropdown-item:active {
  transform: scale(0.98);
  transition: transform 0.1s;
}

/* ========================================
   SIDEBAR RESPONSIVE
   ======================================== */

/* Mobile toggle button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1001;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-primary);
  box-shadow: var(--shadow-md);
  border: none;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* Tablet: 768px - 1024px */
@media (max-width: 1024px) {
  .sidebar {
    width: 80px;
  }
  
  .sidebar .sidebar-logo-text,
  .sidebar .nav-item-text,
  .sidebar .nav-section-title,
  .sidebar .sidebar-footer {
    display: none;
  }
  
  .sidebar .nav-item {
    justify-content: center;
    padding: var(--space-3);
  }
  
  .sidebar .nav-item-icon {
    margin: 0;
  }
  
  .main-content {
    margin-left: 80px;
  }
  
  .sidebar.expanded {
    width: 260px;
  }
  
  .sidebar.expanded .sidebar-logo-text,
  .sidebar.expanded .nav-item-text,
  .sidebar.expanded .nav-section-title {
    display: block;
  }
  
  .sidebar.expanded .nav-item {
    justify-content: flex-start;
    padding: var(--space-3) var(--space-4);
  }
}

/* Mobile: < 768px */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
  
  .sidebar {
    position: fixed;
    left: -280px;
    width: 280px !important;
    height: 100vh;
    height: 100dvh;
    transition: left 0.3s ease, transform 0.3s ease;
    z-index: 1000;
    transform: none !important;
  }
  
  .sidebar.open {
    left: 0;
    transform: none !important;
  }
  
  .sidebar .sidebar-logo-text,
  .sidebar .nav-item-text,
  .sidebar .nav-section-title,
  .sidebar .sidebar-footer {
    display: block;
  }
  
  .sidebar .nav-item {
    justify-content: flex-start;
    padding: var(--space-3) var(--space-4);
  }
  
  .main-content {
    margin-left: 0;
    padding-top: 60px;
  }
}

/* ========================================
   HEADER RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .header-title {
    font-size: var(--text-lg);
  }
  
  .header-actions {
    width: 100%;
    justify-content: space-between;
    margin-top: var(--space-2);
  }
  
  .header-search {
    flex: 1;
    max-width: none;
  }
  
  .user-menu .user-info {
    display: none;
  }
  
  .language-selector select {
    font-size: 0;
    width: 40px;
    padding-right: 0;
  }

  /* .top-header mobile */
  .top-header {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }
  .top-header h1,
  .top-header .header-title {
    font-size: var(--text-lg);
  }
  .top-header .header-right {
    width: 100%;
    justify-content: flex-end;
  }
  .top-header .header-search-inline {
    min-width: 0;
    flex: 1;
  }
}

/* ========================================
   GRID RESPONSIVE
   ======================================== */

/* Stats Grid */
.stats-grid,
.dashboard-stats {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 1200px) {
  .stats-grid,
  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px) {
  .stats-grid,
  .dashboard-stats {
    grid-template-columns: 1fr;
  }
}

/* Card Grid */
.card-grid,
.report-cards {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

@media (max-width: 600px) {
  .card-grid,
  .report-cards {
    grid-template-columns: 1fr;
  }
}

/* Two Column Layout */
.two-column {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 992px) {
  .two-column {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   TABLE RESPONSIVE
   ======================================== */

.data-table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
  .data-table {
    font-size: var(--text-sm);
  }
  
  .data-table th,
  .data-table td {
    padding: var(--space-2) var(--space-3);
    white-space: nowrap;
  }
  
  /* Hide less important columns on mobile */
  .data-table .hide-mobile {
    display: none;
  }
}

/* Card-style table for mobile */
@media (max-width: 600px) {
  .table-responsive-cards .data-table,
  .table-responsive-cards .data-table thead,
  .table-responsive-cards .data-table tbody,
  .table-responsive-cards .data-table th,
  .table-responsive-cards .data-table td,
  .table-responsive-cards .data-table tr {
    display: block;
  }
  
  .table-responsive-cards .data-table thead {
    position: absolute;
    left: -9999px;
  }
  
  .table-responsive-cards .data-table tr {
    background: var(--bg-primary);
    margin-bottom: var(--space-3);
    padding: var(--space-3);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
  }
  
  .table-responsive-cards .data-table td {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .table-responsive-cards .data-table td:last-child {
    border-bottom: none;
  }
  
  .table-responsive-cards .data-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: var(--space-3);
  }
}

/* ========================================
   CARDS RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .card {
    padding: var(--space-4);
  }
  
  .card-header {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .card-title {
    font-size: var(--text-base);
    width: 100%;
  }
  
  .card-actions {
    width: 100%;
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: var(--space-2);
  }
  
  .card-actions .btn {
    flex-shrink: 0;
  }
}

/* ========================================
   FORMS RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: var(--space-4);
  }
  
  .form-row .form-group {
    width: 100%;
  }
  
  .form-group-inline {
    flex-direction: column;
    align-items: stretch;
  }
  
  .input-group {
    flex-direction: column;
  }
  
  .input-group input,
  .input-group select,
  .input-group button {
    width: 100%;
  }
}

/* Larger touch targets for inputs */
input,
select,
textarea {
  min-height: 44px;
  font-size: 16px !important; /* Prevent iOS zoom */
}

/* ========================================
   BUTTONS RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .btn {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
  }
  
  .btn-group {
    flex-wrap: wrap;
    gap: var(--space-2);
  }
  
  .btn-group .btn {
    flex: 1;
    min-width: calc(50% - var(--space-1));
    text-align: center;
    justify-content: center;
  }
  
  /* Full width buttons on mobile */
  .btn-full-mobile {
    width: 100%;
  }
}

/* ========================================
   TABS RESPONSIVE
   ======================================== */

.tabs {
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: var(--space-1);
  padding-bottom: var(--space-2);
}

.tab,
.tab-btn {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .tabs {
    gap: 0;
    border-radius: var(--radius-lg);
    background: var(--gray-100);
    padding: var(--space-1);
  }
  
  .tab,
  .tab-btn {
    flex: 1;
    text-align: center;
    padding: var(--space-3);
    font-size: var(--text-sm);
    justify-content: center;
  }
}

/* ========================================
   MODALS RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  .modal-content {
    width: 100%;
    max-width: none;
    margin: 0;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    position: absolute;
    bottom: 0;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .modal-header {
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 1;
  }
  
  .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    flex-direction: column;
    gap: var(--space-2);
  }
  
  .modal-footer .btn {
    width: 100%;
  }
}

/* ========================================
   MAP CONTAINER RESPONSIVE
   ======================================== */

.map-container {
  position: relative;
  width: 100%;
  height: 400px;
}

@media (max-width: 768px) {
  .map-container {
    height: 300px;
  }
  
  .map-controls {
    bottom: auto;
    top: var(--space-3);
  }
  
  .map-legend {
    display: none;
  }
  
  .map-legend.visible {
    display: block;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: none;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }
}

/* ========================================
   FILTERS RESPONSIVE
   ======================================== */

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: center;
}

@media (max-width: 768px) {
  .filters-bar {
    flex-direction: column;
    align-items: stretch;
  }
  
  .filters-bar > * {
    width: 100%;
  }
  
  .filters-bar select,
  .filters-bar input {
    width: 100%;
  }
  
  /* Collapsible filters */
  .filters-collapsible {
    display: none;
    flex-direction: column;
    gap: var(--space-3);
  }
  
  .filters-collapsible.open {
    display: flex;
  }
  
  .filters-toggle {
    display: flex;
    width: 100%;
  }
}

/* ========================================
   DASHBOARD SPECIFIC
   ======================================== */

@media (max-width: 992px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .dashboard-map {
    height: 300px;
    order: -1;
  }
  
  .dashboard-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }
}

@media (max-width: 600px) {
  .dashboard-sidebar {
    grid-template-columns: 1fr;
  }
}

/* ========================================
   LIVE TRACKING RESPONSIVE
   ======================================== */

@media (max-width: 992px) {
  .tracking-layout {
    flex-direction: column;
  }
  
  .tracking-sidebar {
    width: 100%;
    height: auto;
    max-height: 300px;
    order: 2;
    overflow-y: auto;
  }
  
  .tracking-map {
    flex: 1;
    min-height: 400px;
  }
}

/* ========================================
   TYPOGRAPHY RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
  h1 {
    font-size: 1.75rem;
  }
  
  h2 {
    font-size: 1.5rem;
  }
  
  h3 {
    font-size: 1.25rem;
  }
  
  .text-xl {
    font-size: 1.125rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
}

/* ========================================
   UTILITIES RESPONSIVE
   ======================================== */

/* Hide on specific breakpoints */
@media (max-width: 1200px) {
  .hide-lg {
    display: none !important;
  }
}

@media (max-width: 992px) {
  .hide-md {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .hide-sm {
    display: none !important;
  }
}

@media (max-width: 576px) {
  .hide-xs {
    display: none !important;
  }
}

/* Show on specific breakpoints */
@media (min-width: 769px) {
  .show-mobile-only {
    display: none !important;
  }
}

/* Stack horizontally on desktop, vertically on mobile */
.flex-responsive {
  display: flex;
  gap: var(--space-3);
}

@media (max-width: 768px) {
  .flex-responsive {
    flex-direction: column;
  }
}

/* Text alignment responsive */
@media (max-width: 768px) {
  .text-center-mobile {
    text-align: center;
  }
}

/* Spacing responsive */
@media (max-width: 768px) {
  .p-mobile-0 {
    padding: 0;
  }
  
  .m-mobile-0 {
    margin: 0;
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
  .sidebar,
  .main-header,
  .mobile-menu-toggle,
  .sidebar-overlay,
  .btn,
  .filters-bar,
  .pagination {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0;
    padding: 0;
  }
  
  .card {
    box-shadow: none;
    border: 1px solid #ccc;
  }
}
