/**
 * Responsive Design Styles
 * Mobile-first approach with breakpoints for tablet and desktop
 * Breakpoints: Mobile (< 768px), Tablet (768px - 991px), Desktop (>= 992px)
 */

/* ============================================
   MOBILE STYLES (< 768px)
   ============================================ */

@media (max-width: 767px) {
  /* Reduce padding in top header */
  .top-header {
    padding: 0 var(--spacing-4);
  }

  /* Single column layouts */
  .grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  /* Force single column on mobile for multi-column grids */
  .grid-cols-2,
  .grid-cols-3,
  .grid-cols-4,
  .grid-cols-md-2,
  .grid-cols-md-3,
  .grid-cols-lg-2,
  .grid-cols-lg-3,
  .grid-cols-lg-4 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
  }

  /* Card adjustments */
  .card {
    margin-bottom: var(--spacing-4);
  }

  .card-header,
  .card-body,
  .card-footer {
    padding: var(--spacing-4);
  }

  /* Reduce spacing between cards */
  .summary-cards {
    gap: var(--spacing-4);
    margin-bottom: var(--spacing-6);
  }

  /* Summary card adjustments */
  .summary-card-icon {
    width: 48px;
    height: 48px;
  }

  .summary-card-icon svg {
    width: 24px;
    height: 24px;
  }

  .summary-card-value {
    font-size: var(--text-2xl);
  }

  /* Quick actions - stack buttons */
  .quick-actions-grid {
    gap: var(--spacing-3);
  }

  .quick-action-btn {
    width: 100%;
  }

  /* DataTables - horizontal scroll */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 calc(var(--spacing-4) * -1);
    padding: 0 var(--spacing-4);
  }

  .dataTables_wrapper {
    overflow-x: auto;
  }

  /* Table adjustments */
  .services-table,
  table.dataTable {
    min-width: 600px;
  }

  .services-table th,
  .services-table td {
    padding: var(--spacing-3);
    font-size: var(--text-xs);
  }

  /* Filter buttons - wrap and full width */
  .filter-buttons {
    flex-wrap: wrap;
    width: 100%;
  }

  .filter-buttons .btn {
    flex: 1;
    min-width: auto;
  }

  /* Card header with filters - stack vertically */
  .card-header.d-flex {
    flex-direction: column;
    align-items: flex-start !important;
    gap: var(--spacing-4);
  }

  .card-header .filter-buttons {
    width: 100%;
    flex-direction: column;
  }

  /* Page header adjustments */
  .page-header h1,
  .dashboard-header h1 {
    font-size: var(--text-2xl);
  }

  /* Service detail page */
  .service-header-top {
    flex-direction: column;
    gap: var(--spacing-3);
    align-items: stretch;
  }

  .service-header-top .btn {
    width: 100%;
    justify-content: center;
  }

  .service-header-main {
    flex-direction: column;
    align-items: flex-start;
  }

  .service-header-badge {
    align-self: flex-start;
  }

  .service-icon-large {
    width: 48px;
    height: 48px;
  }

  .service-icon-large svg {
    width: 24px;
    height: 24px;
  }

  .service-title {
    font-size: var(--text-xl);
  }

  /* Service tabs - horizontal scroll */
  .service-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Detail rows - stack vertically */
  .detail-row {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-2);
  }

  .detail-label {
    min-width: auto;
  }

  .detail-value {
    text-align: left;
  }

  .detail-value-multi {
    align-items: flex-start;
  }

  /* Preview actions - stack vertically */
  .preview-actions {
    flex-direction: column;
    width: 100%;
  }

  .preview-actions .btn {
    width: 100%;
  }

  /* Preview actions bottom - stack on mobile */
  .preview-actions-bottom {
    flex-direction: column;
  }

  .preview-actions-bottom .btn {
    width: 100%;
  }

  /* Preview image placeholder - smaller on mobile */
  .preview-image-placeholder {
    min-height: 200px;
    padding: var(--spacing-6) var(--spacing-3);
  }

  .preview-image-placeholder svg,
  .preview-image-placeholder i {
    width: 48px;
    height: 48px;
    font-size: 48px;
  }

  /* Invoice balance card */
  .balance-content {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-4);
  }

  .balance-amount {
    font-size: var(--text-3xl);
  }

  .balance-actions {
    width: 100%;
    flex-direction: column;
  }

  .balance-actions .btn {
    width: 100%;
  }

  /* Modal adjustments */
  .modal {
    padding: var(--spacing-2);
  }

  .modal-dialog {
    max-width: 100%;
    margin: 0;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: var(--spacing-4);
  }

  /* Form adjustments */
  .form-group {
    margin-bottom: var(--spacing-4);
  }

  /* Button adjustments */
  .btn {
    padding: var(--spacing-3) var(--spacing-4);
  }

  .btn-sm {
    padding: var(--spacing-2) var(--spacing-3);
  }

  /* User menu adjustments */
  .user-name {
    display: none;
  }

  .user-menu-toggle {
    padding: var(--spacing-2);
  }

  /* Header actions spacing */
  .header-actions {
    gap: var(--spacing-2);
  }



  .ticket-message {
    padding: var(--spacing-3);
    max-width: 100%;
  }

  /* Profile tabs */
  .profile-tabs {
    flex-wrap: wrap;
    flex-direction: column;
  }

  .profile-tab {
    flex: 1;
    min-width: 120px;
  }

  /* Reduce font sizes globally on mobile */
  body {
    font-size: var(--text-sm);
  }

  h1 {
    font-size: var(--text-2xl);
  }

  h2 {
    font-size: var(--text-xl);
  }

  h3 {
    font-size: var(--text-lg);
  }

  /* Container adjustments */
  .container {
    padding-left: var(--spacing-3);
    padding-right: var(--spacing-3);
  }
}

/* ============================================
   TABLET STYLES (768px - 991px)
   ============================================ */

@media (min-width: 768px) and (max-width: 991px) {
  /* Two-column layouts */
  .grid-cols-md-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-cols-lg-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-cols-lg-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Card spacing */
  .card-header,
  .card-body,
  .card-footer {
    padding: var(--spacing-5);
  }

  /* Summary cards - 2 columns */
  .summary-cards {
    gap: var(--spacing-5);
  }

  /* Quick actions - 2 columns */
  .quick-actions-grid {
    gap: var(--spacing-4);
  }

  /* Service header adjustments */
  .service-header-main {
    flex-direction: column;
    align-items: flex-start;
  }

  .service-header-badge {
    align-self: flex-start;
  }

  /* Service tabs - allow wrapping */
  .service-tabs {
    flex-wrap: wrap;
  }

  /* Balance card - keep horizontal layout */
  .balance-content {
    flex-direction: row;
  }

  .balance-actions {
    flex-direction: row;
  }

  /* Table responsive */
  .table-responsive {
    overflow-x: auto;
  }

  /* Modal size */
  .modal-dialog {
    max-width: 600px;
  }

  /* Adjust font sizes */
  .page-header h1,
  .dashboard-header h1 {
    font-size: var(--text-3xl);
  }

  .summary-card-value {
    font-size: var(--text-3xl);
  }

  .balance-amount {
    font-size: var(--text-4xl);
  }
}

/* ============================================
   DESKTOP STYLES (>= 992px)
   ============================================ */

@media (min-width: 992px) {
  /* Fixed sidebar on desktop - starts expanded */
  .sidebar {
    width: 250px;
    transform: translateX(0);
  }

  /* Collapsed sidebar shows only icons */
  .app-layout.sidebar-collapsed .sidebar {
    width: 70px;
  }

  /* Main wrapper with sidebar margin */
  .main-wrapper {
    margin-left: 250px;
  }

  .app-layout.sidebar-collapsed .main-wrapper {
    margin-left: 70px;
  }

  /* Hide mobile menu toggle on desktop */
  .mobile-menu-toggle {
    display: none !important;
  }

  /* Disable sidebar collapse on desktop - always expanded */
  .app-layout.sidebar-collapsed .sidebar {
    width: 250px !important;
  }

  .app-layout.sidebar-collapsed .sidebar-logo-text,
  .app-layout.sidebar-collapsed .nav-item span {
    opacity: 1 !important;
    width: auto !important;
    display: block !important;
  }

  /* Full padding in main content */
  .main-content {
    padding: var(--spacing-6);
  }

  /* Multi-column layouts */
  .grid-cols-lg-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .grid-cols-lg-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  /* Card spacing */
  .card-header,
  .card-body,
  .card-footer {
    padding: var(--spacing-6);
  }

  .card-header h2,
  .card-header h3 {
    font-size: var(--text-xl);
  }

  /* Summary cards - 3 columns */
  .summary-cards {
    gap: var(--spacing-6);
  }

  /* Quick actions - 4 columns */
  .quick-actions-grid {
    gap: var(--spacing-4);
  }

  /* Service header - horizontal layout */
  .service-header-main {
    flex-direction: row;
    align-items: center;
  }

  .service-header-badge {
    align-self: auto;
  }

  /* Service tabs - horizontal */
  .service-tabs {
    flex-wrap: nowrap;
  }

  /* Detail rows - horizontal */
  .detail-row {
    flex-direction: row;
    align-items: flex-start;
  }

  .detail-label {
    min-width: 140px;
  }

  .detail-value {
    text-align: right;
  }

  .detail-value-multi {
    align-items: flex-end;
  }

  /* Balance card - horizontal */
  .balance-content {
    flex-direction: row;
    align-items: center;
  }

  .balance-actions {
    flex-direction: row;
  }

  /* Tables - no horizontal scroll needed */
  .table-responsive {
    overflow-x: visible;
  }

  /* Modal sizes */
  .modal-dialog {
    max-width: 500px;
  }

  .modal-lg .modal-dialog {
    max-width: 800px;
  }

  .modal-xl .modal-dialog {
    max-width: 1140px;
  }

  /* Enable hover effects on desktop */
  .card-hover:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
  }

  .btn:hover {
    opacity: 0.9;
  }

  /* User menu - show name */
  .user-name {
    display: inline;
  }

  /* Larger spacing */
  .quick-actions,
  .my-services,
  .recent-transactions {
    margin-bottom: var(--spacing-8);
  }
}

/* ============================================
   EXTRA LARGE DESKTOP (>= 1200px)
   ============================================ */

@media (min-width: 1200px) {
  /* Remove max-width constraint for full-width content */
  .main-content {
    max-width: none;
  }

  /* Keep standard padding */
  .main-content {
    padding: var(--spacing-6);
  }

  /* Card spacing */
  .card-header,
  .card-body,
  .card-footer {
    padding: var(--spacing-5) var(--spacing-6);
  }

  /* Summary cards - larger icons */
  .summary-card-icon {
    width: 64px;
    height: 64px;
  }

  .summary-card-icon svg {
    width: 32px;
    height: 32px;
  }

  /* Larger font sizes */
  .summary-card-value {
    font-size: var(--text-4xl);
  }

  .balance-amount {
    font-size: var(--text-4xl);
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  /* Hide navigation and non-essential elements */
  .sidebar,
  .top-header,
  .mobile-menu-toggle,
  .mobile-backdrop,
  .btn,
  .filter-buttons,
  .quick-actions,
  .user-menu,
  .notification-btn {
    display: none !important;
  }

  /* Reset layout for printing */
  .main-wrapper {
    margin-left: 0;
  }

  .main-content {
    padding: 0;
  }

  /* Ensure content fits on page */
  .card {
    box-shadow: none;
    border: 1px solid #000;
    page-break-inside: avoid;
  }

  /* Remove backgrounds */
  body,
  .card,
  .card-header,
  .card-body {
    background-color: #fff;
  }

  /* Adjust colors for print */
  .badge {
    border: 1px solid #000;
  }

  /* Show all table content */
  .table-responsive {
    overflow: visible;
  }
}

/* ============================================
   UTILITY CLASSES FOR RESPONSIVE DISPLAY
   ============================================ */

/* Hide on mobile */
@media (max-width: 767px) {
  .hide-mobile {
    display: none !important;
  }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 991px) {
  .hide-tablet {
    display: none !important;
  }
}

/* Hide on desktop */
@media (min-width: 992px) {
  .hide-desktop {
    display: none !important;
  }
}

/* Show only on mobile */
.show-mobile {
  display: none !important;
}

@media (max-width: 767px) {
  .show-mobile {
    display: block !important;
  }
}

/* Show only on tablet */
.show-tablet {
  display: none !important;
}

@media (min-width: 768px) and (max-width: 991px) {
  .show-tablet {
    display: block !important;
  }
}

/* Show only on desktop */
.show-desktop {
  display: none !important;
}

@media (min-width: 992px) {
  .show-desktop {
    display: block !important;
  }
}
