/**
 * Bangla Typing Test Styles
 * Version: 1.3.1
 */

/* --- Container & Global --- */
.btt-container {
    /* Added specific Bangla fonts for better rendering */
    font-family: "Hind Siliguri", "SolaimanLipi", "Kalpurush", "Helvetica Neue", Helvetica, Arial, sans-serif;
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    background-color: #ffffff;
}

.btt-header {
    text-align: center;
    margin-bottom: 2rem;
}

.btt-header h2 {
    margin: 0 0 0.5rem;
    font-size: 2rem;
    color: #1a202c;
}

.btt-header p {
    margin: 0;
    color: #718096;
    font-size: 1rem;
}

/* --- Controls (Dropdowns & Buttons) --- */
.btt-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #edf2f7;
}

.btt-controls label {
    font-weight: 700;
    color: #4a5568;
    font-size: 0.9rem;
}

.btt-controls select {
    padding: 0.5rem 2rem 0.5rem 0.8rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.95rem;
    background-color: #fff;
    cursor: pointer;
    outline: none;
}

.btt-controls select:focus {
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.btt-secondary-btn {
    background: #edf2f7;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btt-secondary-btn:hover {
    background: #e2e8f0;
    color: #1a202c;
}

/* --- Stats Dashboard --- */
.btt-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
    background-color: #f7fafc;
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid #edf2f7;
}

.btt-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 0.85rem;
    color: #718096;
}

.btt-stat strong {
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.75rem;
}

.btt-stat span {
    font-size: 1.5rem;
    font-weight: 800;
    color: #2d3748;
}

/* Specific color highlighting for stats */
#btt-time-left { color: #3182ce; }
#btt-wpm { color: #d69e2e; }
#btt-accuracy { color: #805ad5; }
#btt-correct { color: #38a169; }
#btt-wrong { color: #e53e3e; }

/* --- Typing Area --- */
.btt-test-area {
    position: relative;
    margin-bottom: 1.5rem;
}

.btt-text {
    /* Height calculation for approx 3 lines:
       Font size: 1.3rem
       Line height: 1.8
       1 Line = 1.3 * 1.8 = 2.34rem
       3 Lines = 7.02rem
       Padding = 1rem (top) + 1rem (bottom) = 2rem
       Total = ~9rem. Setting 10rem (160px) for comfort.
    */
    height: 10rem;
    overflow-y: hidden; /* Hides scrollbar but allows JS to scroll */
    position: relative; /* Crucial for offsetTop calculations */
    
    margin-bottom: 1rem;
    line-height: 1.8; 
    font-size: 1.3rem; 
    color: #4a5568;
    background: #fff;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    user-select: none; 
    
    /* Smooth scrolling behavior */
    scroll-behavior: auto; 
}

.btt-input {
    width: 100%;
    height: 60px;
    resize: none;
    padding: 0.75rem;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    font-size: 1.2rem;
    font-family: inherit;
    background-color: #fff;
    color: #2d3748;
    transition: all 0.2s ease;
}

/* Strong focus state since there is no start button */
.btt-input:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 4px rgba(66, 153, 225, 0.2);
}

.btt-input:disabled {
    background-color: #edf2f7;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Word Highlighting */
.btt-word {
    padding: 2px 4px;
    border-radius: 4px;
    margin: 0 1px;
}

.btt-word.btt-current {
    background-color: #bee3f8; /* Soft Blue */
    color: #2b6cb0;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.btt-word.btt-correct {
    color: #38a169; /* Green text */
}

.btt-word.btt-wrong {
    background-color: #fed7d7; /* Soft Red Bg */
    color: #c53030; /* Dark Red Text */
    text-decoration: line-through;
}

/* --- Results & Messages --- */
.btt-result {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    min-height: 2.5rem; /* Reserve space */
    display: flex;
    align-items: center;
    justify-content: center;
}

.btt-result:empty { display: none; }
.btt-result.is-good { background: #c6f6d5; color: #22543d; border: 1px solid #9ae6b4; }
.btt-result.is-warn { background: #feebc8; color: #744210; border: 1px solid #fbd38d; }
.btt-result.is-bad  { background: #fed7d7; color: #822727; border: 1px solid #feb2b2; }

/* --- Progress & Certificate --- */
.btt-progress {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid #edf2f7;
}

.btt-progress-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: #a0aec0;
    margin-bottom: 1rem;
    letter-spacing: 0.05em;
}

.btt-certificate-btn {
    width: 100%;
    max-width: 300px;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 700;
    font-size: 1rem;
    background: #38a169;
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(56, 161, 105, 0.2);
    transition: all 0.2s ease;
}

.btt-certificate-btn:disabled {
    background: #cbd5e0;
    color: #718096;
    box-shadow: none;
    cursor: not-allowed;
}

.btt-certificate-btn:not(:disabled):hover {
    background: #2f855a;
    transform: translateY(-1px);
    box-shadow: 0 6px 8px rgba(56, 161, 105, 0.3);
}

.btt-hint {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #718096;
}

/* --- Modal --- */
.btt-modal {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 99999;
}

.btt-modal.is-open { display: flex; align-items: center; justify-content: center; }

.btt-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
}

.btt-modal__dialog {
    position: relative;
    width: 90%;
    max-width: 500px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.btt-modal__header {
    padding: 1rem 1.5rem;
    background: #f7fafc;
    border-bottom: 1px solid #edf2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btt-modal__header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #2d3748;
}

.btt-icon-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: #a0aec0;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.btt-icon-btn:hover { color: #e53e3e; }

.btt-modal__body { padding: 1.5rem; }

.btt-input-text {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1rem;
    margin-top: 0.5rem;
}

.btt-input-text:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

.btt-modal__note {
    font-size: 0.85rem;
    color: #718096;
    margin-top: 0.75rem;
    line-height: 1.4;
}

.btt-modal__footer {
    padding: 1rem 1.5rem;
    background: #f7fafc;
    border-top: 1px solid #edf2f7;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* This class is used by the Modal Generate Button */
.btt-start-btn {
    background-color: #3182ce;
    color: #fff;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btt-start-btn:hover { background-color: #2b6cb0; }
.btt-start-btn:disabled { background-color: #cbd5e0; cursor: wait; }

/* --- Hidden Certificate Template (PDF Generation) --- */
/* Kept largely static to ensure PDF rendering stays consistent */
.btt-certificate {
    position: fixed;
    left: -99999px;
    top: 0;
    width: 210mm;
    height: 297mm;
    background: #ffffff;
    padding: 14mm;
    color: #000;
    z-index: -1;
}

.btt-cert__border {
    width: 100%;
    height: 100%;
    border: 3px solid #2c3e50;
    padding: 14mm;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.btt-cert__top { text-align: center; margin-bottom: 10mm; }
.btt-cert__brand { font-size: 24pt; font-weight: 900; letter-spacing: 1px; color: #2d3748; }
.btt-cert__title { font-size: 22pt; font-weight: 900; margin-top: 8mm; color: #1a202c; }
.btt-cert__subtitle { font-size: 14pt; margin-top: 3mm; color: #4a5568; }

.btt-cert__body { text-align: center; flex: 1; }
.btt-cert__text { font-size: 13pt; line-height: 1.6; color: #4a5568; }
.btt-cert__name { 
    font-size: 20pt; 
    font-weight: 900; 
    margin: 8mm 0; 
    padding-bottom: 2mm; 
    border-bottom: 2px solid #cbd5e0; 
    display: inline-block; 
    min-width: 100mm;
}

.btt-cert__table {
    margin: 15mm auto 0;
    width: 160mm;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    overflow: hidden;
}

.btt-cert__row {
    display: flex;
    justify-content: space-between;
    padding: 5mm 8mm;
    font-size: 12pt;
    border-bottom: 1px solid #e2e8f0;
}
.btt-cert__row:last-child { border-bottom: none; }
.btt-cert__cell { font-weight: 600; color: #2d3748; }

.btt-cert__footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-top: auto;
    font-size: 11pt;
    color: #718096;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .btt-container { padding: 1rem; }
    .btt-stats { grid-template-columns: repeat(2, 1fr); }
    .btt-controls { flex-direction: column; align-items: stretch; }
    .btt-controls select { width: 100%; }
    .btt-secondary-btn { width: 100%; text-align: center; }
    .btt-header h2 { font-size: 1.5rem; }
}