/* =========================================
   CONTAINER CHÍNH
   ========================================= */
.mmt-container { background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 24px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; max-width: 800px; margin: 0 auto; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05); box-sizing: border-box; }
.mmt-container * { box-sizing: border-box; }

/* HEADER */
.mmt-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid #f1f5f9; }
.mmt-title { font-size: 20px; font-weight: 700; color: #0f172a; display: flex; align-items: center; gap: 8px; margin: 0; }
.mmt-balance-area { display: flex; align-items: center; gap: 10px; }
.mmt-balance { background: #f0f9ff; color: #0284c7; padding: 6px 14px; border-radius: 20px; font-size: 14px; font-weight: 600; border: 1px solid #bae6fd; }
.mmt-deposit-btn { background: #f59e0b !important; color: white !important; padding: 7px 16px !important; border-radius: 20px !important; font-size: 13px !important; font-weight: bold !important; text-decoration: none !important; border: none !important; box-shadow: 0 2px 5px rgba(245, 158, 11, 0.3); }
.mmt-deposit-btn:hover { background: #d97706 !important; transform: translateY(-1px); }

/* TABS */
.mmt-tabs { display: flex; gap: 5px; background: #f1f5f9; padding: 5px; border-radius: 10px; margin-bottom: 24px; }
.mmt-tab { flex: 1; text-align: center; padding: 10px; cursor: pointer; font-size: 14px; font-weight: 600; color: #64748b; border-radius: 8px; transition: 0.2s; background: transparent; }
.mmt-tab.active { background: #fff; color: #0f172a; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.mmt-tab-content { display: none; animation: fadeIn 0.3s; }
.mmt-tab-content.active { display: block; }

/* GRID & TOOLTIP (TTS) */
.mmt-model-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-top: 8px; }
.mmt-radio-card { position: relative; cursor: pointer; margin: 0; } 
.mmt-radio-card input { display: none; }
.mmt-rc-content { border: 1px solid #e2e8f0; border-radius: 8px; padding: 10px; background: #fff; display: flex; flex-direction: column; gap: 2px; transition: all 0.2s ease; height: 100%; text-align: center; }
.mmt-rc-head { display: flex; align-items: center; justify-content: center; gap: 5px; }
.mmt-rc-title { font-weight: 700; font-size: 13px; color: #334155; }
.mmt-rc-price { font-size: 11px; color: #64748b; }
.mmt-radio-card input:checked + .mmt-rc-content { border-color: #6366f1; background: #eef2ff; box-shadow: 0 0 0 1px #6366f1; }
.mmt-radio-card input:checked + .mmt-rc-content .mmt-rc-title { color: #4338ca; }
.mmt-radio-card:hover .mmt-rc-content { border-color: #cbd5e1; transform: translateY(-1px); }

/* Tooltip TTS */
.mmt-tooltip-wrap { position: relative; display: inline-flex; align-items: center; }
.mmt-info-icon { font-size: 14px; color: #94a3b8; cursor: help; }
.mmt-info-icon:hover { color: #6366f1; }
.mmt-tooltip-text { visibility: hidden; width: 220px; background-color: #1e293b; color: #fff; text-align: left; border-radius: 6px; padding: 10px; position: absolute; z-index: 100; bottom: 135%; left: 50%; margin-left: -110px; opacity: 0; transition: opacity 0.3s; font-size: 11px; line-height: 1.4; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); pointer-events: none; }
.mmt-tooltip-wrap:hover .mmt-tooltip-text { visibility: visible; opacity: 1; }

/* === NEW: TOOLTIP CLONE LIMIT (FIX HIỂN THỊ) === */
.mmt-limit-info { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; color: #64748b; position: relative; }
.mmt-tooltip-wrap-right { position: relative; display: inline-flex; align-items: center; cursor: help; }
.mmt-tooltip-content { visibility: hidden; opacity: 0; position: absolute; bottom: 150%; right: -10px; width: 280px; background: #fff; border: 1px solid #e2e8f0; box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.15); border-radius: 8px; padding: 15px; z-index: 999; text-align: left; transition: all 0.2s ease; transform: translateY(10px); }
.mmt-tooltip-content::after { content: ""; position: absolute; top: 100%; right: 12px; border-width: 6px; border-style: solid; border-color: #fff transparent transparent transparent; }
.mmt-tooltip-wrap-right:hover .mmt-tooltip-content { visibility: visible; opacity: 1; transform: translateY(0); }
.mmt-tt-title { font-weight: 700; color: #334155; margin-bottom: 8px; border-bottom: 1px solid #f1f5f9; padding-bottom: 5px; }
.mmt-tt-list { list-style: none; padding: 0; margin: 0; }
.mmt-tt-list li { font-size: 12px; color: #475569; margin-bottom: 5px; display: flex; justify-content: space-between; }
.mmt-tt-btn { display: block; text-align: center; margin-top: 10px; background: #6366f1; color: #fff; padding: 8px; border-radius: 6px; text-decoration: none; font-size: 12px; font-weight: 600; transition: 0.2s; }
.mmt-tt-btn:hover { background: #4f46e5; color: #fff; }

/* FORM ELEMENTS */
.mmt-form-group { margin-bottom: 20px; }
.mmt-form-group label { display: block; font-weight: 600; font-size: 13px; color: #475569; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.mmt-select, .mmt-input, .mmt-textarea { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; color: #1e293b; background: #fff; min-height: 42px; line-height: 1.5; font-family: inherit; }
.mmt-select:focus, .mmt-input:focus, .mmt-textarea:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }
.mmt-voice-selector { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid #cbd5e1; border-radius: 10px; cursor: pointer; transition: 0.2s; background: #fff; }
.mmt-voice-selector:hover { border-color: #6366f1; background: #f8fafc; }
.mmt-vs-avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; background: #e2e8f0; }
.mmt-vs-info { flex: 1; display: flex; flex-direction: column; }
.mmt-vs-name { font-weight: 700; color: #334155; font-size: 15px; }
.mmt-vs-hint { font-size: 12px; color: #94a3b8; }

/* ADVANCED & BUTTONS */
.mmt-advanced-toggle { margin-bottom: 15px; cursor: pointer; color: #6366f1; font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 5px; width: fit-content; }
.mmt-advanced-content { display: none; background: #f8fafc; padding: 20px; border-radius: 12px; border: 1px solid #e2e8f0; margin-bottom: 20px; }
.mmt-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 15px; }
.mmt-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 15px; padding-top: 15px; border-top: 1px solid #f1f5f9; }
.mmt-btn { background: #6366f1; color: white; border: none; padding: 12px 28px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; font-size: 15px; }
.mmt-btn:hover { background: #4f46e5; transform: translateY(-1px); } 
.mmt-btn:disabled { background: #94a3b8; cursor: not-allowed; }
.mmt-btn-outline { background: transparent; border: 1px solid #6366f1; color: #6366f1; width: 100%; } .mmt-btn-outline:hover { background: #f5f3ff; }

/* PROGRESS BAR */
#mmt-progress-area { display: none; margin-top: 20px; background: #fff; padding: 15px; border: 1px solid #e2e8f0; border-radius: 10px; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05); }
.mmt-progress-bar { width: 100%; height: 12px; background: #f1f5f9; border-radius: 6px; overflow: hidden; border: 1px solid #e2e8f0; position: relative; margin-top: 5px; }
.mmt-progress-fill { width: 0%; height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); transition: width 0.3s ease-in-out; position: relative; }
.mmt-progress-fill::after { content: ""; position: absolute; top: 0; left: 0; bottom: 0; right: 0; background-image: linear-gradient(45deg,rgba(255, 255, 255, 0.15) 25%,transparent 25%,transparent 50%,rgba(255, 255, 255, 0.15) 50%,rgba(255, 255, 255, 0.15) 75%,transparent 75%,transparent); background-size: 20px 20px; animation: moveStripe 1s linear infinite; }

/* UPLOAD & CLONE */
.mmt-upload-zone { position: relative; width: 100%; margin-bottom: 10px; }
.mmt-upload-input { position: absolute; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 2; }
.mmt-upload-label { display: flex; flex-direction: column; align-items: center; justify-content: center; border: 2px dashed #cbd5e1; border-radius: 12px; padding: 30px; background: #f8fafc; text-align: center; }
.mmt-upload-icon { font-size: 40px; color: #94a3b8; margin-bottom: 10px; }
.mmt-preview-box { display: none; margin-top: 15px; background: #f1f5f9; padding: 10px; border-radius: 8px; align-items: center; gap: 10px; border: 1px solid #e2e8f0; }
.mmt-mini-btn { background: #fff; border: 1px solid #cbd5e1; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; color: #64748b; } 
.mmt-legal-box { margin-top: 15px; margin-bottom: 25px; padding: 15px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; }
.mmt-clone-item { display: flex; align-items: center; justify-content: space-between; background: #fff; border: 1px solid #e2e8f0; padding: 12px 15px; border-radius: 8px; margin-bottom: 10px; }
.mmt-edit-clone-btn, .mmt-delete-clone-btn { width: 34px; height: 34px; border-radius: 6px; border: 1px solid #e2e8f0; background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #64748b; }

/* SAMPLE GRID STYLE (NÂNG CẤP) */
.mmt-sample-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; margin-top: 10px; max-height: 380px; overflow-y: auto; padding-right: 5px; }
.mmt-sample-grid::-webkit-scrollbar { width: 6px; }
.mmt-sample-grid::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.mmt-sample-card { background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; text-align: center; transition: all 0.2s ease; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; height: 100%; box-sizing: border-box; }
.mmt-sample-card:hover { border-color: #6366f1; transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); }
.mmt-sc-img { width: 48px; height: 48px; border-radius: 50%; object-fit: cover; margin: 0 auto 8px; background: #f1f5f9; }
.mmt-sc-name { font-size: 13px; font-weight: 600; color: #334155; margin-bottom: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mmt-sc-btn { font-size: 11px; padding: 6px; width: 100%; background: #eff6ff; color: #4f46e5; border: 1px solid #e0e7ff; border-radius: 4px; font-weight: 700; cursor: pointer; transition: 0.2s; }
.mmt-sample-card:hover .mmt-sc-btn { background: #6366f1; color: #fff; border-color: #6366f1; }

/* HISTORY */
.mmt-history-section { margin-top: 32px; border-top: 1px solid #f1f5f9; padding-top: 24px; }
.mmt-history-item { background: #fff; border: 1px solid #e2e8f0; padding: 16px; border-radius: 12px; margin-bottom: 12px; }
.mmt-h-info { display: flex; flex-direction: column; gap: 6px; }
.mmt-h-actions { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 5px; } 
.mmt-h-actions audio { height: 36px; flex: 1; border-radius: 18px; }
.mmt-copy-btn, .mmt-dl-btn { background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; width: 36px; height: 36px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: #64748b; }
.mmt-badge { font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 4px; text-transform: uppercase; }
.mmt-badge-turbo { background: #e0f2fe; color: #0284c7; }
.mmt-badge-hd { background: #dcfce7; color: #16a34a; }
.mmt-badge-v26 { background: #f3e8ff; color: #7e22ce; }
.mmt-badge-clone { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }

/* FIXED MODAL */
.mmt-modal { display: none; position: fixed !important; z-index: 2147483647 !important; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; background-color: rgba(15, 23, 42, 0.75) !important; backdrop-filter: blur(4px); align-items: center; justify-content: center; }
.mmt-lib-content { background-color: #fff !important; width: 90% !important; max-width: 900px !important; height: 85vh !important; border-radius: 16px !important; display: flex !important; flex-direction: column !important; margin: auto !important; position: relative !important; animation: scaleUp 0.2s ease; }
.mmt-lib-header { padding: 20px 24px !important; border-bottom: 1px solid #e2e8f0 !important; display: flex !important; justify-content: space-between !important; align-items: center !important; background: #fff !important; border-radius: 16px 16px 0 0 !important; }
.mmt-lib-header h3 { margin: 0 !important; font-size: 18px !important; color: #1e293b !important; font-weight: 700 !important; }
.mmt-lib-search { flex: 1 !important; margin: 0 20px !important; padding: 10px 16px !important; border: 1px solid #e2e8f0 !important; border-radius: 24px !important; font-size: 14px !important; background: #f8fafc !important; height: 40px !important; }
.mmt-modal-close-simple { font-size: 32px !important; border: none !important; background: none !important; cursor: pointer !important; color: #64748b !important; padding: 0 !important; line-height: 1 !important; }
.mmt-lib-tabs { display: flex !important; gap: 8px !important; padding: 12px 24px !important; border-bottom: 1px solid #f1f5f9 !important; background: #fff !important; }
.mmt-lib-tab { border: 1px solid #e2e8f0 !important; background: #fff !important; font-weight: 600 !important; color: #64748b !important; cursor: pointer !important; padding: 6px 16px !important; border-radius: 20px !important; font-size: 13px !important; }
.mmt-lib-tab:hover { background: #f8fafc !important; }
.mmt-lib-tab.active { background: #e0e7ff !important; color: #4338ca !important; border-color: #e0e7ff !important; }
.mmt-lib-grid { flex: 1 !important; overflow-y: auto !important; padding: 24px !important; display: grid !important; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)) !important; gap: 20px !important; background: #f8fafc !important; border-radius: 0 0 16px 16px !important; }
.mmt-voice-card { background: #fff !important; border: 1px solid #e2e8f0 !important; border-radius: 12px !important; padding: 16px !important; display: flex !important; flex-direction: column !important; gap: 12px !important; cursor: default !important; position: relative !important; box-shadow: none !important; margin: 0 !important; }
.mmt-voice-card:hover { transform: translateY(-4px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05) !important; border-color: #cbd5e1 !important; }
.mmt-vc-avatar-wrap { width: 56px; height: 56px; align-self: center; position: relative; }
.mmt-vc-avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; display: block; }
.mmt-play-btn { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 50%; background: rgba(0,0,0,0.4); color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; opacity: 0; transition: 0.2s; }
.mmt-voice-card:hover .mmt-play-btn { opacity: 1; }
.mmt-play-btn.playing { opacity: 1; background: rgba(99, 102, 241, 0.9); }
.mmt-play-btn.loading { opacity: 1; background: rgba(255, 255, 255, 0.8); color: #6366f1; }
.mmt-play-btn.loading span { animation: spin 1s infinite linear; }
.mmt-play-btn.loading span:before { content: "\f463"; }
.mmt-vc-info { text-align: center; }
.mmt-vc-name { font-weight: 700; color: #334155; font-size: 15px; margin: 0 0 4px 0 !important; }
.mmt-vc-tags { display: flex; justify-content: center; gap: 5px; flex-wrap: wrap; }
.mmt-tag { font-size: 11px; background: #f1f5f9; padding: 3px 8px; border-radius: 4px; color: #64748b; }
.mmt-use-btn { width: 100%; padding: 10px; background: #f1f5f9 !important; border: 1px solid #cbd5e1 !important; border-radius: 8px !important; font-weight: 600; color: #475569 !important; cursor: pointer; }
.mmt-use-btn:hover { background: #6366f1 !important; color: white !important; border-color: #6366f1 !important; }
.mmt-modal-content { background-color: #fff; margin: auto; padding: 30px; border: 0; width: 90%; max-width: 400px; border-radius: 16px; text-align: center; box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1); animation: scaleUp 0.3s ease; }
.mmt-modal-icon { width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 32px; }
.mmt-modal-icon.error { background: #fee2e2; color: #ef4444; } .mmt-modal-icon.error::after { content: "✕"; }
.mmt-modal-icon.success { background: #dcfce7; color: #22c55e; } .mmt-modal-icon.success::after { content: "✓"; }
.mmt-modal-close { background: #f1f5f9; color: #475569; border: none; padding: 10px 30px; border-radius: 8px; font-weight: 600; cursor: pointer; margin-top: 20px; }
.mmt-modal-actions { display: flex; gap: 12px; margin-top: 20px; justify-content: center; }
.mmt-modal-actions .mmt-btn { flex: 1; padding: 10px; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleUp { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes spin { 100% { transform: rotate(360deg); } }
@keyframes moveStripe { 0% { background-position: 0 0; } 100% { background-position: 20px 0; } }

/* =================================================================
   MOBILE FIX (CỰC KỲ QUAN TRỌNG ĐỂ HIỂN THỊ KHUNG TÌM KIẾM)
   ================================================================= */
@media (max-width: 600px) {
    /* Layout cơ bản */
    .mmt-grid-2, .mmt-model-grid { grid-template-columns: 1fr; gap: 10px; } 
    .mmt-footer { flex-direction: column; gap: 15px; align-items: stretch; } 
    .mmt-cost { text-align: center; margin-bottom: 5px; } 
    .mmt-header { flex-direction: column; align-items: flex-start; gap: 10px; } 
    .mmt-balance-area { width: 100%; justify-content: space-between; } 
    .mmt-lib-content { height: 95vh; width: 95%; }

    /* --- FIX HEADER MODAL TRÊN MOBILE --- */
    .mmt-lib-header {
        flex-direction: column !important; /* Xếp dọc */
        align-items: flex-start !important;
        position: relative !important;
        padding: 45px 15px 15px 15px !important; /* Chừa chỗ cho Title ở trên */
        gap: 10px !important;
    }

    /* 1. Tiêu đề "Thư viện..." */
    .mmt-lib-header h3 {
        position: absolute !important;
        top: 15px !important;
        left: 15px !important;
        margin: 0 !important;
        font-size: 16px !important;
    }

    /* 2. Nút đóng (X) */
    .mmt-modal-close-simple {
        position: absolute !important;
        top: 10px !important;
        right: 15px !important;
        margin: 0 !important;
        z-index: 99;
    }

    /* 3. Khung chứa Input + Button (Wrapper) */
    .mmt-lib-header > div {
        width: 100% !important;
        margin: 0 !important;
        display: flex !important;
        gap: 5px !important;
        box-sizing: border-box !important;
    }

    /* 4. Ô Input tìm kiếm */
    #mmt-lib-search-manual {
        flex: 1 !important;
        width: auto !important;
        border: 1px solid #ccc !important; /* Viền xám rõ */
        background-color: #f9f9f9 !important; /* Nền hơi xám để nổi bật */
        color: #333 !important;
        min-height: 40px !important;
        margin: 0 !important;
        padding: 0 10px !important;
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
    }
    
    /* 5. Nút tìm */
    #mmt-lib-search-btn {
        width: auto !important;
        min-width: 60px !important;
        padding: 0 10px !important;
    }
}