/* ==========================================================================
   SkillLink — Comprehensive Responsive & Mobile System (responsive.css)
   ========================================================================== */

/* Prevent horizontal overflow globally */
html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

/* Background shapes — scale down on mobile to prevent scrollbar issues */
@media (max-width: 768px) {
  .bg-shape {
    transform: scale(0.5) !important;
  }
  .shape-1 { width: 280px; height: 280px; top: -80px; right: -60px; }
  .shape-2 { width: 200px; height: 200px; }
  .shape-3 { width: 140px; height: 240px; }
  .shape-4 { width: 180px; height: 180px; }
  .shape-5 { width: 160px; height: 160px; }
  .shape-6 { width: 220px; height: 130px; }
}

/* Large Laptops & Tablets (< 1024px) */
@media (max-width: 1024px) {
  .marketplace-content {
    grid-template-columns: 1fr;
  }

  .dashboard-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 260px;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(6px);
    z-index: 999;
  }

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

  .mobile-toggle {
    display: block !important;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 32px;
  }

  /* Filter panel stacks on tablet */
  .filter-panel {
    margin-bottom: 20px;
  }
}

/* Mobile Devices (< 768px) */
@media (max-width: 768px) {
  .navbar {
    width: calc(100% - 24px);
    padding: 10px 14px;
    top: 10px;
    border-radius: var(--radius-md);
  }

  .logo {
    font-size: 1.15rem;
    gap: 8px;
  }

  .logo-mark-svg {
    width: 30px;
    height: 30px;
  }

  /* Stunning Liquid Glass Mobile Dropdown Menu */
  .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border: 1.5px solid rgba(255, 255, 255, 0.95);
    border-radius: var(--radius-lg);
    flex-direction: column;
    padding: 16px;
    gap: 8px;
    box-shadow: 0 24px 60px -10px rgba(2, 132, 199, 0.22), 0 10px 25px rgba(0, 0, 0, 0.08);
    z-index: 1000;
    transform: translateY(-8px) scale(0.98);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  }

  .nav-links.active {
    display: flex;
    transform: translateY(0) scale(1);
    opacity: 1;
  }

  .nav-links a {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: all 0.2s ease;
  }

  .nav-links a:hover,
  .nav-links a.active {
    background: rgba(2, 132, 199, 0.1);
    color: var(--primary);
    border-color: rgba(2, 132, 199, 0.25);
    transform: translateX(4px);
  }

  .mobile-nav-toggle {
    display: flex !important;
  }

  /* Hero Section */
  .hero-title {
    font-size: 2.1rem !important;
    line-height: 1.25 !important;
    letter-spacing: -0.02em;
  }

  /* Responsive Buttons with Description */
  .cta-group {
    flex-direction: column;
    width: 100%;
    gap: 14px;
  }

  .cta-group .btn,
  .cta-group .btn-with-desc {
    width: 100%;
    justify-content: flex-start;
  }

  .btn-with-desc {
    width: 100%;
    padding: 16px 20px;
  }

  /* Stats Grid */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px 14px;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  /* Role Selection and Register Page */
  .role-selector {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .role-card {
    width: 100% !important;
    padding: 20px 18px !important;
  }

  .auth-card {
    padding: 28px 18px !important;
    margin: 10px auto;
  }

  .form-row {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  /* Cards */
  .card-header-row,
  .job-card-top {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  /* Tables */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -8px;
    padding: 0 8px;
  }

  .custom-table {
    min-width: 540px;
    font-size: 0.85rem;
  }

  .custom-table th,
  .custom-table td {
    padding: 10px 12px;
    white-space: nowrap;
  }

  /* Footer */
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .footer {
    padding: 40px 0 24px;
  }

  /* Main content padding */
  .main-wrapper main {
    padding: 16px !important;
  }

  /* Top navbar for dashboards */
  .top-navbar {
    padding: 0 16px;
    height: 64px;
    gap: 10px;
  }

  .top-navbar h2 {
    font-size: 1rem !important;
  }

  /* Welcome banner */
  .glass-card h1 {
    font-size: 1.35rem;
  }

  /* Category strip on marketplace */
  .category-strip {
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 8px;
    overflow-x: auto;
  }

  .category-card {
    padding: 8px 14px;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  /* Job cards */
  .job-glass-card {
    padding: 18px;
  }

  /* Marketplace layout */
  .marketplace-layout {
    padding: 0 12px;
    margin: 16px auto;
  }

  /* Search bar */
  .search-bar-wrap input {
    height: 46px;
    font-size: 0.9rem;
  }

  /* Modal responsive */
  .modal-overlay .modal-content,
  .glass-card[style*="max-width"] {
    width: 94% !important;
    max-width: 100% !important;
    margin: auto;
    max-height: 88vh;
    overflow-y: auto;
    padding: 22px 18px !important;
  }

  /* Container padding */
  .container {
    padding: 0 16px;
  }

  /* Nav auth actions */
  .auth-btn-group {
    gap: 8px !important;
  }

  .auth-btn-group .btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  /* User nav badge in navbar */
  .user-nav-badge {
    gap: 6px !important;
  }

  .user-nav-badge .btn {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
}

/* Small Screens (< 480px) */
@media (max-width: 480px) {
  .hero-title {
    font-size: 1.7rem !important;
  }

  .top-navbar {
    padding: 0 12px;
    height: 58px;
  }

  .stat-card {
    padding: 14px;
  }

  .stat-card .stat-icon-wrap {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    margin-bottom: 8px;
  }

  .stat-label {
    font-size: 0.7rem;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  /* Stats grid single column on very small screens */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Navbar logo */
  .logo {
    font-size: 1.15rem;
  }

  .logo-mark-svg {
    width: 28px;
    height: 28px;
  }

  /* Glass cards padding */
  .glass-card {
    padding: 16px;
  }

  /* Freelancer cards grid */
  #freelancersList {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  /* Dashboard welcome banner */
  .main-wrapper main > .glass-card:first-child {
    padding: 20px !important;
    margin-bottom: 20px !important;
  }

  /* Modal on tiny screens */
  .modal-overlay .modal-content {
    width: 96% !important;
    padding: 20px !important;
  }

  /* Section padding on homepage */
  section[id] {
    padding: 50px 0 !important;
  }

  /* Grid items in categories */
  [style*="grid-template-columns: repeat(auto-fit"] {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
}

/* Touch target minimums for all interactive elements */
@media (hover: none) and (pointer: coarse) {
  .btn,
  .btn-sm,
  .nav-link,
  .category-card,
  input,
  select,
  textarea {
    min-height: 44px;
  }

  .btn-sm {
    padding: 10px 16px;
  }
}

@media (max-width: 768px) {
  body#clientDashboardRoot #chatInterfaceContainer,
  body#freelancerDashboardRoot #chatInterfaceContainer {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(0, 1fr);
    height: calc(100vh - 82px) !important;
    height: calc(100dvh - 82px) !important;
    min-height: 320px;
    width: 100%;
    padding: 0 !important;
    border-radius: 14px !important;
  }

  body#clientDashboardRoot .main-wrapper > main,
  body#freelancerDashboardRoot .main-wrapper > main {
    padding: 12px !important;
  }

  #chatInterfaceContainer > div:first-child,
  #chatInterfaceContainer > div:last-child {
    grid-column: 1;
    min-width: 0;
    min-height: 0;
    width: 100%;
  }

  #chatInterfaceContainer > div:last-child {
    display: none !important;
  }

  #chatInterfaceContainer.mobile-chat-open > div:first-child {
    display: none !important;
  }

  #chatInterfaceContainer.mobile-chat-open > div:last-child {
    display: flex !important;
  }

  #chatInterfaceContainer > div:last-child > div:first-child {
    padding: 10px 12px !important;
  }

  .chat-back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-dark);
    cursor: pointer;
  }

  .chat-back-button .svg-icon {
    width: 22px;
    height: 22px;
  }

  #chatMessagesBody {
    min-height: 0;
    padding: 14px !important;
  }

  #sendMessageForm {
    flex: 0 0 auto;
    gap: 8px !important;
    padding: 10px !important;
    padding-bottom: max(10px, env(safe-area-inset-bottom)) !important;
  }

  #chatInput {
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
  }

  #sendMessageForm button[type="submit"] {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 10px 14px !important;
  }
}

@media (min-width: 769px) {
  .chat-back-button {
    display: none;
  }
}