:root {
    --header-bg: #0f172a;
    --primary-color: #2563eb;
    --pink-color: #ec4899;
    --blue-color: #0284c7;
    --success-color: #16a34a;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #cbd5e1;
    --text-color: #0f172a;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { background-color: var(--bg-color); color: var(--text-color); padding-bottom: 60px; }

header {
    background-color: var(--header-bg);
    color: white;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between; /* Избутва заглавието вляво, а десния блок вдясно */
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 50px;
    width: 100%;
    box-sizing: border-box;
}

header h1 {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    position: static; /* Премахва абсолютното позициониране, ако е имало такова */
    transform: none; /* Премахва всякакво избутване към средата */
    white-space: nowrap;
}

/* Контейнерът за потребителя вдясно */
#authContainer, #userInfo {
    display: flex;
    align-items: center;
    gap: 10px;
    position: static;
}

#userEmail {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    max-width: 140px; /* Скрива прекалено дълги имейли с точки, за да не избутват бутона */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Бутони за Вход/Изход в хедъра */
.welcome-card {
    background: linear-gradient(135deg, #ffffff 0%, #f4f7fe 100%);
    border-radius: 16px;
    padding: 20px 16px;
    margin: 12px 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    border: 1px solid #eaedf5;
    text-align: center;
}

.welcome-badge {
    display: inline-block;
    background-color: #e8f0fe;
    color: #1a73e8;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    margin-bottom: 10px;
}

.welcome-card h2 {
    font-size: 18px;
    color: #2c3e50;
    margin-bottom: 8px;
    line-height: 1.3;
}

.welcome-text {
    font-size: 14px;
    color: #606f7b;
    line-height: 1.5;
    margin-bottom: 16px;
}

.login-prompt-box {
    background-color: #ffffff;
    border: 1px dashed #4285f4;
    border-radius: 12px;
    padding: 14px;
}

.login-prompt-box p {
    font-size: 13px;
    color: #4a5568;
    margin-bottom: 12px;
    line-height: 1.4;
}

.btn-google-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px;
    background-color: #4285f4;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(66, 133, 244, 0.3);
}

.btn-google-login img {
    width: 18px;
    height: 18px;
    background: white;
    padding: 2px;
    border-radius: 50%;
}

.auth-btn {
    background: #4285f4;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}
.logout-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    margin-left: 8px;
}
#userInfo { font-size: 12px; color: #cbd5e1; }

/* Табове (Навигация) */
.tab-nav {
    display: flex;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 53px;
    z-index: 99;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    color: #64748b;
    border: none;
    background: none;
    cursor: pointer;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: #eff6ff;
}

.container {
    max-width: 650px;
    margin: 0 auto;
    padding: 12px;
}

/* Бюджет каре */
.budget-card {
    background: linear-gradient(135deg, #1e293b, #334155);
    color: white;
    padding: 14px;
    border-radius: 10px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.budget-val { font-size: 18px; font-weight: 700; color: #38bdf8; }

/* Филтри */
.filters-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 15px;
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.gender-selector { display: flex; gap: 6px; }

.gender-btn {
    flex: 1;
    padding: 8px;
    font-size: 12px;
    font-weight: 700;
    border: 1px solid var(--border-color);
    background: #f1f5f9;
    border-radius: 6px;
    cursor: pointer;
}

.gender-btn.active-all { background: var(--header-bg); color: white; }
.gender-btn.active-boy { background: var(--blue-color); color: white; }
.gender-btn.active-girl { background: var(--pink-color); color: white; }

.btn-add-custom {
    width: 100%;
    padding: 10px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 15px;
}

/* Карта на продукт */
.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.catalog-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.item-info { flex: 1; }
.item-title-wrap { display: flex; align-items: center; gap: 6px; }
.item-title { font-weight: 700; font-size: 14px; color: var(--text-color); }

.info-btn {
    background: #e2e8f0;
    color: #475569;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.info-btn:hover { background: var(--primary-color); color: white; }

.item-cat { font-size: 11px; color: #64748b; font-weight: 600; text-transform: uppercase; margin-bottom: 2px; }

.tag {
    display: inline-block;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    margin-left: 4px;
}
.tag-uni { background: #e2e8f0; color: #334155; }
.tag-boy { background: #e0f2fe; color: #0369a1; }
.tag-girl { background: #fce7f3; color: #be185d; }

.add-to-list-btn {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.add-to-list-btn.added {
    background: #f1f5f9;
    color: #94a3b8;
    border-color: #cbd5e1;
    cursor: default;
}

/* Афилиейт бутони за покупка */
.affiliate-section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
}
.affiliate-title {
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 6px;
    text-transform: uppercase;
}
.affiliate-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.affiliate-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    background: #fff7ed;
    color: #c2410c;
    border: 1px solid #ffedd5;
    border-radius: 6px;
    text-decoration: none;
    font-size: 11px;
    font-weight: 700;
    transition: all 0.2s;
}
.affiliate-btn:hover {
    background: #ffedd5;
    border-color: #fdba74;
}

/* Моя Списък */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding-bottom: 6px;
}
.card-header-row.has-border {
    border-bottom: 1px dashed var(--border-color);
    margin-bottom: 8px;
}
.card-title-btn {
    flex: 1;
    text-align: center;
    font-weight: 700;
    font-size: 14px;
    color: var(--primary-color);
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    background: #eff6ff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.bought-wrap { display: flex; align-items: center; gap: 4px; font-weight: 700; font-size: 13px; }
.bought-wrap input { width: 18px; height: 18px; }
.del-btn { background: none; border: none; font-size: 16px; cursor: pointer; }
.card-body.collapsed { display: none; }

.field-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.field-group label { font-size: 10px; font-weight: 700; color: #64748b; text-transform: uppercase; }
.field-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

input[type="text"], input[type="number"], select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    background: white;
}

.link-input-wrap { display: flex; gap: 4px; }
.open-link-btn { background: #e2e8f0; border: 1px solid #cbd5e1; padding: 6px 10px; border-radius: 6px; text-decoration: none; font-size: 12px; }
.empty-state { text-align: center; padding: 30px; color: #64748b; font-size: 14px; }

/* Модален прозорец */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(2px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 15px;
}
.modal-card {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    padding: 20px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    position: relative;
}
.modal-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--header-bg); }
.modal-close { background: none; border: none; font-size: 20px; font-weight: 700; cursor: pointer; color: #64748b; }
.modal-body { font-size: 13px; line-height: 1.5; color: #334155; }