/* --- VARIABLES & RESET --- */
:root {
    --bvg-primary: #6366f1;       /* Indigo: Generate */
    --bvg-primary-dark: #4f46e5;
    --bvg-secondary: #10b981;     /* Emerald: Download */
    --bvg-secondary-dark: #059669;
    --bvg-tertiary: #3b82f6;      /* Blue: Save to Media */
    --bvg-tertiary-dark: #2563eb;
    --bvg-bg: #f8fafc;
    --bvg-card-bg: #ffffff;
    --bvg-text-main: #1e293b;
    --bvg-text-sub: #64748b;
    --bvg-border: #e2e8f0;
    --bvg-radius: 12px;
    --bvg-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --bvg-shadow-hover: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.bvg-wrapper {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--bvg-text-main);
    line-height: 1.5;
    max-width: 800px;
    margin: 2rem auto;
}

.bvg-wrapper * {
    box-sizing: border-box;
}

/* --- MAIN CARD --- */
.bvg-card {
    background: var(--bvg-card-bg);
    border-radius: var(--bvg-radius);
    box-shadow: var(--bvg-shadow);
    padding: 2.5rem;
    border: 1px solid var(--bvg-border);
}

/* --- HEADER --- */
.bvg-header {
    text-align: center;
    margin-bottom: 2rem;
}

.bvg-icon-badge {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: inline-block;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.bvg-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -0.025em;
    color: var(--bvg-text-main);
}

.bvg-header .text-gradient {
    background: linear-gradient(135deg, var(--bvg-primary), #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.bvg-header p {
    color: var(--bvg-text-sub);
    font-size: 1rem;
    margin-top: 0.5rem;
}

/* --- FORM ELEMENTS --- */
.bvg-group {
    margin-bottom: 1.5rem;
}

.bvg-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--bvg-text-main);
}

.bvg-select-wrapper select,
.bvg-select-sm {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--bvg-border);
    background-color: #fff;
    font-size: 1rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

textarea#text-input {
    width: 100%;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid var(--bvg-border);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s ease;
}

.bvg-select-wrapper select:focus,
textarea#text-input:focus,
.bvg-select-sm:focus {
    outline: none;
    border-color: var(--bvg-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* SSML Toggle */
.bvg-toggle-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: var(--bvg-bg);
    border-radius: 8px;
}

.bvg-checkbox {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--bvg-primary);
    cursor: pointer;
}

/* SSML Templates (Pro) */
.bvg-ssml-wrapper {
    width: 100%;
    border-top: 1px dashed var(--bvg-border);
    padding-top: 0.75rem;
    margin-top: 0.5rem;
}

.bvg-select-sm {
    padding: 0.5rem;
    font-size: 0.9rem;
    color: var(--bvg-text-sub);
}

/* --- SLIDERS --- */
.bvg-controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.bvg-slider-box {
    background: var(--bvg-bg);
    padding: 1rem;
    border-radius: 8px;
}

.bvg-slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}

input[type=range] {
    width: 100%;
    cursor: pointer;
    accent-color: var(--bvg-primary);
}

/* --- BUTTONS --- */
.bvg-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Base Button Style */
.bvg-btn-primary,
.bvg-btn-secondary,
#download-container a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    border: none;
    border-radius: 50px; /* Fully curved */
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-decoration: none;
    line-height: 1;
}

/* 1. Generate Button (Purple) */
.bvg-btn-primary {
    background: linear-gradient(135deg, var(--bvg-primary), var(--bvg-primary-dark));
    width: 100%; /* Full width on mobile, auto on desktop */
}

.bvg-btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(99, 102, 241, 0.3);
}

.bvg-btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.bvg-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: var(--bvg-text-sub);
}

.bvg-btn-primary .btn-icon {
    margin-left: 8px;
    font-size: 1.2rem;
}

/* 2. Download Button (Green) - Injected via JS */
#download-container a {
    background-color: var(--bvg-secondary);
    margin-right: 10px;
}

#download-container a:hover {
    background-color: var(--bvg-secondary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(16, 185, 129, 0.3);
}

/* 3. Save to Media Button (Blue) - Pro Feature */
.bvg-btn-secondary,
#save-to-media-btn {
    background-color: var(--bvg-tertiary);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 0.85rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#save-to-media-btn:hover:not(:disabled) {
    background-color: var(--bvg-tertiary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(59, 130, 246, 0.3);
}

#save-to-media-btn:disabled {
    background-color: var(--bvg-text-sub);
    cursor: wait;
}

/* --- LOADER & MESSAGES --- */
.bvg-loader {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--bvg-text-sub);
    font-size: 0.9rem;
    font-weight: 500;
}

.bvg-loader .spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--bvg-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.hidden { display: none !important; }

@keyframes spin { to { transform: rotate(360deg); } }

.bvg-error {
    color: #ef4444;
    font-weight: 600;
    text-align: center;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: #fef2f2;
    border-radius: 6px;
    border: 1px solid #fee2e2;
}

/* --- AUDIO PLAYER --- */
.bvg-player-area {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--bvg-border);
}

.bvg-label-sm {
    display: block;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bvg-text-sub);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

#audio-player {
    width: 100%;
    border-radius: 30px;
}

/* --- HISTORY SECTION (PRO) --- */
.bvg-history-section {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--bvg-bg);
}

.bvg-history-section h3 {
    font-size: 1.1rem;
    color: var(--bvg-text-main);
    margin-bottom: 1rem;
}

#bvg-history-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

/* Custom Scrollbar for history */
#bvg-history-list::-webkit-scrollbar {
    width: 6px;
}
#bvg-history-list::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 3px;
}

/* History Item Card */
.bvg-history-item {
    background: #fff;
    border: 1px solid var(--bvg-border);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.bvg-history-item:hover {
    border-color: var(--bvg-primary);
    transform: translateX(4px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.bvg-history-meta {
    flex: 1;
    min-width: 0; /* Truncate fix */
    margin-right: 1rem;
}

.bvg-voice-tag {
    display: inline-block;
    background: #e0e7ff;
    color: var(--bvg-primary-dark);
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
    margin-right: 6px;
    vertical-align: middle;
}

.bvg-history-text {
    font-size: 0.9rem;
    color: var(--bvg-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
    vertical-align: middle;
    max-width: 70%;
}

.bvg-history-date {
    display: block;
    font-size: 0.75rem;
    color: var(--bvg-text-sub);
    margin-top: 2px;
}

/* Load Button in History */
.bvg-btn-xs {
    background: white;
    border: 1px solid var(--bvg-border);
    color: var(--bvg-text-main);
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.1s;
    font-weight: 600;
}

.bvg-btn-xs:hover {
    border-color: var(--bvg-primary);
    color: var(--bvg-primary);
    background: #f8fafc;
}
