/* Mobile Responsive Styles for TalentIQ */

/* Extra Small Devices (< 480px) */
@media (max-width: 480px) {
  html {
    font-size: 14px;
    overflow-x: hidden;
  }

  body {
    font-size: 13px;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
  }

  h1 {
    font-size: 1.5rem;
  }
  h2 {
    font-size: 1.25rem;
  }
  h3 {
    font-size: 1.1rem;
  }
  h4 {
    font-size: 1rem;
  }
  h5 {
    font-size: 0.95rem;
  }
  
  .container {
    padding: 0 0.75rem;
    overflow-x: hidden;
  }

  /* Chat widget on extra small devices */
  .chat-widget {
    bottom: 1rem;
    right: 1rem;
    left: auto;
    width: auto;
  }

  .chat-window {
    width: calc(100vw - 2rem);
    max-width: 320px;
    height: 65vh;
    right: 0;
    left: auto;
  }

  .chat-toggle {
    width: auto;
    font-size: 0.8rem;
    padding: 0.625rem 0.875rem;
  }
  }
}

/* Small Devices (480px - 768px) */
@media (max-width: 768px) {
  body {
    font-size: 14px;
  }

  h1 {
    font-size: 1.75rem;
  }
  h2 {
    font-size: 1.5rem;
  }
  h3 {
    font-size: 1.25rem;
  }
  h4 {
    font-size: 1.1rem;
  }
}

/* Navigation Responsive Styles */
@media (max-width: 768px) {
  .dashboard-nav {
    padding: 0.75rem 1rem;
  }

  .nav-brand {
    flex: 1;
  }

  .nav-menu {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    flex-direction: column;
    padding: 1rem;
  }

  .nav-menu.mobile-open {
    display: flex;
  }

  .nav-link {
    padding: 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    width: 100%;
    text-align: left;
  }

  .nav-link:last-child {
    border-bottom: none;
  }

  .nav-toggle {
    display: flex;
    flex-direction: column;
    gap: 3px;
    cursor: pointer;
    padding: 0.5rem;
  }

  .nav-toggle .bar {
    width: 20px;
    height: 2px;
    background: #374151;
    transition: 0.3s;
  }

  .nav-toggle.active .bar:nth-child(1) {
    transform: rotate(-45deg) translate(-5px, 6px);
  }

  .nav-toggle.active .bar:nth-child(2) {
    opacity: 0;
  }

  .nav-toggle.active .bar:nth-child(3) {
    transform: rotate(45deg) translate(-5px, -6px);
  }

  /* User dropdown adjustments */
  .user-dropdown {
    position: relative;
  }

  .dropdown-menu {
    right: 0;
    left: auto;
    min-width: 200px;
  }
}

/* Container and Layout Responsive Styles */
@media (max-width: 1200px) {
  .container {
    max-width: 1024px;
    padding: 0 2rem;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }

  /* Two-column layouts become single column */
  .jobs-layout,
  .learning-layout,
  .cv-layout {
    flex-direction: column;
    gap: 2rem;
  }

  .jobs-sidebar,
  .learning-sidebar {
    order: 2;
  }

  .jobs-results,
  .learning-main,
  .cv-builder {
    order: 1;
    width: 100%;
  }

  .cv-preview {
    order: 3;
    width: 100%;
  }
}

/* Job Cards Responsive */
@media (max-width: 768px) {
  .jobs-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .job-card {
    padding: 1rem;
  }

  .job-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .save-job-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
  }

  .job-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  .job-footer {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .apply-btn {
    width: 100%;
    justify-content: center;
  }
}

/* Course Cards Responsive */
@media (max-width: 768px) {
  .courses-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .course-card {
    max-width: none;
  }

  .course-stats {
    flex-direction: column;
    gap: 0.5rem;
  }

  .rating {
    flex-direction: column;
    align-items: flex-start;
  }

  .course-footer {
    flex-direction: column;
    gap: 1rem;
  }

  .enroll-btn {
    width: 100%;
    justify-content: center;
  }

  /* List view adjustments for mobile */
  .courses-grid.list-layout .course-card {
    flex-direction: column;
  }

  .courses-grid.list-layout .course-image {
    width: 100%;
    height: 200px;
  }
}

/* CV Builder Responsive */
@media (max-width: 768px) {
  .cv-layout {
    flex-direction: column;
  }

  .cv-builder {
    order: 1;
  }

  .cv-preview {
    order: 2;
    display: none;
  }

  .cv-preview.show-mobile {
    display: block;
  }

  .form-row {
    flex-direction: column;
  }

  .form-actions {
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 1rem;
    margin: -1rem -1rem 0;
    z-index: 10;
  }

  .form-actions button {
    flex: 1;
    min-width: 0;
  }

  .cv-document {
    transform: scale(0.8);
    transform-origin: top left;
    width: 125%;
  }
}

/* Filter Sidebar Mobile */
@media (max-width: 768px) {
  .mobile-filter-toggle {
    display: block;
    width: 100%;
    background: #6366f1;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 1rem;
    cursor: pointer;
  }

  .jobs-sidebar,
  .learning-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 1001;
    padding: 1rem;
    overflow-y: auto;
  }

  .jobs-sidebar.show-mobile,
  .learning-sidebar.show-mobile {
    display: block;
  }

  /* Add close button for mobile filters */
  .jobs-sidebar::before,
  .learning-sidebar::before {
    content: "× Close Filters";
    display: block;
    background: #f3f4f6;
    margin: -1rem -1rem 1rem;
    padding: 1rem;
    cursor: pointer;
    font-weight: 500;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
  }
}

/* Search and Controls Responsive */
@media (max-width: 768px) {
  .search-form {
    flex-direction: column;
    gap: 1rem;
  }

  .search-input-group,
  .location-input-group,
  .category-select-group {
    width: 100%;
  }

  .search-btn {
    width: 100%;
    padding: 1rem;
  }

  .results-header {
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
  }

  .controls {
    flex-direction: column;
    gap: 1rem;
  }

  .sort-select {
    width: 100%;
  }

  .view-toggle {
    align-self: center;
  }
}

/* Modal Responsive */
@media (max-width: 768px) {
  .job-modal-content,
  .course-modal-content {
    width: 95vw;
    height: 90vh;
    margin: 5vh auto;
    overflow-y: auto;
  }

  .job-modal-footer,
  .course-modal-footer {
    flex-direction: column;
    gap: 1rem;
  }

  .job-modal-footer button,
  .course-modal-footer button {
    width: 100%;
  }
}

/* Chat Widget Mobile */
@media (max-width: 768px) {
  .chat-widget {
    bottom: 1rem;
    right: 1rem;
    left: auto;
  }

  .chat-window {
    width: calc(100vw - 2rem);
    max-width: 350px;
    height: 70vh;
    bottom: 60px;
    right: 0;
    left: auto;
  }

  .chat-toggle {
    width: auto;
    border-radius: 25px;
    padding: 0.75rem 1rem;
  }

  .chat-label {
    display: inline;
  }
}

/* Footer Responsive */
@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
    gap: 2rem;
    text-align: center;
  }

  .footer-bottom {
    flex-direction: column;
    gap: 1rem;
    text-align: center;
  }
}

/* Utility Classes for Mobile */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .show-mobile {
    display: block !important;
  }

  .flex-mobile {
    display: flex !important;
  }

  .text-center-mobile {
    text-align: center !important;
  }

  .full-width-mobile {
    width: 100% !important;
  }
}

/* Touch-friendly improvements for all touch devices */
@media (hover: none) and (pointer: coarse) {
  button,
  .btn,
  .nav-link,
  .dropdown-item {
    min-height: 44px;
    min-width: 44px;
  }

  .job-card,
  .course-card {
    padding: 1rem;
  }

  .save-job-btn,
  .favorite-btn {
    padding: 0.75rem;
  }

  /* Improve tap target sizes */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  textarea,
  select {
    min-height: 44px;
    font-size: 16px;
  }

  a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}

/* Extra small devices (320px - 480px) */
@media (max-width: 480px) {
  /* Forms */
  .form-input,
  .form-select,
  .form-textarea {
    font-size: 16px;
    min-height: 44px;
    padding: 0.75rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .form-group {
    margin-bottom: 1rem;
  }

  /* Buttons */
  button,
  .btn,
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .button-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  .button-group button {
    width: 100%;
  }

  /* Cards */
  .card {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  /* Modals */
  .modal-header {
    padding: 1rem;
  }

  .modal-body {
    padding: 1rem;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
  }

  .modal-footer {
    padding: 1rem;
    flex-direction: column;
    gap: 0.5rem;
  }

  .modal-footer button {
    width: 100%;
  }

  /* Chat widget */
  .chat-input-wrapper {
    gap: 0.5rem;
    padding: 0.75rem;
  }

  #chat-input-field {
    min-height: 40px;
    font-size: 16px;
  }

  /* Remove floating elements on very small screens */
  .float-start,
  .float-end {
    float: none;
    width: 100%;
    margin-bottom: 1rem;
  }
}

/* Small to medium devices (480px - 768px) */
@media (max-width: 768px) {
  /* Ensure proper spacing */
  .container {
    padding: 0 1rem;
  }

  /* Flexible grid layouts */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  /* Section spacing */
  section {
    padding: 1.5rem 0;
  }

  /* Card improvements */
  .card-body {
    padding: 1.25rem;
  }

  /* Table responsive */
  table {
    width: 100%;
    font-size: 0.9rem;
  }

  table th,
  table td {
    padding: 0.75rem 0.5rem;
  }

  /* Lists */
  ul, ol {
    padding-left: 1.25rem;
  }

  li {
    margin-bottom: 0.5rem;
  }

  /* Images */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Videos */
  iframe,
  video {
    max-width: 100%;
    height: auto;
  }

  /* Alert boxes */
  .alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-size: 0.95rem;
  }

  /* Badges and labels */
  .badge,
  .label {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
  }

  /* Pagination */
  .pagination {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .pagination button,
  .pagination a {
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
  }
}

/* Medium devices (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
  .container {
    max-width: 95%;
  }

  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .sidebar {
    width: 100%;
    margin-top: 1.5rem;
  }
}

/* Landscape orientation adjustments */
@media (max-width: 896px) and (orientation: landscape) {
  .chat-window {
    height: 60vh;
  }

  .job-modal-content,
  .course-modal-content {
    height: 80vh;
  }

  nav,
  .header {
    height: auto;
  }

  .dashboard-header {
    padding: 0.5rem 1rem;
  }

  .nav-menu {
    top: 50px;
  }
}

/* Print styles */
@media print {
  nav,
  .navbar,
  .chat-widget,
  .sidebar,
  button,
  .btn {
    display: none;
  }

  body {
    font-size: 12pt;
    line-height: 1.5;
  }

  .container {
    max-width: 100%;
  }
}

/* High DPI screens (Retina displays) */
@media (-webkit-min-device-pixel-ratio: 2),
  (min-resolution: 192dpi) {
  body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

