/* css/components.css - v1.9.0 (Visual Expansion) */

/* --- IDOL CARD RE-DESIGN --- */
.idol-card {
    background: linear-gradient(145deg, #1e1e1e, #121212);
    border: 1px solid #333;
    border-radius: 16px;
    padding: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), border-color 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.idol-card:hover {
    transform: translateY(-8px);
    border-color: var(--primary);
}

.idol-card-header {
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid #333;
    padding-bottom: 12px;
}

/* Avatar tròn cho Model */
.idol-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    object-fit: cover;
    background: #000;
    flex-shrink: 0;
}

.idol-info-basic {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.idol-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.idol-concept {
    font-size: 10px;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(211, 47, 47, 0.1);
    padding: 4px 8px;
    border-radius: 4px;
    
    /* Cơ chế cắt dòng hiện đại */
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Chỉ hiện tối đa 2 dòng */
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    max-height: 2.8em;
    width: auto; /* Cho phép giãn theo container thay vì fit-content */
}

.tabs-navigation {
    display: flex;
    gap: 5px;
    margin-bottom: 25px;
    border-bottom: 1px solid #222;
    padding-bottom: 10px;
}

.tab-btn {
    background: #1a1a1a;
    border: 1px solid #333;
    color: #666;
    padding: 10px 20px;
    border-radius: 8px 8px 0 0;
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    transition: 0.3s;
    letter-spacing: 1px;
}

.tab-btn:hover {
    color: #fff;
    border-color: #444;
}

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

/* Hiệu ứng chuyển cảnh giữa các Tab */
.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tinh chỉnh lại Header Card để tránh lệch Avatar */
.idol-card-header {
    display: grid !important;
    grid-template-columns: 60px 1fr 20px;
    align-items: center;
    gap: 15px;
}

/* --- STATS & TRENDS --- */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-item { background: #222; padding: 10px; border-radius: 8px; text-align: center; border: 1px solid #2a2a2a; }
.stat-label { font-size: 9px; color: #666; text-transform: uppercase; margin-bottom: 4px; }
.stat-value { font-size: 16px; font-weight: 700; color: #fff; }

.trend-alert {
    font-size: 12px; color: #aaa; background: rgba(0,0,0,0.3); padding: 10px;
    border-left: 3px solid #ff9800; border-radius: 4px; line-height: 1.4; font-style: italic;
}

/* --- TOAST SYSTEM --- */
.toast {
    background: #1a1a1a;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    min-width: 250px;
    animation: slideInRight 0.3s ease forwards;
    pointer-events: auto;
}

.toast.success { border-left-color: var(--success); }
.toast.info { border-left-color: var(--accent); }

@keyframes slideInRight {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
    animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeOut {
    to { transform: translateX(20px); opacity: 0; }
}

/* --- GALLERY GRID --- */
.gallery-item {
    position: relative;
    aspect-ratio: 1/1;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #333;
    cursor: pointer;
    transition: 0.3s;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item:hover {
    transform: scale(1.05);
    border-color: var(--primary);
    z-index: 5;
}

.gallery-item::after {
    content: "VIEW";
    position: absolute;
    inset: 0;
    background: rgba(211, 47, 47, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    opacity: 0;
    transition: 0.2s;
}

.gallery-item:hover::after { opacity: 1; }

/* --- UTILS --- */
.prompt-text.collapsed {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#zoomed-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border: 2px solid var(--primary);
    animation: zoomIn 0.3s ease-out;
}

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

/* =========================================
   1. TỐI ƯU HÓA THẺ IDOL (CHỐNG ÉP CHỮ)
========================================= */
.idol-card {
    display: flex !important;
    flex-direction: column !important;
    /* XÓA 2 DÒNG DƯỚI ĐÂY ĐỂ THẺ THU GỌN LẠI */
    /* min-height: 400px !important; */ 
    /* height: auto !important; */
}

/* Nhắm mục tiêu trực tiếp vào phần chữ Bio (đã được định dạng inline trong app.js) */
.idol-card > div[style*="font-size: 11px"] {
    flex-grow: 1 !important; /* Tự động đẩy các chỉ số Stats và Nút bấm xuống đáy thẻ */
    font-size: 13px !important; /* Tăng kích thước chữ lên mức tiêu chuẩn dễ đọc */
    line-height: 1.6 !important; /* Tạo khoảng cách giữa các dòng cho thoáng */
    margin-bottom: 15px !important;
}

/* =========================================
   2. BỐ CỤC LƯỚI CHO DANH SÁCH IDOL
========================================= */
#idol-container {
    display: grid !important;
    /* Tự động chia cột: mỗi thẻ tối thiểu 280px, màn hình càng rộng càng nhiều cột */
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    gap: 20px !important;
    align-items: stretch !important; /* Đảm bảo các thẻ trên cùng 1 hàng có chiều cao bằng nhau */
}

/* =========================================
   3. RESPONSIVE MOBILE (TỈ LỆ 9:16)
========================================= */
@media screen and (max-width: 900px) {
    /* Ép container chính gập thành 1 cột (CHỈ NHẮM VÀO MAIN CONTAINER, BỎ QUA CÁC MODAL ẨN) */
    body > .main-container { 
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        overflow-y: auto !important;
        padding: 10px !important;
    }
    /* Các panel công cụ (Scout / Studio) chiếm full chiều rộng */
    .idol-card-header, /* Nếu có panel bọc ngoài, thêm class vào đây */
    [style*="width:"] { /* Ghi đè các style inline set width cứng nếu có */
        width: 100% !important;
        max-width: 100% !important;
    }

    #idol-container {
        /* Trải dài thẻ Idol full màn hình điện thoại */
        grid-template-columns: 1fr !important; 
        gap: 15px !important;
    }

    .idol-card {
        min-height: auto !important;
        padding: 15px !important; /* Giảm viền để nhường chỗ cho nội dung */
    }
}

/* =========================================
   4. CƠ CHẾ THẺ IDOL XỔ XUỐNG (ACCORDION)
========================================= */

/* Biến phần Header thành nút bấm có thể tương tác */
.idol-card-header {
    cursor: pointer;
    position: relative;
    padding-right: 20px; /* Nhường chỗ cho mũi tên */
    transition: opacity 0.2s;
}

.idol-card-header:hover {
    opacity: 0.8;
}

/* Icon mũi tên xổ xuống */
.toggle-icon {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: #888;
    transition: transform 0.3s ease; /* Hiệu ứng xoay mượt mà */
}

/* Vùng chứa chi tiết: Mặc định ẨN đi */
.idol-details {
    display: none; /* Ẩn hoàn toàn */
    flex-direction: column;
    margin-top: 15px;
    border-top: 1px dashed #333; /* Đường kẻ phân cách nhẹ nhàng */
    padding-top: 15px;
    flex-grow: 1;
}

/* --- TRẠNG THÁI MỞ RỘNG (EXPANDED) --- */
/* Khi thẻ idol được thêm class 'expanded', vùng chi tiết sẽ HIỆN ra */
.idol-card.expanded .idol-details {
    display: flex !important;
    animation: fadeInDown 0.3s ease forwards;
}

/* Xoay mũi tên ngược lên khi đã mở */
.idol-card.expanded .toggle-icon {
    transform: translateY(-50%) rotate(180deg);
}

/* Hiệu ứng mờ dần và trượt xuống khi xổ ra */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================
   5. BỔ SUNG TÍNH NĂNG QUẢN LÝ (v1.9.5)
========================================= */

/* Nút Xóa/Sa thải (Màu đỏ cảnh báo) */
.btn-danger {
    background: #b71c1c; /* Đỏ sậm */
    color: white;
}
.btn-danger:hover {
    background: #f44336; /* Đỏ rực khi hover */
}

/* Nhóm nút bấm trong thẻ Idol (Để chia đôi nút Update và Xóa) */
.action-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}
.action-group .btn-action {
    flex: 1; /* Chia đều 50/50 chiều rộng */
    margin-top: 0;
}

/* Hiệu ứng pop-up mượt mà cho Scout Preview */
#scout-preview-modal .modal-content {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}