/**
 * MEDIA QUERIES
 * Полный адаптив для всех страниц магазина
 * Плавное уменьшение от 768px до 300px
 * Учтены: index.php, admin.php, form.php, orders.php, admin_login.php
 */

/* ============================================================
   768px - Планшеты (iPad, небольшие ноутбуки)
   ============================================================ */
@media (max-width: 1000px) {
  /* ---------- ОБЩИЕ ---------- */
  body {
    font-size: 15px;
  }

  .container {
    padding-left: 20px;
    padding-right: 20px;
  }

  /* ---------- ШАПКА (header) ---------- */
  .header {
    padding-top: 30px;
    padding-bottom: 30px;
  }

  .header .display-4 {
    font-size: 2rem;
  }

  .header .lead {
    font-size: 1rem;
  }

  .header img {
    width: 70px;
  }

  /* ---------- ТОВАРЫ (index.php) ---------- */
  .product-img {
    width: 200px;
  }

  .item-title {
    font-size: 1.2rem;
    height: auto;
    min-height: 50px;
  }

  .details-wrapper {
    width: 90%;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
  }

  .price__currency {
    font-size: 1.2rem;
  }

  /* ---------- КОРЗИНА (index.php) ---------- */
  .cart-item__top {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .cart-item__img img {
    text-align: center;
    max-width: 80px;
  }

  .cart-item__title {
    font-size: 14px;
  }

  .cart-item__details .price__currency {
    font-size: 16px;
  }

  .cart-total {
    font-size: 16px;
  }

  .total-price {
    font-size: 1.3rem !important;
  }

  /* ---------- ФОРМА ЗАКАЗА (index.php) ---------- */
  #order-form .form-control {
    font-size: 14px;
    padding: 8px 12px;
  }

  /* ---------- КНОПКИ УПРАВЛЕНИЯ (index.php, admin.php, form.php) ---------- */
  .admin-buttons .btn {
    padding: 6px 14px;
    font-size: 13px;
  }

  /* ---------- АДМИНКА - ТОВАРЫ (admin.php) ---------- */
  .product-row {
    flex-wrap: wrap;
    gap: 10px;
  }

  .product-row img {
    width: 50px;
    height: 50px;
  }

  .product-info {
    flex: 1 1 100%;
    order: 3;
  }

  .product-actions {
    order: 4;
    width: 100%;
    justify-content: flex-end;
  }

  .product-actions .btn {
    font-size: 12px;
    padding: 4px 10px;
  }

  /* ---------- АДМИНКА - ЗАКАЗЫ (orders.php) ---------- */
  .order-card {
    padding: 15px;
  }

  .order-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .order-client strong {
    min-width: 70px;
  }

  .order-items .item {
    font-size: 13px;
  }

  .order-total {
    font-size: 16px;
  }

  .order-actions .btn {
    font-size: 12px;
    padding: 4px 10px;
  }

  /* ---------- СТРАНИЦА ВХОДА (admin_login.php) ---------- */
  .login-card {
    padding: 30px !important;
    max-width: 350px !important;
  }

  .login-card h2 {
    font-size: 1.5rem !important;
  }

  .login-card .form-control {
    font-size: 14px !important;
    padding: 10px !important;
  }

  .login-card .btn-primary {
    font-size: 14px !important;
    padding: 10px !important;
  }

  /* ---------- ФОРМА ДОБАВЛЕНИЯ ТОВАРА (form.php) ---------- */
  .form-card {
    padding: 25px !important;
    max-width: 500px !important;
  }

  .form-card h1 {
    font-size: 1.8rem !important;
  }

  .field-group input,
  .field-group .input-with-suffix input {
    font-size: 14px !important;
    padding: 8px 12px !important;
  }

  .field-group .suffix {
    font-size: 14px !important;
    padding: 8px 12px !important;
  }

  .file-btn {
    font-size: 13px !important;
    padding: 8px 16px !important;
  }

  .action-buttons .btn {
    font-size: 14px !important;
    padding: 10px 20px !important;
  }
}

/* ============================================================
   600px - Крупные телефоны (iPhone Plus, Android)
   ============================================================ */
@media (max-width: 600px) {
  /* ---------- ОБЩИЕ ---------- */
  body {
    font-size: 14px;
  }

  .container {
    padding-left: 15px;
    padding-right: 15px;
  }

  /* ---------- ШАПКА ---------- */
  .header {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  .header .display-4 {
    font-size: 1.6rem;
  }

  .header .lead {
    font-size: 0.9rem;
  }

  .header img {
    width: 60px;
  }

  /* ---------- ТОВАРЫ ---------- */
  .col-md-8 .col-sm-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  .product-img {
    width: 160px;
  }

  .item-title {
    font-size: 1rem;
    min-height: 40px;
  }

  .details-wrapper {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .items {
    width: 100px;
    font-size: 16px;
    height: 28px;
  }

  .items__control {
    width: 35px;
  }

  .items__current {
    width: 30px;
  }

  .price {
    text-align: center;
  }

  .price__currency {
    font-size: 1.1rem;
  }

  .btn {
    font-size: 13px;
    padding: 6px 14px;
  }

  /* ---------- КОРЗИНА (поднимается наверх) ---------- */
  .col-md-4 {
    order: -1;
    margin-bottom: 20px;
  }

  .cart-item__top {
    flex-direction: row;
  }

  .cart-item__img img {
    max-width: 70px;
  }

  .cart-item__desc {
    padding-left: 10px;
    padding-top: 10px;
  }

  .cart-item__title {
    font-size: 13px;
  }

  .cart-item__weight {
    font-size: 12px;
    margin-bottom: 10px;
  }

  .cart-item__details .price__currency {
    font-size: 14px;
    margin-left: 10px;
  }

  .cart-total {
    font-size: 14px;
  }

  .total-price {
    font-size: 1.1rem !important;
  }

  /* ---------- ФОРМА ЗАКАЗА ---------- */
  #order-form .form-control {
    font-size: 13px;
    padding: 6px 10px;
  }

  #order-form .btn-primary {
    font-size: 14px;
    padding: 10px;
  }

  /* ---------- КНОПКИ УПРАВЛЕНИЯ ---------- */
  .admin-buttons {
    gap: 6px;
    height: 40px;
  }

  .admin-buttons .btn {
    font-size: 12px;
    padding: 5px 12px;
  }

  /* ---------- АДМИНКА - ТОВАРЫ ---------- */

  .product-row img {
    width: 45px;
    height: 45px;
    margin-right: 10px;
  }

  .product-info strong {
    font-size: 13px;
  }

  .product-actions .btn-sm {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* ---------- АДМИНКА - ЗАКАЗЫ ---------- */
  .order-card {
    padding: 12px;
  }

  .order-id {
    font-size: 14px;
  }

  .order-date {
    font-size: 12px;
  }

  .order-client div {
    font-size: 13px;
  }

  .order-items .item {
    font-size: 12px;
    padding: 3px 0;
  }

  .order-total {
    font-size: 15px;
  }

  .order-actions .btn {
    font-size: 11px;
    padding: 3px 8px;
  }

  /* ---------- СТРАНИЦА ВХОДА ---------- */
  .login-card {
    padding: 25px !important;
    max-width: 320px !important;
    margin: 15px !important;
  }

  .login-card h2 {
    font-size: 1.3rem !important;
  }

  .login-card .form-control {
    font-size: 13px !important;
    padding: 8px !important;
  }

  .login-card .btn-primary {
    font-size: 13px !important;
    padding: 8px !important;
  }

  .login-card .logo img {
    width: 60px !important;
  }

  /* ---------- ФОРМА ДОБАВЛЕНИЯ ТОВАРА ---------- */
  .form-card {
    padding: 20px !important;
    max-width: 100% !important;
    margin: 10px !important;
  }

  .form-card h1 {
    font-size: 1.5rem !important;
  }

  .subhead {
    font-size: 13px !important;
  }

  .field-group input,
  .field-group .input-with-suffix input {
    font-size: 13px !important;
    padding: 6px 10px !important;
  }

  .field-group .suffix {
    font-size: 13px !important;
    padding: 6px 10px !important;
  }

  .file-btn {
    font-size: 12px !important;
    padding: 6px 12px !important;
  }

  .file-name {
    font-size: 12px !important;
  }

  .action-buttons .btn {
    font-size: 13px !important;
    padding: 8px 16px !important;
  }

  .checkbox-row label {
    font-size: 13px !important;
  }

  .extra-weight-block {
    font-size: 13px !important;
    padding: 10px !important;
  }

  /* ---------- ТОП-МЕНЮ АДМИНКИ ---------- */
  [style*="display: flex"][style*="justify-content: space-between"] {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }

  [style*="display: flex"][style*="justify-content: space-between"] > div {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
  }

  [style*="display: flex"][style*="justify-content: space-between"] .btn {
    font-size: 12px;
    padding: 5px 10px;
  }
}

/* ============================================================
   480px - Средние телефоны
   ============================================================ */
@media (max-width: 480px) {
  /* ---------- ОБЩИЕ ---------- */
  body {
    font-size: 13px;
  }

  .container {
    padding-left: 10px;
    padding-right: 10px;
  }

  h1,
  .h1 {
    font-size: 1.5rem;
  }

  h2,
  .h2 {
    font-size: 1.3rem;
  }

  h5,
  .h5 {
    font-size: 1rem;
  }

  /* ---------- ШАПКА ---------- */
  .header .display-4 {
    font-size: 1.3rem;
  }

  .header .lead {
    font-size: 0.8rem;
  }

  .header img {
    width: 50px;
  }

  /* ---------- ТОВАРЫ (по одному в ряд) ---------- */
  .col-md-8 .col-sm-6 {
    flex: 0 0 100%;
    max-width: 100%;
  }

  .product-img {
    width: 180px;
  }

  .item-title {
    font-size: 1.1rem;
    text-align: center;
  }

  .details-wrapper {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
  }

  .items {
    width: 90px;
    font-size: 14px;
    height: 26px;
  }

  .items__control {
    width: 30px;
    font-size: 14px;
  }

  .items__current {
    width: 30px;
    font-size: 14px;
  }

  .price__currency {
    font-size: 1rem;
  }

  .btn {
    font-size: 12px;
    padding: 5px 12px;
  }

  /* ---------- КОРЗИНА ---------- */
  .sticky-top {
    position: relative !important;
    top: 0 !important;
  }

  .cart-item__img img {
    max-width: 60px;
  }

  .cart-item__desc {
    padding-left: 8px;
    padding-top: 5px;
  }

  .cart-item__title {
    font-size: 12px;
  }

  .cart-item__weight {
    font-size: 11px;
    margin-bottom: 5px;
  }

  .cart-item__details .price__currency {
    font-size: 13px;
    margin-left: 8px;
  }

  .cart-total p {
    margin-bottom: 5px;
    font-size: 13px;
  }

  .total-price {
    font-size: 1rem !important;
  }

  .rouble {
    font-size: 1rem !important;
  }

  /* ---------- ФОРМА ЗАКАЗА ---------- */
  #order-form {
    padding: 12px 15px !important;
  }

  #order-form .form-control {
    font-size: 12px;
    padding: 5px 8px;
  }

  #order-form .btn-primary {
    font-size: 13px;
    padding: 8px;
  }

  /* ---------- КНОПКИ УПРАВЛЕНИЯ ---------- */
  .admin-buttons .btn {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* ---------- АДМИНКА - ТОВАРЫ ---------- */
  .product-row {
    padding: 10px;
    flex-direction: column;
    align-items: flex-start;
  }

  .product-row img {
    width: 60px;
    height: 60px;
    margin-right: 0;
    margin-bottom: 8px;
  }

  .product-info strong {
    font-size: 13px;
  }

  .product-actions {
    width: 100%;
    justify-content: flex-start;
    margin-top: 8px;
  }

  .product-actions .btn-sm {
    font-size: 11px;
    padding: 4px 8px;
  }

  /* ---------- АДМИНКА - ЗАКАЗЫ ---------- */
  .order-card {
    padding: 10px;
  }

  .order-id {
    font-size: 13px;
  }

  .order-date {
    font-size: 11px;
  }

  .badge-email,
  .badge-no-email {
    font-size: 10px;
    padding: 1px 6px;
  }

  .order-client div {
    font-size: 12px;
    margin-bottom: 2px;
  }

  .order-client strong {
    min-width: 60px;
  }

  .order-items {
    padding: 8px 10px;
  }

  .order-items .item {
    font-size: 11px;
    padding: 2px 0;
  }

  .order-total {
    font-size: 14px;
  }

  .order-actions .btn {
    font-size: 11px;
    padding: 3px 8px;
  }

  /* ---------- СТРАНИЦА ВХОДА ---------- */
  .login-card {
    padding: 20px !important;
    max-width: 100% !important;
    margin: 10px !important;
    border-radius: 15px !important;
  }

  .login-card h2 {
    font-size: 1.1rem !important;
  }

  .login-card .form-control {
    font-size: 12px !important;
    padding: 6px !important;
  }

  .login-card .btn-primary {
    font-size: 12px !important;
    padding: 6px !important;
  }

  .login-card .logo img {
    width: 50px !important;
  }

  /* ---------- ФОРМА ДОБАВЛЕНИЯ ТОВАРА ---------- */
  .form-card {
    padding: 15px !important;
    margin: 5px !important;
    border-radius: 15px !important;
  }

  .form-card h1 {
    font-size: 1.3rem !important;
  }

  .subhead {
    font-size: 12px !important;
  }

  .field-group label {
    font-size: 13px !important;
  }

  .field-group input,
  .field-group .input-with-suffix input {
    font-size: 12px !important;
    padding: 5px 8px !important;
  }

  .field-group .suffix {
    font-size: 12px !important;
    padding: 5px 8px !important;
  }

  .file-btn {
    font-size: 11px !important;
    padding: 5px 10px !important;
  }

  .file-name {
    font-size: 11px !important;
  }

  .action-buttons {
    flex-direction: column !important;
    gap: 8px !important;
  }

  .action-buttons .btn {
    font-size: 12px !important;
    padding: 8px !important;
    width: 100% !important;
  }

  .checkbox-row label {
    font-size: 12px !important;
  }

  .extra-weight-block {
    font-size: 12px !important;
    padding: 8px !important;
  }

  /* ---------- ТОП-МЕНЮ АДМИНКИ ---------- */
  [style*="display: flex"][style*="justify-content: space-between"] .btn {
    font-size: 11px;
    padding: 4px 8px;
  }

  [style*="display: flex"][style*="justify-content: space-between"] h1 {
    font-size: 1.2rem !important;
  }
}

/* ============================================================
   400px - Маленькие телефоны
   ============================================================ */
@media (max-width: 400px) {
  /* ---------- ОБЩИЕ ---------- */
  body {
    font-size: 12px;
  }

  .container {
    padding-left: 8px;
    padding-right: 8px;
  }

  h1,
  .h1 {
    font-size: 1.3rem;
  }

  h5,
  .h5 {
    font-size: 0.9rem;
  }

  /* ---------- ШАПКА ---------- */
  .header {
    padding-top: 15px;
    padding-bottom: 15px;
  }

  .header .display-4 {
    font-size: 1.1rem;
  }

  .header .lead {
    font-size: 0.7rem;
  }

  .header img {
    width: 40px;
  }

  /* ---------- ТОВАРЫ ---------- */
  .product-img {
    width: 150px;
  }

  .item-title {
    font-size: 1rem;
    min-height: 35px;
  }

  .items {
    width: 80px;
    font-size: 13px;
    height: 24px;
  }

  .items__control {
    width: 26px;
    font-size: 13px;
  }

  .items__current {
    width: 28px;
    font-size: 13px;
  }

  .price__currency {
    font-size: 0.9rem;
  }

  .btn {
    font-size: 11px;
    padding: 4px 10px;
  }

  /* ---------- КОРЗИНА ---------- */
  .cart-item__img img {
    max-width: 50px;
  }

  .cart-item__desc {
    padding-left: 6px;
  }

  .cart-item__title {
    font-size: 11px;
  }

  .cart-item__weight {
    font-size: 10px;
  }

  .cart-item__details .price__currency {
    font-size: 12px;
    margin-left: 5px;
  }

  .cart-total p {
    font-size: 12px;
  }

  .total-price {
    font-size: 0.9rem !important;
  }

  /* ---------- ФОРМА ЗАКАЗА ---------- */
  #order-form .form-control {
    font-size: 11px;
    padding: 4px 6px;
  }

  #order-form .btn-primary {
    font-size: 12px;
    padding: 6px;
  }

  /* ---------- КНОПКИ УПРАВЛЕНИЯ ---------- */
  .admin-buttons .btn {
    font-size: 10px;
    padding: 3px 8px;
  }

  /* ---------- АДМИНКА ---------- */
  .product-row {
    padding: 8px;
  }

  .product-row img {
    width: 50px;
    height: 50px;
  }

  .product-info strong {
    font-size: 12px;
  }

  .product-info div {
    font-size: 11px;
  }

  .product-actions .btn-sm {
    font-size: 10px;
    padding: 3px 6px;
  }

  /* ---------- АДМИНКА - ЗАКАЗЫ ---------- */
  .order-card {
    padding: 8px;
  }

  .order-id {
    font-size: 12px;
  }

  .order-date {
    font-size: 10px;
  }

  .order-client div {
    font-size: 11px;
  }

  .order-items .item {
    font-size: 10px;
  }

  .order-total {
    font-size: 13px;
  }

  .order-actions .btn {
    font-size: 10px;
    padding: 2px 6px;
  }

  /* ---------- СТРАНИЦА ВХОДА ---------- */
  .login-card {
    padding: 15px !important;
    border-radius: 12px !important;
  }

  .login-card h2 {
    font-size: 1rem !important;
  }

  .login-card .form-control {
    font-size: 11px !important;
    padding: 5px !important;
  }

  .login-card .btn-primary {
    font-size: 11px !important;
    padding: 5px !important;
  }

  .login-card .logo img {
    width: 40px !important;
  }

  /* ---------- ФОРМА ДОБАВЛЕНИЯ ТОВАРА ---------- */
  .form-card {
    padding: 12px !important;
  }

  .form-card h1 {
    font-size: 1.1rem !important;
  }

  .subhead {
    font-size: 11px !important;
  }

  .field-group label {
    font-size: 12px !important;
  }

  .field-group input,
  .field-group .input-with-suffix input {
    font-size: 11px !important;
    padding: 4px 6px !important;
  }

  .field-group .suffix {
    font-size: 11px !important;
    padding: 4px 6px !important;
  }

  .file-btn {
    font-size: 10px !important;
    padding: 4px 8px !important;
  }

  .file-name {
    font-size: 10px !important;
  }

  .action-buttons .btn {
    font-size: 11px !important;
    padding: 6px !important;
  }

  .checkbox-row label {
    font-size: 11px !important;
  }

  .extra-weight-block {
    font-size: 11px !important;
    padding: 6px !important;
  }

  /* ---------- ТОП-МЕНЮ АДМИНКИ ---------- */
  [style*="display: flex"][style*="justify-content: space-between"] .btn {
    font-size: 10px;
    padding: 3px 6px;
  }
}

/* ============================================================
   350px - Самые маленькие экраны
   ============================================================ */
@media (max-width: 350px) {
  /* ---------- ОБЩИЕ ---------- */
  .container {
    padding-left: 5px;
    padding-right: 5px;
  }

  /* ---------- ШАПКА ---------- */
  .header .display-4 {
    font-size: 1rem;
  }

  /* ---------- ТОВАРЫ ---------- */
  .product-img {
    width: 130px;
  }

  .item-title {
    font-size: 0.9rem;
    min-height: 30px;
  }

  .items {
    width: 70px;
    font-size: 12px;
    height: 22px;
  }

  .items__control {
    width: 22px;
    font-size: 12px;
  }

  .items__current {
    width: 26px;
    font-size: 12px;
  }

  /* ---------- КОРЗИНА ---------- */
  .cart-item__img img {
    max-width: 45px;
  }

  .cart-item__title {
    font-size: 10px;
  }

  .cart-item__details .price__currency {
    font-size: 11px;
  }

  /* ---------- КНОПКИ УПРАВЛЕНИЯ ---------- */
  .admin-buttons .btn {
    font-size: 9px;
    padding: 2px 6px;
  }

  /* ---------- ФОРМА ---------- */
  #order-form .btn-primary {
    font-size: 11px;
    padding: 5px;
  }

  .form-card {
    padding: 10px !important;
  }

  .form-card h1 {
    font-size: 1rem !important;
  }
}

/* ============================================================
   УТИЛИТЫ ДЛЯ СКРЫТИЯ НА МОБИЛЬНЫХ
   ============================================================ */
@media (max-width: 576px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 577px) and (max-width: 768px) {
  .hide-tablet {
    display: none !important;
  }
}

/* ============================================================
   ФИКС ДЛЯ STICKY НА МОБИЛЬНЫХ
   ============================================================ */
@media (max-width: 768px) {
  .sticky-top {
    position: relative !important;
    top: 0 !important;
  }
}

/* ============================================================
   ФИКС ДЛЯ ИЗОБРАЖЕНИЙ
   ============================================================ */
@media (max-width: 576px) {
  img {
    max-width: 100%;
    height: auto;
  }
}

/* ============================================================
   ПЛАВНЫЕ ПЕРЕХОДЫ
   ============================================================ */
* {
  transition: all 0.2s ease-in-out;
}
