/* ============================
   ThreadsBot Mobile Improvements - ENHANCED
   ============================ */

/* Tablet Devices (768px and below) */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 0px;
  }

  body {
    font-size: 14px;
  }

  button, a, input[type="button"], input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    width: 100%;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    padding: 12px 16px;
  }

  .page-title {
    font-size: 18px;
  }

  .content-area {
    padding: 12px;
  }

  .card {
    padding: 12px;
    margin-bottom: 12px;
  }

  input, textarea, select {
    font-size: 16px;
    padding: 12px;
    width: 100%;
    box-sizing: border-box;
  }

  .btn {
    padding: 12px 16px;
    font-size: 14px;
    width: 100%;
  }

  table {
    font-size: 12px;
    width: 100%;
  }

  th, td {
    padding: 8px 6px;
  }

  .grid, .grid-2, .grid-3, .dashboard-grid, .two-column {
    grid-template-columns: 1fr !important;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .stat-card {
    padding: 12px;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
  }
}

/* Mobile Devices (480px and below) */
@media (max-width: 480px) {
  :root {
    --sidebar-width: 100%;
  }

  body {
    font-size: 13px;
  }

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

  .sidebar.open {
    left: 0;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  .topbar {
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition);
  }

  .menu-toggle:active {
    background: var(--bg-card-hover);
  }

  .page-title {
    font-size: 14px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .content-area {
    padding: 10px;
  }

  .card {
    padding: 10px;
    margin-bottom: 10px;
  }

  .form-group {
    margin-bottom: 10px;
  }

  label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 500;
  }

  input, textarea, select {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    box-sizing: border-box;
  }

  .btn {
    width: 100%;
    padding: 10px;
    font-size: 13px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    min-height: 44px;
  }

  .btn-primary {
    background: var(--accent-primary);
    color: white;
  }

  .btn-primary:active {
    opacity: 0.9;
  }

  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .btn-group .btn {
    width: 100%;
  }

  table {
    width: 100%;
    font-size: 11px;
    overflow-x: auto;
  }

  th, td {
    padding: 6px 4px;
    text-align: left;
  }

  .nav-menu {
    display: flex;
    flex-direction: column;
  }

  .nav-item {
    width: 100%;
  }

  .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    width: 100%;
  }

  .nav-icon {
    font-size: 16px;
    min-width: 24px;
  }

  .alert {
    padding: 10px;
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
  }

  .grid, .grid-2, .grid-3, .dashboard-grid, .two-column {
    grid-template-columns: 1fr !important;
  }

  .stats-grid {
    grid-template-columns: 1fr !important;
  }

  .stat-card {
    padding: 10px;
  }

  .stat-value {
    font-size: 18px;
  }

  .modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  .modal-content {
    max-height: 90vh;
    overflow-y: auto;
  }

  .dropdown {
    width: 100%;
  }

  .mt-1 { margin-top: 6px; }
  .mt-2 { margin-top: 10px; }
  .mt-3 { margin-top: 12px; }
  .mb-1 { margin-bottom: 6px; }
  .mb-2 { margin-bottom: 10px; }
  .mb-3 { margin-bottom: 12px; }
  .p-1 { padding: 6px; }
  .p-2 { padding: 10px; }
  .p-3 { padding: 12px; }

  .sidebar-footer {
    padding: 10px;
    text-align: center;
    font-size: 11px;
  }

  body, html {
    overflow-x: hidden;
  }

  .list-item {
    padding: 10px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  h1 { font-size: 18px; }
  h2 { font-size: 16px; }
  h3 { font-size: 14px; }
  h4 { font-size: 13px; }
  h5 { font-size: 12px; }
  h6 { font-size: 11px; }
}

/* Small Mobile (360px and below) */
@media (max-width: 360px) {
  body {
    font-size: 12px;
  }

  .topbar {
    padding: 8px;
  }

  .page-title {
    font-size: 12px;
  }

  .content-area {
    padding: 8px;
  }

  .card {
    padding: 8px;
  }

  .btn {
    padding: 8px;
    font-size: 12px;
  }

  input, textarea, select {
    padding: 8px;
    font-size: 14px;
  }

  h1 { font-size: 16px; }
  h2 { font-size: 14px; }
  h3 { font-size: 12px; }
}

/* Landscape orientation */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    height: auto;
    max-height: 100vh;
    overflow-y: auto;
  }

  .topbar {
    padding: 8px 12px;
  }

  .content-area {
    padding: 8px;
  }

  .card {
    padding: 8px;
  }
}

/* Print styles */
@media print {
  .sidebar, .topbar, .menu-toggle {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  body {
    background: white;
    color: black;
  }
}
