/* ======== Шрифты ======== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ======== CSS переменные ======== */
:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #94a3b8;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

/* ======== Общие стили ======== */
body {
    background-color: var(--bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}

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

/* ======== Навбар ======== */
.navbar-main {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #3730a3 100%);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 0.6rem 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.navbar-main .navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #fff !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-main .navbar-brand .brand-icon {
    background: rgba(255,255,255,0.15);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.navbar-main .nav-link {
    color: rgba(255,255,255,0.75) !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0.9rem !important;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.navbar-main .nav-link:hover,
.navbar-main .nav-link.active {
    color: #fff !important;
    background: rgba(255,255,255,0.1);
}

.navbar-main .nav-link-admin {
    color: #fbbf24 !important;
}

.navbar-main .nav-link-admin:hover {
    background: rgba(251,191,36,0.15);
}

/* ======== Бейдж корзины ======== */
.cart-badge {
    font-size: 0.6rem;
    font-weight: 700;
    padding: 0.25em 0.5em;
    min-width: 18px;
    background: var(--danger) !important;
    border: 2px solid #312e81;
    animation: badge-pop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes badge-pop {
    0% { transform: translate(-50%, -50%) scale(0); }
    60% { transform: translate(-50%, -50%) scale(1.3); }
    100% { transform: translate(-50%, -50%) scale(1); }
}

/* ======== Заголовки страниц ======== */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text);
    margin: 0;
}

.page-header h1 i {
    color: var(--primary);
    margin-right: 0.3rem;
}

/* ======== Поиск ======== */
.search-box {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 4px;
    margin-bottom: 1.5rem;
}

.search-box .form-control {
    border: none;
    font-size: 0.95rem;
    padding: 0.7rem 1rem;
    background: transparent;
}

.search-box .form-control:focus {
    box-shadow: none;
}

.search-box .input-group-text {
    background: transparent;
    border: none;
    padding-left: 1rem;
    color: var(--text-muted);
}

.search-box .btn {
    border-radius: var(--radius-sm) !important;
    padding: 0.5rem 1.2rem;
    font-weight: 600;
    font-size: 0.9rem;
}

/* ======== Карточки товаров (каталог) ======== */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.product-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    overflow: hidden;
    transition: all 0.25s ease;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: #c7d2fe;
}

.product-card-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    background: #f8fafc;
}

.product-card-img-placeholder {
    width: 100%;
    height: 180px;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 2.5rem;
}

.product-card-body {
    padding: 1rem 1.2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.3rem;
    color: var(--text);
    line-height: 1.3;
}

.product-card-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.8rem;
    line-height: 1.45;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-card-footer {
    padding: 0.8rem 1.2rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fafbfc;
}

.product-card-price {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
}

.product-card-price small {
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ======== Кнопка "В корзину" ======== */
.btn-add-cart {
    background: var(--success);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
    font-weight: 600;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
}

.btn-add-cart:hover {
    background: var(--success-hover);
    color: #fff;
    transform: scale(1.03);
}

/* ======== Виджет количества ======== */
.qty-widget {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    background: var(--card-bg);
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    padding: 2px;
}

.qty-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.qty-btn-minus:hover {
    background: #fef2f2;
    color: var(--danger);
}

.qty-input {
    width: 40px !important;
    height: 30px;
    font-weight: 600;
    font-size: 0.85rem;
    text-align: center;
    border: none !important;
    background: transparent;
    color: var(--text);
    padding: 0;
    -moz-appearance: textfield;
}

.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-input:focus {
    outline: none;
    box-shadow: none;
}

.qty-input-form {
    display: inline-flex;
}

/* ======== Карточки-контейнеры ======== */
.content-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.content-card-body {
    padding: 1.5rem;
}

/* ======== Таблицы (корзина, админ) ======== */
.styled-table {
    margin: 0;
}

.styled-table thead th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    padding: 0.8rem 1rem;
    white-space: nowrap;
}

.styled-table tbody td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.9rem;
}

.styled-table tbody tr {
    transition: background 0.15s;
}

.styled-table tbody tr:hover {
    background: #f8fafc;
}

.styled-table tbody tr:last-child td {
    border-bottom: none;
}

.styled-table tfoot td {
    padding: 1rem;
    border-top: 2px solid var(--border);
    background: #f8fafc;
}

/* ======== Миниатюры ======== */
.thumb {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
}

.thumb-placeholder {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1rem;
}

/* ======== Кнопки ======== */
.btn-primary {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--primary-hover) !important;
    border-color: var(--primary-hover) !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.btn-success {
    background: var(--success) !important;
    border-color: var(--success) !important;
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.btn-success:hover {
    background: var(--success-hover) !important;
    border-color: var(--success-hover) !important;
}

.btn-outline-secondary {
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.btn-outline-danger {
    border-radius: var(--radius-sm);
    font-weight: 500;
}

.btn-pay {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    border: none;
    color: #fff;
    border-radius: var(--radius);
    padding: 0.8rem 2rem;
    font-weight: 700;
    font-size: 1.05rem;
    transition: all 0.25s;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.25);
}

.btn-pay:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
}

/* ======== Итого в корзине ======== */
.cart-total-row td {
    font-size: 1.1rem !important;
}

.cart-total-amount {
    color: var(--success);
    font-weight: 700 !important;
}

/* ======== Кнопки корзины (±) ======== */
.cart-qty-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--border);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}

.cart-qty-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

/* ======== QR-код ======== */
.qr-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.qr-container {
    display: inline-block;
    padding: 20px;
    background: white;
    border-radius: var(--radius);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.qr-image {
    max-width: 250px;
}

.qr-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--success);
    letter-spacing: -0.02em;
}

/* ======== Форма входа ======== */
.login-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.login-card .card-body {
    padding: 2rem;
}

.form-control {
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* ======== Бейджи ======== */
.badge-stock {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.35em 0.7em;
    border-radius: 6px;
}

/* ======== Пустые состояния ======== */
.empty-state {
    padding: 4rem 1rem;
    text-align: center;
}

.empty-state-icon {
    font-size: 3.5rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

/* ======== Футер ======== */
footer {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s;
}

.footer-link:hover {
    color: var(--primary);
}

/* ======== Юридический текст ======== */
.legal-text h5 {
    font-size: 1rem;
    font-weight: 700;
    margin-top: 1.5rem;
    margin-bottom: 0.6rem;
    color: var(--text);
}

.legal-text h5:first-of-type {
    margin-top: 0;
}

.legal-text p, .legal-text li {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--text-secondary);
}

.legal-text ul {
    padding-left: 1.2rem;
}

/* ======== Карточка ======== */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* ======== Адаптивность ======== */
@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    .product-card-img,
    .product-card-img-placeholder {
        height: 140px;
    }

    .page-header h1 {
        font-size: 1.3rem;
    }

    .qr-image {
        max-width: 200px;
    }

    .qr-amount {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .product-grid {
        grid-template-columns: 1fr;
    }

    .content-card-body {
        padding: 1rem;
    }
}
