/* admin_panel/avatars/avatar_editor.css */
:root {
    --text-dark: #1c1c1e;
    --text-secondary: #6c757d;
    --background-light: #f0f2f5; /* iOS light grey background */
    --card-background: #ffffff;
    --border-color: #e5e5ea;
    --primary-blue: #007aff;
    --primary-green: #34c759;
    --primary-red: #ff3b30;
    --woman-color: #ff8fa3;
    --man-color: #5390d9;
    --pet-color: #70e000;
    --status-active-bg: #dcfce7; /* green-100 */
    --status-active-text: #166534; /* green-800 */
    /* NEW: Neutral grey for hidden status */
    --status-hidden-bg: #f3f4f6; /* gray-100 */
    --status-hidden-text: #4b5563; /* gray-600 */
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    display: flex; flex-direction: column; min-height: 100vh;
    background: var(--background-light); color: var(--text-dark);
}
main {
    flex: 1; padding: 1rem; max-width: 1400px; margin: 0 auto; width: 100%;
}
/* Header overrides */
body #header-placeholder { position: static; }
body header { 
    position: static !important; background: var(--background-light) !important; 
    border-bottom: 1px solid var(--border-color); padding: 0.75rem 1rem;
}
body #header-placeholder .header-logo {
    filter: none !important; 
    height: 56px !important;
}
body #header-placeholder .burger-btn { color: var(--text-dark); }


/* Page Title */
.title-container {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 2.5rem;
}
.main-title {
    font-size: 2.5rem;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1;
    text-align: left;
}
.main-title span { display: block; }

.back-link {
    width: 40px; height: 40px;
    background: white; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none; color: var(--text-dark);
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.back-link svg { width: 24px; height: 24px; }


/* Control Cards (Upload & Tags) */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}
.control-card {
    background: var(--card-background);
    border-radius: 26px;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.control-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* Form Styles inside Cards */
.upload-avatar-form, .add-tag-form { display: flex; flex-direction: column; gap: 1rem; }
.add-tag-form { flex-direction: row; }

.form-group select, .form-group .file-input-label, .add-tag-form input {
    width: 100%; padding: 0.8rem 1rem; border-radius: 26px;
    border: 1px solid var(--border-color); font-size: 1rem; background: var(--background-light);
}
.file-input-label { cursor: pointer; display: block; text-align: center; color: var(--text-secondary); }
.file-input-label.has-file { color: var(--text-dark); background: #e9f5e9; border-color: var(--primary-green); }
#avatar-file-input { display: none; }

.btn {
    padding: 0.8rem 1.2rem; border: none; border-radius: 26px; cursor: pointer;
    font-size: 1rem; font-weight: 500; transition: all 0.2s;
}
.btn-add, .btn-upload { background: var(--primary-blue); color: white; }

/* Tag List */
.tags-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.tag-item { 
    background: #e5e5ea; 
    color: var(--text-dark); 
    padding: 0.4rem 0.8rem; 
    border-radius: 26px; 
    font-size: 0.9rem; 
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}
.delete-tag-btn {
    background: rgba(0,0,0,0.1);
    border: none;
    cursor: pointer;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.2s;
}
.delete-tag-btn:hover {
    background-color: var(--primary-red);
}
.delete-tag-btn img {
    width: 10px;
    height: 10px;
    display: block;
}
.delete-tag-btn:hover img {
    filter: brightness(0) invert(1);
}

/* Gender Tabs */
.gender-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}
.gender-tab {
    padding: 0.75rem 1rem;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    background-color: transparent;
    color: var(--text-secondary);
    transition: all 0.2s ease-in-out;
}
.gender-tab.active { color: var(--text-dark); }
.gender-tab[data-gender="woman"].active { border-color: var(--woman-color); }
.gender-tab[data-gender="man"].active { border-color: var(--man-color); }
.gender-tab[data-gender="pet"].active { border-color: var(--pet-color); }


/* --- AVATAR GRID - ПРИНУДИТЕЛЬНО 2 в РЯД --- */
.avatar-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(2, 1fr); /* ПРИНУДИТЕЛЬНО 2 в ряд */
}

/* Заголовки разделов галереи */
.gallery-section-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.gallery-section-header:first-child {
    margin-top: 0;
}

.section-title-group {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 800;
    text-transform: uppercase;
    color: #1c1c1e;
    margin: 0;
    line-height: 1;
}

.section-count {
    font-size: 1rem;
    font-weight: 500;
    color: #8e8e93;
    line-height: 1;
}

.section-price-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-price-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: #1c1c1e;
}

.category-price-input {
    width: 80px;
    padding: 0.4rem 0.6rem;
    border: 2px solid #e5e5ea;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-align: right;
    transition: border-color 0.2s;
}

.category-price-input:focus {
    outline: none;
    border-color: #007AFF;
}

.btn-save-price {
    padding: 0.4rem 0.8rem;
    font-size: 0.9rem;
    background-color: var(--primary-green);
    color: white;
    border: none;
    border-radius: 26px;
    cursor: pointer;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.btn-save-price:hover {
    background-color: #28a745;
}

.btn-save-price:disabled {
    background-color: #a5d6a7;
    cursor: not-allowed;
    opacity: 0.8;
}


#avatars-gallery .loader { 
    grid-column: 1 / -1; 
    text-align: center; 
    color: var(--text-secondary); 
    padding: 2rem; 
}


/* --- AVATAR CARD --- */
.avatar-card {
    position: relative;
    background: var(--card-background);
    border-radius: 26px; /* iOS style */
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* UPDATED: 9:16 Aspect Ratio */
.avatar-card-img-container {
    width: 100%;
    padding-top: calc(100% * 16 / 9);
    position: relative;
    background-color: var(--background-light);
    cursor: default; /* Больше не открывает модальное окно */
}

.avatar-card img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* NEW: Creation Date */
.avatar-creation-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: left;
    padding: 0.5rem 1rem 0 1rem;
}


/* КНОПКА УДАЛЕНИЯ - В ПРАВОМ ВЕРХНЕМ УГЛУ ФОТО */
.delete-avatar-btn-image {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: background-color 0.2s;
    backdrop-filter: blur(2px);
    z-index: 10;
}
.delete-avatar-btn-image:hover { background: var(--primary-red); }
.delete-avatar-btn-image svg { width: 16px; height: 16px; }


/* --- CONTROLS (ПОД ФОТО) --- */
.avatar-card-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start; /* ВЫРАВНИВАНИЕ ПО ЛЕВОМУ КРАЮ */
    text-align: left; /* ВЫРАВНИВАНИЕ ПО ЛЕВОМУ КРАЮ */
    gap: 1rem;
}

/* UPDATED: STATUS CONTROL */
.status-control {
    width: 100%; /* Занимает всю ширину для выравнивания */
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    background-color: transparent; 
    border-radius: 0;
    padding: 0;
}

.status-text {
    font-weight: 600;
    font-size: 0.9rem;
    height: 48px;
    padding: 0 14px;
    box-sizing: border-box;
    border-radius: 26px;
    white-space: nowrap;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.status-text.active { 
    background-color: var(--status-active-bg); 
    color: var(--status-active-text); 
}
.status-text.hidden { 
    background-color: var(--status-hidden-bg); 
    color: var(--status-hidden-text); 
}

/* NEW: Editable name input */
.avatar-name-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    text-align: left;
    background: var(--background-light);
    color: var(--text-dark);
}

.avatar-name-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

/* Tag select */
.tag-select {
    width: 100%;
    padding: 0.75rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    background: var(--background-light);
    font-size: 0.9rem;
    color: var(--text-secondary);
}


/* AVATAR TAGS DISPLAY */
.avatar-tags-display {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start; /* ВЫРАВНИВАНИЕ ПО ЛЕВОМУ КРАЮ */
    width: 100%;
    min-height: 28px; /* Reserve space */
}
.avatar-tag {
    background: var(--primary-blue);
    color: white;
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}
.remove-tag-btn { 
    background: none; 
    border: none; 
    color: inherit; 
    cursor: pointer; 
    opacity: 0.7; 
    font-size: 1.1rem; 
    line-height: 1; 
    padding: 0; 
}
.remove-tag-btn:hover { opacity: 1; }


/* Status Message */
#status-message {
    position: fixed; 
    top: 20px; 
    left: 50%;
    padding: 1rem 1.5rem; 
    border-radius: 26px; 
    color: white; 
    font-weight: 500;
    background: rgba(0,0,0,0.7); 
    backdrop-filter: blur(5px);
    z-index: 9999; 
    opacity: 0; 
    transition: opacity 0.3s, transform 0.3s; 
    pointer-events: none;
    transform: translate(-50%, -20px);
}
#status-message.success { background: rgba(52, 199, 89, 0.8); }
#status-message.error { background: rgba(255, 59, 48, 0.8); }
#status-message.visible { opacity: 1; transform: translate(-50%, 0); }

/* Save Prices Button */
.save-prices-btn {
    margin-top: 2rem;
    width: 100%;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    display: block;
    background-color: var(--primary-green);
    color: white;
}

/* ========================================
   УНИКАЛЬНЫЕ КЛАССЫ V2024 (ОБНОВЛЕНО)
   ======================================== */

/* КНОПКА ПЕРЕКЛЮЧЕНИЯ ВИДИМОСТИ */
.ae-visibility-toggle-btn-v2024 {
    position: relative;
    width: 48px;
    height: 48px;
    min-width: 48px;
    padding: 0;
    margin: 0;
    border-radius: 50%;
    border: none;
    background: white;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 5;
}
.ae-visibility-toggle-btn-v2024:hover {
    background: #f5f5f5;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}
.ae-visibility-toggle-btn-v2024::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    background-color: #1c1c1e;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}
.ae-visibility-toggle-btn-v2024[data-current-status="active"]::before {
    -webkit-mask-image: url(../../components/svg/svg_ui/hide.svg);
    mask-image: url(../../components/svg/svg_ui/hide.svg);
}
.ae-visibility-toggle-btn-v2024[data-current-status="hidden"]::before {
    -webkit-mask-image: url(../../components/svg/svg_ui/visible.svg);
    mask-image: url(../../components/svg/svg_ui/visible.svg);
}

/* БЕЙДЖИ (ВЫБРАЛИ / КУПИЛИ) */
.ae-avatar-badge-v2024 {
    position: absolute !important;
    background: rgba(0,0,0,0.6) !important;
    backdrop-filter: blur(2px);
    color: white !important;
    padding: 6px 10px !important;
    font-size: 0.8rem !important;
    font-weight: 500 !important;
    border-radius: 999px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 6px !important;
    line-height: 1 !important;
}
.ae-user-count-badge-v2024 {
    bottom: 10px !important;
    left: 12px !important;
}
.ae-purchase-count-badge-v2024 {
    bottom: 10px !important;
    right: 12px !important;
}
.ae-avatar-badge-v2024::before {
    content: '';
    display: block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    background-color: white;
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    transform: translateY(1px);
}
.ae-user-count-badge-v2024::before {
    -webkit-mask-image: url(../../components/svg/svg_ui/profile.svg);
    mask-image: url(../../components/svg/svg_ui/profile.svg);
}
.ae-purchase-count-badge-v2024::before {
    -webkit-mask-image: url(../../components/svg/svg_ui/coins.svg);
    mask-image: url(../../components/svg/svg_ui/coins.svg);
}
.ae-avatar-badge-v2024 span {
    display: inline-block !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.footer-delete-btn {
    background: transparent;
    border: none;
    color: var(--primary-red);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 26px; /* iOS Style */
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}