/* Omnithium v2 - Mobile Responsive Styles */

/* =====================================
     MOBILE BREAKPOINT (max-width: 768px)
     ===================================== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
    --header-height: 60px;
    --spacing-sm: 0.5rem;
    --spacing-md: 0.75rem;
    --spacing-lg: 1rem;
    --spacing-xl: 1.25rem;
    --font-size-base: 0.9375rem;
    --font-size-lg: 1rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
  }

  html {
    font-size: 15px;
  }

  /* =====================================
       SIDEBAR (Mobile Drawer)
       ===================================== */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 85vw;
    max-width: 320px;
    transform: translateX(-100%);
    z-index: 10000;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
  }

  .sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
  }

  .sidebar-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 1;
  }

  .sidebar-nav {
    padding: var(--spacing-md);
  }

  .nav-item {
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-xs);
    transition: background 0.2s ease;
  }

  .nav-item:hover {
    background: var(--bg-hover);
  }

  .nav-item.active {
    background: var(--primary-color);
    color: white;
  }

  /* =====================================
       MAIN LAYOUT
       ===================================== */
  .app-layout {
    flex-direction: column;
  }

  .main-content {
    margin-left: 0;
    margin-top: var(--header-height);
    min-height: calc(100vh - var(--header-height));
    padding-bottom: 80px;
  }

  .main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    padding: 0 var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
  }

  .btn-menu {
    display: flex;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
  }

  .header-title {
    flex: 1;
    text-align: center;
    margin: 0 var(--spacing-md);
  }

  .header-title h1 {
    font-size: var(--font-size-lg);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .page-content {
    padding: var(--spacing-md);
  }

  /* =====================================
       LOGIN PAGE (Full screen)
       ===================================== */
  .login-page {
    min-height: 100vh;
    padding: var(--spacing-lg);
  }

  .login-container,
  .register-container {
    max-width: 100%;
    width: 100%;
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
  }

  .login-header {
    margin-bottom: var(--spacing-xl);
  }

  .login-header h1 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--spacing-sm);
  }

  .login-header p {
    font-size: var(--font-size-base);
    opacity: 0.8;
  }

  .form-group {
    margin-bottom: var(--spacing-lg);
  }

  .form-label {
    font-size: var(--font-size-sm);
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    display: block;
  }

  .form-input {
    width: 100%;
    padding: var(--spacing-md);
    font-size: var(--font-size-base);
    border-radius: var(--radius-md);
  }

  .btn-primary {
    width: 100%;
    padding: var(--spacing-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    border-radius: var(--radius-md);
  }

  .form-footer {
    margin-top: var(--spacing-xl);
    text-align: center;
  }

  .form-footer a {
    font-size: var(--font-size-sm);
  }

  /* =====================================
       DASHBOARD
       ===================================== */
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  .stat-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
  }

  .stat-card .stat-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    margin-bottom: 0;
  }

  .stat-card .stat-content {
    flex: 1;
  }

  .stat-card .stat-value {
    font-size: var(--font-size-xl);
    font-weight: 700;
  }

  .stat-card .stat-label {
    font-size: var(--font-size-sm);
    opacity: 0.7;
  }

  /* =====================================
       CARDS
       ===================================== */
  .card {
    border-radius: var(--radius-lg);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  }

  .card-header {
    padding: var(--spacing-md);
  }

  .card-body {
    padding: var(--spacing-md);
  }

  .card-header h3 {
    font-size: var(--font-size-base);
    font-weight: 600;
  }

  /* =====================================
       TABLES (Scrollable)
       ===================================== */
  .table-container {
    margin: 0 calc(var(--spacing-md) * -1);
    border-radius: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .table {
    min-width: 600px;
  }

  .table th,
  .table td {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    white-space: nowrap;
  }

  /* =====================================
       MODAL (Sheet style)
       ===================================== */
  .modal-container {
    padding: var(--spacing-md);
    align-items: flex-end;
  }

  .modal {
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: slideUp 0.3s ease;
  }

  @keyframes slideUp {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .modal-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .modal-header h2 {
    font-size: var(--font-size-lg);
    font-weight: 600;
  }

  .modal-body {
    padding: var(--spacing-md);
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-footer {
    padding: var(--spacing-md);
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
  }

  .btn-close-modal {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
  }

  /* =====================================
       TOAST (Bottom centered)
       ===================================== */
  .toast-container {
    bottom: var(--spacing-lg);
    right: var(--spacing-md);
    left: var(--spacing-md);
    max-width: none;
  }

  .toast {
    width: 100%;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  }

  /* =====================================
       AGENT BUBBLE
       ===================================== */
  .agent-bubble {
    bottom: var(--spacing-lg);
    right: var(--spacing-md);
    z-index: 500;
  }

  .bubble-toggle {
    width: 56px;
    height: 56px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  }

  .bubble-panel {
    position: fixed;
    bottom: 80px;
    right: var(--spacing-md);
    left: var(--spacing-md);
    width: auto;
    height: 60vh;
    max-height: 480px;
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  }

  /* =====================================
       BUTTONS
       ===================================== */
  .btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-md);
  }

  .btn-block-mobile {
    width: 100%;
  }

  .btn-group {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  /* =====================================
       FORMS
       ===================================== */
  .form-row {
    flex-direction: column;
    gap: var(--spacing-md);
  }

  .form-actions {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

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

  /* =====================================
       PAGINATION
       ===================================== */
  .pagination {
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
  }

  .pagination-btn {
    min-width: 40px;
    height: 40px;
    padding: 0 var(--spacing-sm);
  }

  /* =====================================
       EMPTY STATES
       ===================================== */
  .empty-state {
    padding: var(--spacing-xl) var(--spacing-md);
    text-align: center;
  }

  .empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
  }

  .empty-state h3 {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-sm);
  }

  .empty-state p {
    font-size: var(--font-size-sm);
    opacity: 0.7;
  }

  /* =====================================
       PAGE HEADERS
       ===================================== */
  .page-header {
    margin-bottom: var(--spacing-lg);
  }

  .page-header h1 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-xs);
  }

  .page-actions {
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-md);
  }

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

  /* =====================================
       HEADER ACTIONS
       ===================================== */
  .header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
  }

  .language-selector select {
    padding: var(--spacing-sm);
    font-size: var(--font-size-sm);
    border-radius: var(--radius-sm);
  }

  .btn-notification {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
  }

  /* =====================================
       USER MENU (Mobile)
       ===================================== */
  .user-menu {
    padding: var(--spacing-md);
  }

  .user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
  }

  .user-avatar {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
  }

  .user-details {
    flex: 1;
    min-width: 0;
  }

  .user-name {
    font-size: var(--font-size-base);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .user-email {
    font-size: var(--font-size-xs);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* =====================================
       TABS (Scrollable)
       ===================================== */
  .tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .tab {
    white-space: nowrap;
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
  }

  /* =====================================
       LIST ITEMS
       ===================================== */
  .list-item {
    padding: var(--spacing-md);
  }

  .list-item-title {
    font-size: var(--font-size-base);
    font-weight: 500;
  }

  .list-item-subtitle {
    font-size: var(--font-size-sm);
    opacity: 0.7;
  }

  /* =====================================
       SEARCH
       ===================================== */
  .search-container {
    margin-bottom: var(--spacing-md);
  }

  .search-input {
    width: 100%;
    padding: var(--spacing-md);
    font-size: var(--font-size-base);
  }

  /* =====================================
       BADGES & TAGS
       ===================================== */
  .badge {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
    border-radius: var(--radius-sm);
  }

  /* =====================================
       LOADING STATES
       ===================================== */
  .loading-spinner {
    width: 32px;
    height: 32px;
  }

  .skeleton {
    height: 1rem;
    border-radius: var(--radius-sm);
  }

  /* =====================================
       HIDDEN ON MOBILE
       ===================================== */
  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: flex !important;
  }
}

/* =====================================
     SMALL SCREENS (max-width: 480px)
     ===================================== */
@media (max-width: 480px) {
  :root {
    --font-size-base: 0.875rem;
    --spacing-sm: 0.375rem;
    --spacing-md: 0.5rem;
    --spacing-lg: 0.75rem;
  }

  html {
    font-size: 14px;
  }

  .sidebar {
    max-width: 85vw;
  }

  .login-container,
  .register-container {
    padding: var(--spacing-lg);
  }

  .header-title h1 {
    font-size: var(--font-size-md);
  }

  .modal {
    max-height: 90vh;
  }

  .bubble-panel {
    height: 65vh;
  }
}

/* =====================================
     LANDSCAPE MOBILE
     ===================================== */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    width: 280px;
  }

  .agent-bubble {
    display: none;
  }

  .bubble-panel {
    height: 280px;
  }

  .modal {
    max-height: 80vh;
  }
}

/* =====================================
     NOTCH DEVICES
     ===================================== */
@supports (padding-top: env(safe-area-inset-top)) {
  .sidebar {
    padding-top: env(safe-area-inset-top);
  }

  .main-header {
    padding-top: env(safe-area-inset-top);
  }

  .main-content {
    padding-top: calc(var(--header-height) + env(safe-area-inset-top));
  }

  .toast-container {
    padding-bottom: calc(env(safe-area-inset-bottom) + var(--spacing-lg));
  }

  .agent-bubble {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* =====================================
     HIGH CONTRAST MODE
     ===================================== */
@media (prefers-contrast: high) {
  @media (max-width: 768px) {
    .sidebar {
      border-right: 2px solid var(--text-primary);
    }

    .card {
      border: 1px solid var(--text-primary);
    }

    .btn {
      border: 2px solid currentColor;
    }
  }
}

/* =====================================
     REDUCED MOTION
     ===================================== */
@media (prefers-reduced-motion: reduce) {
  @media (max-width: 768px) {
    .sidebar,
    .sidebar-overlay,
    .modal {
      transition: none;
    }

    .modal {
      animation: none;
    }
  }
}
