/* base.css — основные стили проекта */

/* ======================
   Переменные и сброс
====================== */

:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --danger: #e63946;
    --success: #2a9d8f;
    --light: #f8f9fa;
    --dark: #212529;
    --gray: #6c757d;
    --light-gray: #e9ecef;
    --border: #dee2e6;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Roboto', sans-serif;
    background-color: #fafafa;
    color: var(--dark);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ======================
   Контейнер
====================== */

.container {
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ======================
   Шапка (Header)
====================== */

.header {
    background: white;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header__container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 15px;
    padding-right: 25px;
}

.header__left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.header__right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header__logo {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.header__user {
    color: var(--gray);
    text-decoration: none;
    font-weight: bold;
}

.header__user:hover {
    color: var(--primary);
    text-decoration: none;
}

.header__cart {
    position: relative;
    text-decoration: none;
    font-size: 1.4rem;
    color: var(--dark);
}

.cart-badge {
    background: var(--primary);
    color: white;
    font-size: 0.6rem;
    padding: 0.01rem 0.4rem;
    padding-top: 0.05rem;
    border-radius: 50%;
    position: absolute;
    top: -1px;
    right: -8px;
    text-align: center;
}

.main {
    flex: 1;
    padding: 2rem 0;
    padding-top: 1rem;
}

.messages {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert--success {
    background: #d1e7dd;
    color: #0f5132;
    border-color: #badbcc;
}

.alert--info {
    background: #d1e7dd;
    color: #0f5132;
    border-color: #badbcc;
}

.alert--error, .alert--danger {
    background: #f8d7da;
    color: #842029;
    border-color: #f1aeb5;
}

/* ======================
   Пустое состояние
====================== */

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray);
}

.empty-state .btn {
    margin-top: 1rem;
}

/* ======================
   Подвал (Footer)
====================== */

.footer {
    background: var(--dark);
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: auto;
}

/* ======================
   Типографика
====================== */

.page-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    text-align: center;
    color: var(--dark);
}

/* ======================
   Поиск с иконкой
====================== */

.search-form {
    margin: 0 auto 1rem;
    max-width: 1500px;
    width: 100%;
}

.search-wrapper {
    position: relative;
    display: flex;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.search-icon-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.search-icon {
    width: 20px;
    height: 20px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.search-icon-btn:hover .search-icon,
.search-input:focus + .search-icon-btn .search-icon {
    opacity: 1;
}
/* ======================
   Адаптивность
====================== */

@media (max-width: 768px) {
    .header__container {
        flex-wrap: wrap;
        gap: 0.8rem;
    }

    .header__left,
    .header__right {
        gap: 0.8rem;
        padding: 1rem 0;
        padding-right: 15px;
    }

    .header__logo {
        font-size: 1.4rem;
    }

    .page-title {
        font-size: 1.6rem;
    }

    .container {
        padding: 0 0.3rem;
    }
}

@media (max-width: 480px) {
    .header__right {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .header__user {
        width: 100%;
        text-align: right;
        order: -1;
    }
    
}

.icon {
    width: 25px;
    height: 25px;
    filter: brightness(0) saturate(100%) invert(50%);
}

/* Кнопка "Выйти" в шапке — выглядит как ссылка */
.header__logout-btn {
    background: none;
    border: none;
    color: var(--gray);
    font: inherit;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    display: inline;
    font-weight: bold;
    text-decoration: none;
}

.header__logout-btn:hover {
    color: var(--primary);
    text-decoration: none;
}

/* ======================
   Бургер-меню
====================== */

.burger-menu {
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 30px;
    height: 21px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.burger-menu span {
    display: block;
    height: 3px;
    width: 100%;
    background-color: var(--dark);
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* Адаптивность: бургер появляется на мобильных */
@media (max-width: 768px) {
    .burger-menu {
        display: flex;
    }

    /* Скрываем обычное левое меню по умолчанию */
    .header__left {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        box-shadow: var(--shadow-lg);
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        z-index: 999;
    }

    /* Показываем меню, если активно */
    .header__left.active {
        max-width: 20rem;
        display: flex;
    }

    /* Адаптируем контейнер хедера */
    .header__container {
        position: relative;
        flex-wrap: nowrap;
        justify-content: space-between;
        align-items: center;
        padding: 1rem 15px;
    }

    /* Убираем gap у .header__right, если нужно */
    .header__right {
        gap: 0.75rem;
    }

    /* Стили для выпадающего меню внутри мобильного */
    .dropdown {
        width: 100%;
    }

    .dropdown__toggle {
        width: 100%;
        text-align: left;
        padding: 0.5rem 0;
        background: none;
        border: none;
        font-weight: 500;
        cursor: pointer;
        color: var(--dark);
    }

    .dropdown__menu {
        position: static;
        display: none;
        flex-direction: column;
        gap: 0.5rem;
        padding-left: 1rem;
        margin-top: 0.5rem;
    }

    .dropdown__menu.show {
        display: flex;
    }

    .dropdown__menu a {
        text-decoration: none;
        color: var(--gray);
    }

    .dropdown__menu a:hover {
        color: var(--primary);
    }
}

/* Корзина */
.cart-items {
  margin-bottom: 24px;
}

.cart-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid #eee;
}

.cart-img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.cart-item__info {
  flex: 1;
}

.cart-item__info h3 {
  margin: 0 0 6px;
  font-size: 1.1em;
}

.cart-item__info p {
  margin: 0 0 10px;
  color: #666;
}

/* Строка управления: Grid */
.cart-item__controls-row {
  display: grid;
  grid-template-columns: auto auto 32px;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}

/* Кнопки +/- */
.cart-item__quantity-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.quantity-btn {
  width: 28px;
  height: 28px;
  font-size: 16px;
  border: 1px solid #ccc;
  background: #f9f9f9;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: gray;
}

.quantity-btn:hover {
  background: #e9e9e9;
}

.quantity-display {
  min-width: 24px;
  text-align: center;
  font-weight: bold;
}

/* Цена */
.cart-item__total {
  font-weight: bold;
  white-space: nowrap;
  text-align: right;
  font-size: 1em;
}

/* Кнопка удаления */
.cart-delete-form {
  margin: 0;
  display: flex;
  justify-content: center;
}

.cart-item__remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #e74c3c;
  width: 28px;
  height: 28px;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item__remove:hover {
  color: #c0392b;
  background: #fef6f6;
  border-radius: 4px;
}

/* Итог и кнопки */
.cart-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px solid #eee;
}

.total-amount {
  color: #2c3e50;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #777;
}

.empty-state .btn {
  margin-top: 16px;
}

/* Маленькие экраны: адаптация */
@media (max-width: 576px) {
  .cart-item {
    gap: 12px;
  }

  .cart-img {
    width: 70px;
    height: 70px;
  }

  .cart-item__controls-row {
    gap: 10px;
  }

  .quantity-btn {
    width: 26px;
    height: 26px;
    font-size: 14px;
  }

  .cart-item__total {
    font-size: 0.95em;
  }
}