/* Mobile-First Responsive CSS for VIntegrate */

/* ====================================
   MOBILE FOUNDATION
   ==================================== */

/* Base mobile-first approach */
* {
  box-sizing: border-box;
}

/* Touch-friendly tap targets */
.btn, .nav-link, .card, .form-control, 
input[type="button"], input[type="submit"], 
button, a, .clickable {
  min-height: 44px;
  min-width: 44px;
}

/* Mobile-optimized form controls */
.form-control, .form-select {
  font-size: 16px; /* Prevents zoom on iOS */
  padding: 12px 16px;
  border-radius: 8px;
}

/* ====================================
   MOBILE NAVIGATION
   ==================================== */

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1050;
  background: var(--primary-color, #009e1e);
  color: white;
  border: none;
  border-radius: 8px;
  width: 44px;
  height: 44px;
  font-size: 18px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1040;
}

/* Mobile-optimized sidebar */
@media (max-width: 768px) {
  .sidebar-toggle {
    display: block;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -250px;
    width: 250px;
    height: 100vh;
    z-index: 1045;
    transition: left 0.3s ease;
    overflow-y: auto;
  }
  
  .sidebar.show {
    left: 0;
  }
  
  .sidebar-overlay.show {
    display: block;
  }
  
  #content {
    margin-left: 0;
    width: 100%;
    padding: 70px 15px 15px 15px;
  }
  
  .main-content {
    padding: 0;
    max-width: 100%;
  }
}

/* ====================================
   MOBILE CARDS & COMPONENTS
   ==================================== */

/* Mobile-optimized cards */
@media (max-width: 768px) {
  .card {
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  }
  
  .card-body {
    padding: 1rem;
  }
  
  .stat-card {
    margin-bottom: 1rem;
  }
  
  .stat-card .card-body {
    padding: 1.25rem;
  }
}

/* Mobile-friendly tables */
@media (max-width: 768px) {
  .table-responsive {
    border-radius: 8px;
    border: 1px solid #dee2e6;
  }
  
  .table {
    font-size: 14px;
  }
  
  .table th,
  .table td {
    padding: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
  }
  
  /* Stack table on very small screens */
  @media (max-width: 480px) {
    .table thead {
      display: none;
    }
    
    .table tbody tr {
      display: block;
      border: 1px solid #ccc;
      margin-bottom: 10px;
      border-radius: 8px;
      padding: 10px;
    }
    
    .table tbody td {
      display: block;
      text-align: right;
      border: none;
      padding: 5px 0;
      max-width: none;
      white-space: normal;
    }
    
    .table tbody td:before {
      content: attr(data-label) ": ";
      font-weight: bold;
      float: left;
    }
  }
}

/* ====================================
   MOBILE FORMS
   ==================================== */

@media (max-width: 768px) {
  .form-group,
  .mb-3 {
    margin-bottom: 1.5rem;
  }
  
  .form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 14px;
  }
  
  .form-control {
    border: 2px solid #e9ecef;
    transition: border-color 0.15s ease-in-out;
  }
  
  .form-control:focus {
    border-color: var(--primary-color, #009e1e);
    box-shadow: 0 0 0 0.2rem rgba(0, 158, 30, 0.25);
  }
  
  /* Stack form controls on mobile */
  .row .col-md-6,
  .row .col-lg-6 {
    margin-bottom: 1rem;
  }
  
  .input-group {
    flex-direction: column;
  }
  
  .input-group .form-control,
  .input-group .btn {
    border-radius: 8px;
    margin-bottom: 0.5rem;
  }
  
  .input-group .btn {
    margin-bottom: 0;
  }
}

/* ====================================
   MOBILE MODALS
   ==================================== */

@media (max-width: 768px) {
  .modal-dialog {
    margin: 0.5rem;
    max-width: calc(100% - 1rem);
  }
  
  .modal-content {
    border-radius: 12px;
  }
  
  .modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
  }
  
  .modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
  }
  
  .modal-footer {
    padding: 1rem 1.5rem;
    flex-direction: column;
    gap: 0.5rem;
  }
  
  .modal-footer .btn {
    width: 100%;
    margin: 0;
  }
}

/* ====================================
   MOBILE BUTTONS & ACTIONS
   ==================================== */

@media (max-width: 768px) {
  .btn {
    padding: 12px 20px;
    font-size: 16px;
    border-radius: 8px;
    font-weight: 500;
  }
  
  .btn-group {
    flex-direction: column;
    width: 100%;
  }
  
  .btn-group .btn {
    margin-bottom: 0.5rem;
    border-radius: 8px !important;
  }
  
  .btn-group .btn:last-child {
    margin-bottom: 0;
  }
  
  /* Floating action button for mobile */
  .fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color, #009e1e);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
  }
}

/* ====================================
   MOBILE DASHBOARD GRID
   ==================================== */

@media (max-width: 768px) {
  .dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0;
  }
  
  .dashboard-widget {
    grid-column: 1;
    margin-bottom: 0;
  }
  
  /* Stats grid for mobile */
  .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }
  
  @media (max-width: 480px) {
    .stats-grid {
      grid-template-columns: 1fr;
    }
  }
}

/* ====================================
   MOBILE CHAT & COMMUNICATION
   ==================================== */

@media (max-width: 768px) {
  .chat-container {
    height: calc(100vh - 140px);
    padding: 1rem 0.5rem;
  }
  
  .chat-message {
    max-width: 85%;
  }
  
  .message-bubble {
    padding: 0.75rem;
    font-size: 14px;
    border-radius: 18px;
  }
  
  .chat-input {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    padding: 1rem;
    border-top: 1px solid #e9ecef;
    z-index: 100;
  }
  
  .chat-input .input-group {
    flex-direction: row;
  }
  
  .chat-input .form-control {
    border-radius: 20px 0 0 20px;
    border-right: none;
    margin-bottom: 0;
  }
  
  .chat-input .btn {
    border-radius: 0 20px 20px 0;
    margin-bottom: 0;
  }
}

/* ====================================
   MOBILE CALENDAR
   ==================================== */

@media (max-width: 768px) {
  .calendar-container {
    padding: 1rem;
    margin: 0;
    border-radius: 12px;
  }
  
  .fc {
    padding: 10px;
  }
  
  .fc-toolbar {
    flex-direction: column;
    gap: 10px;
  }
  
  .fc-toolbar-chunk {
    display: flex;
    justify-content: center;
  }
  
  .fc-button {
    padding: 8px 12px;
    font-size: 14px;
  }
  
  .fc-event {
    font-size: 12px;
    padding: 2px 4px;
  }
  
  /* Mobile calendar views */
  .fc-dayGridMonth-view .fc-daygrid-day {
    min-height: 80px;
  }
  
  .fc-listWeek-view .fc-list-item {
    padding: 10px;
  }
}

/* ====================================
   MOBILE UTILITIES
   ==================================== */

/* Hide on mobile */
@media (max-width: 768px) {
  .d-mobile-none {
    display: none !important;
  }
  
  .mobile-hidden {
    display: none !important;
  }
}

/* Show only on mobile */
.d-mobile-block {
  display: none !important;
}

@media (max-width: 768px) {
  .d-mobile-block {
    display: block !important;
  }
  
  .mobile-only {
    display: block !important;
  }
}

/* Mobile spacing utilities */
@media (max-width: 768px) {
  .mobile-p-1 { padding: 0.5rem !important; }
  .mobile-p-2 { padding: 1rem !important; }
  .mobile-p-3 { padding: 1.5rem !important; }
  
  .mobile-m-1 { margin: 0.5rem !important; }
  .mobile-m-2 { margin: 1rem !important; }
  .mobile-m-3 { margin: 1.5rem !important; }
  
  .mobile-mb-1 { margin-bottom: 0.5rem !important; }
  .mobile-mb-2 { margin-bottom: 1rem !important; }
  .mobile-mb-3 { margin-bottom: 1.5rem !important; }
}

/* ====================================
   MOBILE PWA ENHANCEMENTS
   ==================================== */

/* PWA status bar styling */
@media (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .sidebar-toggle {
    top: calc(15px + env(safe-area-inset-top));
  }
  
  #content {
    padding-top: calc(70px + env(safe-area-inset-top));
  }
}

/* iOS specific adjustments */
@supports (-webkit-touch-callout: none) {
  .form-control {
    font-size: 16px; /* Prevents zoom */
  }
  
  /* Fix iOS button styling */
  .btn {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 8px;
  }
  
  /* iOS safe area adjustments */
  @media (display-mode: standalone) {
    body {
      padding-bottom: env(safe-area-inset-bottom);
    }
  }
}

/* ====================================
   MOBILE ACCESSIBILITY
   ==================================== */

/* High contrast support */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }
  
  .form-control {
    border: 2px solid #333;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .modal,
  .btn,
  .card {
    transition: none !important;
    animation: none !important;
  }
}

/* Focus indicators for keyboard navigation */
@media (max-width: 768px) {
  .btn:focus,
  .form-control:focus,
  .nav-link:focus {
    outline: 3px solid var(--primary-color, #009e1e);
    outline-offset: 2px;
  }
}

/* ====================================
   MOBILE PERFORMANCE OPTIMIZATIONS
   ==================================== */

/* Optimize rendering */
.sidebar,
.modal,
.card {
  will-change: transform;
  backface-visibility: hidden;
}

/* GPU acceleration for smooth scrolling */
.chat-container,
.calendar-container,
.table-responsive {
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* ====================================
   MOBILE DARK MODE
   ==================================== */

@media (max-width: 768px) and (prefers-color-scheme: dark) {
  .modal-content {
    background-color: #2d3748;
    color: #e2e8f0;
  }
  
  .form-control {
    background-color: #4a5568;
    border-color: #718096;
    color: #e2e8f0;
  }
  
  .card {
    background-color: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
  }
}
