/* Mobile Responsive Styles for Trackara CRM */

/* Base mobile styles - Mobile First Approach */
@media screen and (max-width: 768px) {
  
  /* === GLOBAL MOBILE STYLES === */
  
  body {
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
  }
  
  .container {
    padding: 10px;
    margin: 0;
    max-width: 100%;
  }
  
  /* Typography adjustments */
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  h3 { font-size: 18px; }
  h4 { font-size: 16px; }
  h5 { font-size: 14px; }
  
  /* === NAVIGATION === */
  
  .main-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e2e8f0;
    z-index: 1000;
    padding: 8px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
  }
  
  .nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  
  .nav-item {
    flex: 1;
    text-align: center;
    padding: 8px 4px;
    text-decoration: none;
    color: #6b7280;
    font-size: 11px;
    transition: color 0.2s;
  }
  
  .nav-item.active {
    color: #17afa5;
  }
  
  .nav-item i {
    display: block;
    font-size: 18px;
    margin-bottom: 4px;
  }
  
  .nav-item span {
    display: block;
    font-size: 10px;
  }
  
  /* Main content padding for bottom nav */
  .main-content {
    padding-bottom: 80px;
    min-height: calc(100vh - 80px);
  }
  
  /* === HEADER === */
  
  .page-header {
    padding: 15px 10px;
    border-bottom: 1px solid #e2e8f0;
    background: white;
    position: sticky;
    top: 0;
    z-index: 100;
  }
  
  .page-title {
    font-size: 20px;
    margin: 0;
    color: #1f2937;
  }
  
  .page-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 2px 0 0 0;
  }
  
  /* Header actions */
  .header-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
  }
  
  .header-actions .btn {
    flex: 1;
    min-width: 0;
    padding: 10px 8px;
    font-size: 13px;
  }
  
  /* === BUTTONS === */
  
  .btn {
    padding: 12px 16px;
    font-size: 14px;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    min-height: 44px; /* Touch target */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }
  
  .btn-sm {
    padding: 8px 12px;
    font-size: 12px;
    min-height: 36px;
  }
  
  .btn-lg {
    padding: 16px 24px;
    font-size: 16px;
    min-height: 52px;
  }
  
  /* Button groups */
  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }
  
  .btn-group .btn {
    flex: 1;
  }
  
  /* === FORMS === */
  
  .form-group {
    margin-bottom: 16px;
  }
  
  .form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
  }
  
  .form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px;
    box-sizing: border-box;
  }
  
  .form-control:focus {
    outline: none;
    border-color: #17afa5;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
  }
  
  textarea.form-control {
    min-height: 100px;
    resize: vertical;
  }
  
  select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
  }
  
  /* Form rows */
  .form-row {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }
  
  .form-col {
    flex: 1;
  }
  
  /* === CARDS === */
  
  .card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  }
  
  .card-header {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f3f4f6;
  }
  
  .card-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: #1f2937;
  }
  
  .card-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin: 4px 0 0 0;
  }
  
  .card-body {
    font-size: 14px;
    line-height: 1.5;
  }
  
  .card-actions {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .card-actions .btn {
    flex: 1;
    min-width: 0;
  }
  
  /* === TABLES === */
  
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: -16px;
    padding: 16px;
  }
  
  .table {
    width: 100%;
    min-width: 600px; /* Minimum width for horizontal scroll */
    border-collapse: collapse;
  }
  
  .table th,
  .table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
  }
  
  .table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
  }
  
  /* Card-style table alternative for mobile */
  .table-cards {
    display: block;
  }
  
  .table-cards .table-row {
    display: block;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 16px;
  }
  
  .table-cards .table-cell {
    display: block;
    margin-bottom: 8px;
  }
  
  .table-cards .cell-label {
    font-weight: 600;
    color: #374151;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  .table-cards .cell-value {
    color: #1f2937;
    font-size: 14px;
    margin-top: 2px;
  }
  
  /* === MODALS === */
  
  .modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
  }
  
  .modal-content {
    background: white;
    width: 100%;
    max-height: 90vh;
    border-radius: 12px 12px 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  
  .modal-header {
    padding: 20px 16px 16px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    position: sticky;
    top: 0;
    z-index: 1;
  }
  
  .modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: #1f2937;
  }
  
  .modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .modal-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
  }
  
  .modal-footer {
    padding: 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 12px;
    flex-direction: column;
  }
  
  .modal-footer .btn {
    flex: 1;
  }
  
  /* === LISTS === */
  
  .list-group {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
  }
  
  .list-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #f3f4f6;
    background: white;
    cursor: pointer;
    transition: background 0.2s;
  }
  
  .list-item:last-child {
    border-bottom: none;
  }
  
  .list-item:hover,
  .list-item:active {
    background: #f9fafb;
  }
  
  .list-item-content {
    flex: 1;
    min-width: 0;
  }
  
  .list-item-title {
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px 0;
    font-size: 14px;
  }
  
  .list-item-subtitle {
    color: #6b7280;
    font-size: 12px;
    margin: 0;
  }
  
  .list-item-meta {
    color: #9ca3af;
    font-size: 11px;
    text-align: right;
    white-space: nowrap;
  }
  
  .list-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: #6b7280;
  }
  
  /* === BADGES & STATUS === */
  
  .badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  .badge-success {
    background: #d1fae5;
    color: #065f46;
  }
  
  .badge-warning {
    background: #fef3c7;
    color: #92400e;
  }
  
  .badge-danger {
    background: #fee2e2;
    color: #991b1b;
  }
  
  .badge-info {
    background: #dbeafe;
    color: #1e40af;
  }
  
  .badge-secondary {
    background: #f3f4f6;
    color: #374151;
  }
  
  /* === SEARCH === */
  
  .search-container {
    position: relative;
    margin-bottom: 16px;
  }
  
  .search-input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 16px;
    background: #f9fafb;
  }
  
  .search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
  }
  
  .search-clear {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    min-height: 24px;
    min-width: 24px;
  }
  
  /* === FILTERS === */
  
  .filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }
  
  .filter-chip {
    white-space: nowrap;
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    background: white;
    color: #374151;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
  }
  
  .filter-chip.active {
    background: #17afa5;
    color: white;
    border-color: #17afa5;
  }
  
  /* === STATS/METRICS === */
  
  .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
  }
  
  .stat-card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
  }
  
  .stat-number {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
  }
  
  .stat-label {
    font-size: 12px;
    color: #6b7280;
    margin: 4px 0 0 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  
  /* === LOADING STATES === */
  
  .loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
  }
  
  .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f4f6;
    border-top: 3px solid #17afa5;
    border-radius: 50%;
    animation: spin 1s linear infinite;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  .skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
  }
  
  @keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
  }
  
  .skeleton-line {
    height: 16px;
    border-radius: 4px;
    margin-bottom: 8px;
  }
  
  .skeleton-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
  }
  
  /* === TOAST NOTIFICATIONS === */
  
  .toast-container {
    position: fixed;
    top: 20px;
    left: 16px;
    right: 16px;
    z-index: 10000;
  }
  
  .toast {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideInDown 0.3s ease;
  }
  
  @keyframes slideInDown {
    from {
      transform: translateY(-100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }
  
  .toast-success { border-left: 4px solid #10b981; }
  .toast-error { border-left: 4px solid #ef4444; }
  .toast-warning { border-left: 4px solid #f59e0b; }
  .toast-info { border-left: 4px solid #17afa5; }
  
  /* === UTILITIES === */
  
  .text-center { text-align: center; }
  .text-left { text-align: left; }
  .text-right { text-align: right; }
  
  .mt-0 { margin-top: 0; }
  .mt-1 { margin-top: 8px; }
  .mt-2 { margin-top: 16px; }
  .mt-3 { margin-top: 24px; }
  
  .mb-0 { margin-bottom: 0; }
  .mb-1 { margin-bottom: 8px; }
  .mb-2 { margin-bottom: 16px; }
  .mb-3 { margin-bottom: 24px; }
  
  .p-0 { padding: 0; }
  .p-1 { padding: 8px; }
  .p-2 { padding: 16px; }
  .p-3 { padding: 24px; }
  
  .d-none { display: none; }
  .d-block { display: block; }
  .d-flex { display: flex; }
  
  .justify-center { justify-content: center; }
  .justify-between { justify-content: space-between; }
  .align-center { align-items: center; }
  
  .w-full { width: 100%; }
  .h-full { height: 100%; }
  
  .text-xs { font-size: 11px; }
  .text-sm { font-size: 12px; }
  .text-base { font-size: 14px; }
  .text-lg { font-size: 16px; }
  .text-xl { font-size: 18px; }
  
  .font-normal { font-weight: 400; }
  .font-medium { font-weight: 500; }
  .font-semibold { font-weight: 600; }
  .font-bold { font-weight: 700; }
  
  .text-gray-500 { color: #6b7280; }
  .text-gray-600 { color: #4b5563; }
  .text-gray-700 { color: #374151; }
  .text-gray-900 { color: #1f2937; }
  
  .text-blue-500 { color: #17afa5; }
  .text-blue-600 { color: #2563eb; }
  
  .text-green-500 { color: #10b981; }
  .text-green-600 { color: #059669; }
  
  .text-red-500 { color: #ef4444; }
  .text-red-600 { color: #dc2626; }
  
  .text-yellow-500 { color: #f59e0b; }
  .text-yellow-600 { color: #d97706; }
  
  .bg-white { background-color: white; }
  .bg-gray-50 { background-color: #f9fafb; }
  .bg-gray-100 { background-color: #f3f4f6; }
  
  .rounded { border-radius: 4px; }
  .rounded-md { border-radius: 6px; }
  .rounded-lg { border-radius: 8px; }
  .rounded-xl { border-radius: 12px; }
  .rounded-full { border-radius: 50%; }
  
  .shadow-sm { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05); }
  .shadow { box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
  .shadow-md { box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); }
  .shadow-lg { box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1); }
  
  /* === DARK MODE SUPPORT === */
  
  @media (prefers-color-scheme: dark) {
    body {
      background: #1f2937;
      color: #f9fafb;
    }
    
    .card {
      background: #374151;
      border-color: #4b5563;
    }
    
    .modal-content {
      background: #374151;
    }
    
    .form-control {
      background: #4b5563;
      border-color: #6b7280;
      color: #f9fafb;
    }
    
    .btn {
      background: #4b5563;
      color: #f9fafb;
      border-color: #6b7280;
    }
    
    .btn-primary {
      background: linear-gradient(135deg, #17afa5, #0d8b82);
      border-color: #17afa5;
    }
  }
}

/* === TABLET STYLES === */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  
  .container {
    padding: 20px;
    max-width: 100%;
  }
  
  /* Navigation adjustments for tablet */
  .main-nav {
    position: static;
    border-top: none;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 0;
  }
  
  .nav-items {
    justify-content: flex-start;
    gap: 24px;
    padding: 0 20px;
  }
  
  .nav-item {
    flex: none;
    padding: 12px 16px;
    border-radius: 6px;
  }
  
  .nav-item i {
    display: inline;
    margin-right: 8px;
    margin-bottom: 0;
  }
  
  .nav-item span {
    display: inline;
  }
  
  .main-content {
    padding-bottom: 20px;
  }
  
  /* Grid adjustments */
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  
  .form-row {
    flex-direction: row;
  }
  
  .modal {
    align-items: center;
    padding: 20px;
  }
  
  .modal-content {
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 12px;
  }
  
  .modal-footer {
    flex-direction: row;
  }
}

/* === LARGE SCREENS === */
@media screen and (min-width: 1025px) {
  
  /* Reset mobile styles for large screens */
  .main-nav {
    position: static;
    background: transparent;
    border: none;
    box-shadow: none;
  }
  
  .main-content {
    padding-bottom: 0;
  }
  
  .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px;
  }
  
  /* Desktop navigation */
  .nav-items {
    display: flex;
    gap: 32px;
    padding: 0;
  }
  
  .nav-item {
    flex: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
  }
  
  .nav-item i {
    margin-right: 8px;
  }
  
  /* Desktop modals */
  .modal {
    align-items: center;
    padding: 40px;
  }
  
  .modal-content {
    width: auto;
    min-width: 500px;
    max-width: 90vw;
    border-radius: 12px;
  }
  
  .modal-footer {
    flex-direction: row;
  }
  
  /* Desktop forms */
  .form-row {
    flex-direction: row;
  }
  
  .btn-group {
    flex-direction: row;
  }
  
  /* Desktop grids */
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

/* === ACCESSIBILITY === */

/* Focus styles for keyboard navigation */
.btn:focus,
.form-control:focus,
.nav-item:focus {
  outline: 2px solid #17afa5;
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .btn {
    border: 2px solid currentColor;
  }
  
  .card {
    border: 2px solid currentColor;
  }
  
  .form-control {
    border: 2px solid currentColor;
  }
}