/* --- ЗМІННІ --- */
@import url('../shared/theme.css');

:root {
    --primary: var(--color-primary-soft);
    --primary-hover: var(--color-primary-soft-hover);
    --secondary: var(--color-success);
    --bg-page: var(--color-bg-deep);
    --bg-card: var(--color-bg-surface);
    --bg-input: var(--color-bg-input);
    --border: var(--color-border-strong);
    --text-main: var(--color-text-main);
    --text-muted: var(--color-text-soft);
    --radius: var(--radius-lg);
    --radius-sm: var(--radius-md);
    --gradient-main: var(--gradient-brand);
    --card-hover-bg: var(--color-bg-control);
    --warning-soft: var(--color-warning-soft);
}

body {
    background-color: var(--bg-page);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    margin: 0;
}

.page-container {
    max-width: 1200px;
    margin: 100px auto 60px;
    padding: 0 20px;
}

/* --- PRODUCT GRID --- */
.product-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr; 
    gap: 40px;
    margin-bottom: 50px;
}

/* ЛІВА КОЛОНКА (ФОТО) */
.image-column {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px;
    height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.main-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--radius-sm);
}

.main-image {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Кнопка зміни фото */
.edit-image-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--color-overlay-black-70);
    padding: 10px;
    border-radius: 50%;
    border: 1px solid var(--border);
    color: white;
    cursor: pointer;
    transition: 0.2s;
    z-index: 10;
}
.edit-image-btn:hover { background: var(--primary); }

/* --- МУЗИЧНИЙ ПЛЕЄР --- */
.music-player-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    display: flex;
    justify-content: center;
    align-items: center;
}

.player-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(20px) brightness(0.4);
    z-index: 0;
}

.vinyl-record {
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 5px solid var(--color-border-dark);
    position: relative;
    box-shadow: 0 10px 30px var(--color-overlay-black-50);
    z-index: 1;
    transition: transform 0.5s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.vinyl-record.playing { animation: spin 4s linear infinite; }
@keyframes spin { 100% { transform: rotate(360deg); } }

.vinyl-cover {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.play-btn-overlay {
    position: absolute;
    z-index: 5;
    background: var(--color-overlay-white-10);
    backdrop-filter: blur(5px);
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border: 1px solid var(--color-overlay-white-20);
    transition: 0.2s;
}
.play-btn-overlay:hover { background: var(--primary); border-color: var(--primary); }
.play-btn-overlay i { font-size: 2rem; color: white; margin-left: 5px; }

.player-controls {
    position: absolute;
    bottom: 0; left: 0; width: 100%; padding: 20px;
    background: linear-gradient(to top, var(--color-overlay-black-90), transparent);
    z-index: 2;
}

.progress-bar {
    width: 100%; height: 6px; background: var(--color-overlay-white-20);
    border-radius: 3px; cursor: pointer; margin-bottom: 5px; position: relative;
}
.progress-fill {
    height: 100%; background: var(--primary); width: 0%;
    border-radius: 3px; transition: width 0.1s linear;
}
.time-display {
    display: flex; justify-content: space-between; font-size: 0.8rem;
    color: var(--color-text-faint); font-family: monospace;
}

/* --- ПРАВА КОЛОНКА --- */
.info-column { display: flex; flex-direction: column; }

.meta-info {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;
}

.category-badge {
    background: var(--color-bg-chip); color: var(--primary); padding: 5px 12px;
    border-radius: 20px; font-size: 0.85rem; font-weight: 600;
    border: 1px solid var(--color-border-strong); text-transform: uppercase;
}
.date-badge { color: var(--text-muted); font-size: 0.85rem; }

.product-title {
    font-size: 2rem; font-weight: 800; margin-bottom: 20px;
    line-height: 1.2; color: white;
}

/* Теги */
.tags-wrapper { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.tag-badge {
    padding: 5px 10px; border-radius: 8px; font-size: 0.85rem;
    font-weight: 600; display: flex; align-items: center;
}
.tag-bpm { background: var(--color-danger-soft); color: var(--color-danger); border: 1px solid var(--color-danger-border); }
.tag-key { background: var(--color-success-surface); color: var(--color-success); border: 1px solid var(--color-success-border); }
.tag-generic { background: var(--color-bg-chip); color: var(--color-text-faint); border: 1px solid var(--color-border-strong); }

/* Ціна */
.price-block { margin-bottom: 25px; }
.price-tag { font-size: 2.2rem; font-weight: 700; color: var(--secondary); }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* Продавець Mini */
.seller-mini-card {
    display: flex; align-items: center; background: var(--bg-card);
    border: 1px solid var(--border); padding: 12px 15px;
    border-radius: 12px; text-decoration: none; transition: 0.2s; margin-bottom: 20px;
}
.seller-mini-card:hover { border-color: var(--primary); background: var(--card-hover-bg); }
.seller-mini-avatar { width: 45px; height: 45px; border-radius: 50%; object-fit: cover; margin-right: 15px; }
.seller-mini-info { flex: 1; }
.seller-name-row { font-weight: 700; color: white; font-size: 1rem; }
.seller-rating-row { font-size: 0.85rem; color: var(--warning-soft); margin-top: 3px; }
.arrow-icon { color: var(--text-muted); }

/* Кнопки Дій (Покупець) */
.action-buttons { display: flex; gap: 10px; margin-bottom: 20px; }
.buy-btn {
    flex: 2; background: var(--gradient-main); color: white;
    border: none; padding: 14px; border-radius: 12px;
    font-size: 1.1rem; font-weight: 700; cursor: pointer; transition: 0.2s;
}
.buy-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 20px var(--color-primary-glow); }
.chat-btn, .fav-btn {
    flex: 0.5; background: var(--bg-input); border: 1px solid var(--border);
    color: white; border-radius: 12px; font-size: 1.2rem; cursor: pointer; transition: 0.2s;
}
.chat-btn:hover { background: var(--primary); border-color: var(--primary); }
.fav-btn:hover { border-color: var(--color-pink); color: var(--color-pink); }
.fav-btn.active { background: var(--color-pink); border-color: var(--color-pink); color: white; }

/* Форма донату */
.donation-form {
    background: var(--bg-input); padding: 20px; border-radius: 12px;
    border: 1px solid var(--primary); animation: fadeIn 0.3s;
}
.donation-input {
    width: 100%; padding: 12px; margin: 10px 0; border-radius: 8px;
    border: 1px solid var(--border); background: var(--color-bg-black); color: white;
}
.confirm-btn {
    width: 100%; padding: 12px; background: var(--secondary); border: none;
    border-radius: 8px; font-weight: bold; cursor: pointer;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* Секції */
.content-section {
    background: var(--bg-card); border-radius: var(--radius);
    border: 1px solid var(--border); padding: 30px; margin-bottom: 30px;
}
.section-title {
    font-size: 1.3rem; font-weight: 700; margin-bottom: 20px;
    display: flex; align-items: center; gap: 10px; color: white;
}

/* Коментарі */
.comment-form { display: flex; gap: 10px; margin-bottom: 30px; }
.comment-form textarea {
    flex: 1; background: var(--bg-input); border: 1px solid var(--border);
    border-radius: 10px; padding: 15px; color: white; resize: none;
    height: 50px; transition: 0.2s; font-family: inherit;
}
.comment-form textarea:focus { height: 80px; border-color: var(--primary); outline: none; }
.comment-form button {
    width: 50px; height: 50px; border-radius: 10px;
    background: var(--primary); color: white; border: none; cursor: pointer;
}
.comments-list { display: flex; flex-direction: column; gap: 20px; }
.comment-item { display: flex; gap: 15px; padding-bottom: 20px; border-bottom: 1px solid var(--color-border-dark); }
.comment-item:last-child { border-bottom: none; padding-bottom: 0; }

/* 🔥 АВАТАРКА У КОМЕНТАРЯХ (ЗМЕНШЕНА) 🔥 */
.comment-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--color-bg-chip-hover);
    flex-shrink: 0; overflow: hidden;
}

.comment-content { flex: 1; }
.comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }

/* Посилання на профіль у коментарях */
.comment-author-link {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.95rem;
    font-weight: 600;
}
.comment-author-link:hover .comment-author { color: var(--primary); }

.comment-avatar-link {
    display: block; text-decoration: none; cursor: pointer;
}
.comment-avatar-link img { transition: transform 0.2s; }
.comment-avatar-link:hover img { transform: scale(1.1); }

.comment-date { font-size: 0.8rem; color: var(--color-text-dim); margin-right: 10px; }
.comment-text { color: var(--text-muted); font-size: 0.95rem; line-height: 1.4; }

/* --- OWNER CONTROLS (ВИПРАВЛЕНО) --- */
.owner-controls {
    display: flex; /* Важливо: flex, щоб кнопки були в ряд */
    gap: 10px; 
    margin-bottom: 15px;
    background: var(--color-overlay-white-05); /* Легкий фон */
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--border); /* Сіра рамка */
}

.control-btn {
    padding: 8px 15px; border-radius: 6px; border: 1px solid var(--border);
    cursor: pointer; font-weight: 600; background: var(--color-bg-chip); color: white;
    transition: 0.2s; display: flex; align-items: center; gap: 8px;
}
.control-btn:hover { background: var(--color-bg-chip-hover); }
.control-btn.save { background: var(--secondary); color: black; border-color: var(--secondary); }
.control-btn.cancel { background: var(--color-bg-chip-hover); }
.control-btn.delete { background: var(--color-danger-soft); color: var(--color-danger); border-color: var(--color-danger-border); }
.control-btn.delete:hover { background: var(--color-danger); color: white; border-color: var(--color-danger); }

/* ========================================= */
/* 6. CUSTOM CONFIRM MODAL (Модальне вікно)   */
/* ========================================= */
.custom-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-overlay-black-85); /* Затемнення фону */
    backdrop-filter: blur(5px);      /* Розмиття */
    display: flex;                   /* Центрування */
    justify-content: center;
    align-items: center;
    z-index: 10000;                  /* Поверх усього */
    animation: fadeIn 0.3s ease-out;
}

.custom-confirm-box {
    background: var(--color-bg-control-alt);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    border: 1px solid var(--color-primary-border-soft); /* Фіолетова рамка */
    box-shadow: 0 0 30px var(--color-primary-surface);
    animation: modalAppear 0.3s ease-out;
}

.custom-confirm-box h3 {
    margin-top: 0;
    color: white;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.custom-confirm-box p {
    color: var(--color-text-disabled);
    font-size: 1rem;
    margin-bottom: 25px;
    line-height: 1.5;
}

.confirm-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.btn-confirm-yes, .btn-confirm-no {
    padding: 12px 30px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
}

.btn-confirm-yes {
    background: var(--color-primary); /* Фіолетова кнопка */
    color: white;
}
.btn-confirm-yes:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px var(--color-primary-border);
}

.btn-confirm-no {
    background: transparent;
    border: 1px solid var(--color-border-medium);
    color: var(--color-text-disabled);
}
.btn-confirm-no:hover {
    color: white;
    border-color: white;
    background: var(--color-overlay-white-05);
}

@keyframes modalAppear {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* 🔥 ПОЛЯ РЕДАГУВАННЯ 🔥 */
.edit-input, .edit-select {
    width: 100%;
    padding: 12px;
    background: var(--color-bg-surface);
    border: 1px solid var(--primary);
    color: white;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 1rem;
    display: none; /* JS вмикає block */
}

/* 🔥 КНОПКИ ЗБЕРЕЖЕННЯ (На всю ширину) 🔥 */
#saveCancelBtns {
    display: none; /* JS вмикає flex */
    flex-direction: column; /* Вертикально */
    gap: 10px;
    margin-bottom: 20px;
    margin-top: 10px;
    width: 100%;
}

#saveCancelBtns button {
    width: 100%; /* На всю ширину */
    justify-content: center;
    padding: 12px;
}

/* Кнопка кошика */
.cart-btn-main {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg-chip-soft);
    color: white;
    border: 1px solid var(--color-border-medium);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.2rem;
    min-width: 50px;
    padding: 0;
}

.cart-btn-main:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--color-primary-glow);
}

/* Адаптив */
@media (max-width: 900px) {
    .product-grid { grid-template-columns: 1fr; }
    .image-column { height: 350px; }
}

/* ========================================= */
/* Мобільна адаптація (max-width: 768px)     */
/* ========================================= */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        width: 100%;
    }

    .page-container {
        width: 100%;
        max-width: 100%;
        padding: 12px 16px;
        margin-top: 80px;
        margin-bottom: 40px;
        box-sizing: border-box;
    }

    .product-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .image-column {
        height: 280px;
        padding: 8px;
    }

    .product-title {
        font-size: 1.35rem;
        word-break: break-word;
        margin-bottom: 12px;
    }

    .content-section {
        padding: 16px;
        margin-bottom: 20px;
    }

    .section-title {
        font-size: 1.1rem;
        word-break: break-word;
    }

    .price-tag {
        font-size: 1.6rem;
    }

    .action-buttons {
        flex-direction: column;
        gap: 12px;
    }

    .buy-btn,
    .chat-btn,
    .fav-btn {
        width: 100%;
        min-height: 44px;
        padding: 14px;
        box-sizing: border-box;
    }

    .donation-form {
        padding: 16px;
    }

    .donation-input,
    .confirm-btn {
        width: 100%;
        box-sizing: border-box;
    }

    .comment-form {
        flex-direction: column;
    }

    .comment-form textarea {
        width: 100%;
        min-height: 44px;
        box-sizing: border-box;
    }

    .comment-form button {
        width: 100%;
        min-height: 44px;
    }

    .edit-input,
    .edit-select {
        width: 100%;
        box-sizing: border-box;
    }

    #saveCancelBtns button {
        width: 100%;
        min-height: 44px;
    }

    .custom-confirm-box {
        width: 90%;
        max-width: 100%;
        padding: 20px 16px;
        margin: 16px;
    }

    .custom-confirm-box h3 {
        font-size: 1.2rem;
        word-break: break-word;
    }

    .btn-confirm-yes,
    .btn-confirm-no {
        min-height: 44px;
        padding: 12px 20px;
    }
}
