/* =============================================================================
   VizaAI — Responsive & Mobile Adaptations (responsive.css)
   ============================================================================= */

@import url('./variables.css');

/* ── 1. Large Tablets & Small Laptops (max-width: 1024px) ── */
@media (max-width: 1024px) {
  .container {
    max-width: 960px;
  }

  .grid-layout {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-4);
  }

  .sidebar {
    width: 200px;
  }

  .main-content-with-sidebar {
    margin-left: 200px;
  }

  .card-stat-number {
    font-size: var(--text-2xl);
  }
}

/* ── 2. Tablets & Mobile Devices (max-width: 768px) ── */
@media (max-width: 768px) {

  /* ---- Global overflow prevention ---- */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  .container {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    max-width: 100%;
  }

  .navbar {
    padding: 0 var(--space-4);
    height: 60px;
  }

  /* ---- Mobile hamburger menu hidden (Hamburger moved to bottom nav 5th item) ---- */
  #mobile-menu-toggle-btn,
  #mobile-menu-btn,
  .mobile-menu-toggle {
    display: none !important;
  }

  /* ---- Hide desktop sidebar on mobile ---- */
  .sidebar,
  .app-sidebar {
    display: none !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* ── 4. Mobile Bottom Navigation Bar & Drawer Sheet (Native App Style) ── */
.bottom-nav-bar {
  display: none;
}

.mobile-sheet-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.mobile-sheet-overlay.active {
  display: flex;
  opacity: 1;
}

.mobile-menu-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 88vh;
  max-height: 88dvh;
  background: #0f172a;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.6);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
}

.mobile-sheet-overlay.active .mobile-menu-sheet {
  transform: translateY(0);
}

.mobile-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.mobile-sheet-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #94a3b8;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.mobile-sheet-close-btn:active {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.mobile-sheet-body {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.mobile-menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.mobile-menu-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.mobile-menu-card:active {
  transform: scale(0.97);
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(99, 102, 241, 0.4);
}

.mobile-menu-card-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-menu-card-title {
  font-size: 13px;
  font-weight: 600;
  color: #f1f5f9;
  line-height: 1.3;
}

@media (max-width: 768px) {
  body,
  main,
  .app-main,
  .main-content-with-sidebar,
  .dashboard-container {
    padding-bottom: 84px !important;
  }

  .bottom-nav-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 64px !important;
    background: rgba(15, 23, 42, 0.94) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4) !important;
    z-index: 9999 !important;
    align-items: center !important;
    justify-content: space-around !important;
    padding: 0 4px !important;
  }

  .bottom-nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    height: 100% !important;
    color: var(--text-muted, #94a3b8) !important;
    text-decoration: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    padding: 4px 0 !important;
    user-select: none !important;
    background: transparent !important;
    border: none !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .bottom-nav-item:hover,
  .bottom-nav-item:active {
    color: var(--text-primary, #f8fafc) !important;
  }

  .bottom-nav-item.active {
    color: var(--primary-light, #818cf8) !important;
  }

  .bottom-nav-item.active::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 25% !important;
    right: 25% !important;
    height: 3px !important;
    background: var(--gradient-primary, linear-gradient(135deg, #6366f1 0%, #3b82f6 100%)) !important;
    border-radius: 0 0 4px 4px !important;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.6) !important;
  }

  .bottom-nav-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 26px !important;
    transition: transform 0.2s ease !important;
  }

  .bottom-nav-item.active .bottom-nav-icon {
    transform: translateY(-2px) scale(1.1) !important;
  }

  .bottom-nav-item.active .bottom-nav-icon svg {
    stroke: var(--primary-light, #818cf8) !important;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.4)) !important;
  }

  .bottom-nav-label {
    font-size: 11px !important;
    font-weight: 500 !important;
    margin-top: 2px !important;
    letter-spacing: -0.01em !important;
    transition: color 0.2s ease !important;
  }

  .bottom-nav-item.active .bottom-nav-label {
    font-weight: 700 !important;
    color: #ffffff !important;
  }

  .bottom-nav-badge {
    position: absolute !important;
    top: -4px !important;
    right: -10px !important;
    background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%) !important;
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 800 !important;
    padding: 1px 4px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 6px rgba(236, 72, 153, 0.4) !important;
  }
}

  /* ---- Chat page: sidebar as overlay ---- */
  #chat-history-sidebar {
    position: fixed !important;
    left: -280px !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    top: 0 !important;
    z-index: 1000 !important;
    transition: left 0.3s ease;
  }

  #chat-history-sidebar.open {
    left: 0 !important;
  }

  #chat-menu-toggle-btn {
    display: flex !important;
  }

  .main-chat-wrapper {
    width: 100% !important;
  }

  /* ---- Hide desktop-only elements ---- */
  .hidden-mobile,
  .nav-menu,
  .nav-actions {
    display: none !important;
  }

  /* ---- Landing page mobile nav dropdown ---- */
  .nav-menu.mobile-open {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(16px);
    padding: 16px 24px;
    gap: 12px !important;
    border-bottom: var(--border-glass);
    z-index: 100;
    box-shadow: var(--shadow-lg);
  }

  .nav-actions.mobile-open {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(16px);
    padding: 0 24px 16px;
    gap: 12px !important;
    z-index: 100;
    margin-top: 170px;
  }

  /* ---- Sidebar transitions to Off-canvas Overlay on Mobile ---- */
  .sidebar {
    position: fixed !important;
    width: 280px !important;
    height: 100vh !important;
    height: 100dvh !important;
    top: 0 !important;
    left: -280px !important;
    bottom: 0 !important;
    z-index: 1000 !important;
    transition: left 0.3s ease, transform 0.3s ease;
    box-shadow: var(--shadow-lg);
    overflow-y: auto !important;
  }

  .sidebar.open {
    left: 0 !important;
  }

  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: var(--backdrop-blur);
    z-index: 999;
    display: none;
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* ---- Override inline margin-left for sidebar pages ---- */
  .main-content-with-sidebar,
  [style*="margin-left: 260px"] {
    margin-left: 0 !important;
    width: 100% !important;
  }

  /* ---- Override inline main padding ---- */
  .app-main[style*="margin-left"],
  main[style*="padding: 32px"],
  .app-main[style*="padding: 40px"] {
    margin-left: 0 !important;
    padding: var(--space-4) !important;
    width: 100% !important;
  }

  /* ---- Grid turns single column ---- */
  .grid-layout {
    grid-template-columns: 1fr !important;
  }

  /* ---- Override ALL inline fixed grid-template-columns for mobile ---- */
  [style*="grid-template-columns"]:not([style*="auto-fit"]):not([style*="auto-fill"]) {
    grid-template-columns: 1fr !important;
  }

  /* ---- Grid with auto-fit: allow smaller min values ---- */
  [style*="auto-fit"] {
    grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)) !important;
  }

  /* ---- Dashboard two-column override ---- */
  .grid-dashboard-columns {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* ---- Jobs / Universities sidebar+content layout ---- */
  .grid-jobs-layout {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }

  /* ---- Text overflow prevention ---- */
  h1, h2, h3, h4, h5, h6,
  p, span, a, li, td, th, label, div {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
  }

  .text-gradient {
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
  }

  /* ---- Typography Adjustments ---- */
  h1 { font-size: var(--text-2xl) !important; }
  h2 { font-size: var(--text-xl) !important; }
  h3 { font-size: var(--text-lg) !important; }

  /* ---- Button stacking on mobile ---- */
  .btn {
    white-space: normal;
    word-wrap: break-word;
    text-align: center;
  }

  .btn-md, .btn-lg {
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-sm);
  }

  [style*="display: flex"][style*="gap"] {
    flex-wrap: wrap !important;
  }

  /* ---- Welcome banner adjustments ---- */
  .card[style*="gradient-hero"] {
    padding: 20px !important;
  }

  /* ---- Kanban board mobile scroll view ---- */
  #kanban-view-container {
    min-width: 0 !important;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    padding-bottom: 20px;
  }

  .kanban-column {
    min-width: 85vw !important;
    scroll-snap-align: start;
  }

  /* ---- Chat Bubbles expand ---- */
  .chat-bubble-user, .chat-bubble-ai {
    max-width: 90%;
  }

  .chat-container {
    height: calc(100vh - 120px);
    border-radius: 0;
  }

  /* ---- Modal turns into bottom sheet ---- */
  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin-top: auto;
  }

  .toast-container {
    bottom: var(--space-4);
    right: var(--space-4);
    left: var(--space-4);
  }

  .toast {
    min-width: 100%;
  }

  /* ---- Flex between responsive ---- */
  .flex-between {
    flex-wrap: wrap;
    gap: 8px;
  }

  /* ---- Card stat improvements ---- */
  .card-stat {
    flex-direction: row;
    gap: var(--space-3);
  }

  /* ---- Admin page sidebar override ---- */
  .sidebar[style*="position: fixed"][style*="width: 260px"] {
    left: -280px !important;
    width: 280px !important;
  }

  .sidebar[style*="position: fixed"][style*="width: 260px"].open {
    left: 0 !important;
  }

  /* ---- Fixed width input fields ---- */
  input[style*="width: 280px"],
  input[style*="width: 240px"] {
    width: 100% !important;
  }

  /* ---- Table responsiveness ---- */
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ---- Header bar adjustments ---- */
  .app-header {
    padding: 12px 16px !important;
    flex-direction: column;
    align-items: flex-start !important;
    gap: 8px;
  }

  .app-header h1 {
    font-size: var(--text-lg) !important;
  }

  /* ---- Visa calculator main ---- */
  .app-main[style*="width: calc(100%"] {
    width: 100% !important;
    padding: var(--space-4) !important;
    margin-left: 0 !important;
  }

  /* ---- Profile/Form grid columns ---- */
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* ---- Badge / tag overflow ---- */
  .badge {
    white-space: normal;
    word-wrap: break-word;
  }

  /* ---- Landing hero search bar ---- */
  .hero-section .glass-panel {
    padding: 12px !important;
  }

  /* ---- Landing hero section ---- */
  .hero-section {
    padding: 30px 0 60px !important;
  }

  /* ---- Pricing cards / feature cards ---- */
  .glass-panel, .card {
    max-width: 100%;
    overflow: hidden;
  }
}

/* ── 3. Small Smartphones (max-width: 480px) ── */
@media (max-width: 480px) {
  html {
    font-size: 15px;
  }

  .btn-block {
    width: 100%;
  }

  .btn-icon {
    width: 40px !important;
    height: 40px !important;
  }

  .btn-inline {
    width: auto;
  }

  .card {
    padding: var(--space-3);
    border-radius: var(--radius-md);
  }

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

  .tabs {
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .input-field, .input-select {
    padding: var(--space-3);
  }

  /* Even smaller button text */
  .btn-md, .btn-lg {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }

  /* Welcome banner tighter */
  h1 { font-size: var(--text-xl) !important; }
  h2 { font-size: var(--text-lg) !important; }

  /* Dashboard stat cards stack */
  .card-stat-number {
    font-size: var(--text-xl);
  }

  .container {
    padding-left: var(--space-3);
    padding-right: var(--space-3);
  }

  /* Make sure main content has padding */
  main[style*="padding"] {
    padding: var(--space-3) !important;
  }

  /* Hero section CTA buttons stack */
  .hero-section .flex-center[style*="gap"] {
    flex-direction: column;
    width: 100%;
  }

  .hero-section .btn {
    width: 100%;
  }
}

/* ── 4. Mobile Bottom Navigation Bar (Native App Style) ── */
.bottom-nav-bar {
  display: none;
}

@media (max-width: 768px) {
  body,
  main,
  .app-main,
  .main-content-with-sidebar {
    padding-bottom: 72px !important;
  }

  .bottom-nav-bar {
    display: flex !important;
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 64px !important;
    background: rgba(15, 23, 42, 0.94) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4) !important;
    z-index: 9999 !important;
    align-items: center !important;
    justify-content: space-around !important;
    padding: 0 4px !important;
  }

  .bottom-nav-item {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    flex: 1 !important;
    height: 100% !important;
    color: var(--text-muted, #94a3b8) !important;
    text-decoration: none !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
    position: relative !important;
    padding: 4px 0 !important;
    user-select: none !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .bottom-nav-item:hover,
  .bottom-nav-item:active {
    color: var(--text-primary, #f8fafc) !important;
  }

  .bottom-nav-item.active {
    color: var(--primary-light, #818cf8) !important;
  }

  .bottom-nav-item.active::before {
    content: '' !important;
    position: absolute !important;
    top: 0 !important;
    left: 25% !important;
    right: 25% !important;
    height: 3px !important;
    background: var(--gradient-primary, linear-gradient(135deg, #6366f1 0%, #3b82f6 100%)) !important;
    border-radius: 0 0 4px 4px !important;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.6) !important;
  }

  .bottom-nav-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    height: 26px !important;
    transition: transform 0.2s ease !important;
  }

  .bottom-nav-item.active .bottom-nav-icon {
    transform: translateY(-2px) scale(1.1) !important;
  }

  .bottom-nav-item.active .bottom-nav-icon svg {
    stroke: var(--primary-light, #818cf8) !important;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.4)) !important;
  }

  .bottom-nav-label {
    font-size: 11px !important;
    font-weight: 500 !important;
    margin-top: 2px !important;
    letter-spacing: -0.01em !important;
    transition: color 0.2s ease !important;
  }

  .bottom-nav-item.active .bottom-nav-label {
    font-weight: 700 !important;
    color: #ffffff !important;
  }

  .bottom-nav-badge {
    position: absolute !important;
    top: -4px !important;
    right: -10px !important;
    background: linear-gradient(135deg, #ec4899 0%, #8b5cf6 100%) !important;
    color: #ffffff !important;
    font-size: 9px !important;
    font-weight: 800 !important;
    padding: 1px 4px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 6px rgba(236, 72, 153, 0.4) !important;
  }
}

