/* =======================================
    1. Theme Variables and Global Styles (CSS)
    ======================================= */
:root {
    --tt-primary-blue: #007bff;
    --tt-primary-dark: #343a40;
    --tt-text-main: #212529;
    --tt-bg-main: #f8f9fa;
    --tt-bg-card: #ffffff;
    --tt-shadow-card: rgba(0, 0, 0, 0.1);
    --tt-border-color: #ced4da;
    --tt-success: #28a745;
    --tt-fail: #dc3545;
}

.dark-mode {
    --tt-primary-blue: #4dabf7;
    --tt-primary-dark: #1e1e1e;
    --tt-text-main: #f8f9fa;
    --tt-bg-main: #121212;
    --tt-bg-card: #1f1f1f;
    --tt-shadow-card: rgba(256, 256, 256, 0.1);
    --tt-border-color: #2a2a2a;
    --tt-success: #3ddc84;
    --tt-fail: #ff6b6b;
}


body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--tt-bg-main);
    color: var(--tt-text-main);
}

.container {
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Header and Buttons --- */
.main-header {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: var(--tt-primary-dark);
    padding: 15px 0;
}

.main-header .container {
    max-width: 1000px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-decoration: none;
}

.com-highlight {
    color: var(--tt-primary-blue);
}

.nav-item {
    padding: 10px;
}

.nav-item.active {
    background: var(--tt-primary-blue);
    border-radius: 10px;
}

.main {
    padding-top: 70px;
}

/* ========================================== */
/* === Language Select Interface (Page 1) === */
/* ========================================== */
.hero-section {
    margin: 10px auto;
    max-width: 1000px;
    background: var(--tt-bg-card);
    border-radius: 20px;
    border: 1px solid var(--tt-border-color);
    box-shadow: 0 1px 3px var(--tt-shadow-card);

}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    margin: 5px;
    transition: background-color 0.3s;
}

.btn-primary {
    background-color: var(--tt-primary-blue);
    color: white;
}

.btn-primary:hover {
    background-color: #0056b3;
}

.btn-exam-select {
    background-color: var(--tt-bg-card);
    color: var(--tt-text-main);
    border: 1px solid var(--tt-border-color);
}

.btn-exam-select:hover {
    background-color: #e9ecef;
}

/* --- Rules Card --- */
.rules-summary-card {
    background-color: var(--tt-bg-card);
    border: 1px solid var(--tt-primary-blue);
    padding: 20px;
    border-radius: 8px;
    max-width: 700px;
    margin: 30px auto;
    text-align: left;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.rules-summary-card ul {
    list-style-type: disc;
    padding-left: 20px;
}

.rules-summary-card li {
    margin-bottom: 8px;
}



/* ================================= */
/* === Typing Interface (Page 2) === */
/* ================================= */
.typing-section {
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.main-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0;
}

.typing-test-section {
    background-color: var(--tt-bg-card);
    border: 1px solid var(--tt-border-color);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    padding: 0;
    order: 1;
}

.user-section {
    background-color: var(--tt-bg-card);
    border: 1px solid var(--tt-border-color);
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    padding: 0px;
    text-align: center;
    order: 2;
}


/* 💻 MEDIA QUERY FOR LARGE SCREENS 💻 */
@media (min-width: 950px) {
    .main-content-wrapper {
        flex-direction: row;
        padding: 0 30px;
    }

    .typing-test-section {
        width: 75%;
    }

    .user-section {
        width: 25%;
    }
}

.test-header,
.user-section h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background-color: var(--tt-primary-blue);
    color: white;
    border-radius: 7px 7px 0 0;
    margin-top: 0;
    /* Ensures the header is flush with the top of its parent */
}


.timer-box {
    font-size: 20px;
    font-weight: 700;
}

.typing-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 20px;
    background-color: var(--tt-bg-card);
    border: none;
    border-top: 1px solid var(--tt-border-color);
    border-radius: 0 0 8px 8px;
}

.text-box {
    width: 100%;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid var(--tt-border-color);
    line-height: 1.8;
    font-family: 'Courier New', Courier, monospace;
    box-sizing: border-box;
    /* 💯 IMPORTANT: Prevents padding/border from increasing width */
}

.source-text-box {
    height: 180px;
    overflow-y: scroll;
    background-color: var(--tt-bg-main);
    font-size: 18px;
    color: var(--tt-text-main);
    text-align: justify;
}

.typing-input-box {
    height: 140px;
    resize: none;
    background-color: var(--tt-bg-card);
    font-size: 18px;
    color: var(--tt-text-main);
}

.live-metrics-bar {
    display: flex;
    justify-content: space-around;
    padding: 10px;
    background-color: var(--tt-primary-dark);
    color: white;
    border-radius: 5px;
    font-size: 16px;
    margin-top: 10px;
}

.test-footer {
    padding: 10px;
    text-align: end;
}

.btn-fail {
    margin: 0;
}



.user-section h3 {
    display: block;
    text-align: center;
}


/* =======================================
    4. Result Page Styling
    ======================================= */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.metric-box {
    background-color: var(--tt-bg-card);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.metric-box h3 {
    margin-top: 0;
    font-size: 16px;
    color: #6c757d;
}

.metric-box .value {
    font-size: 36px;
    font-weight: bold;
    color: var(--tt-primary-blue);
}

.metric-box.pass .value {
    color: var(--tt-success);
}

.metric-box.fail .value {
    color: var(--tt-fail);
}

.mistake-summary {
    margin-top: 30px;
    padding: 20px;
    border: 1px solid var(--tt-border-color);
    border-radius: 8px;
}

/* --- NEW STYLES FOR ANALYSIS --- */
#analysis-passage {
    border: 1px solid var(--tt-border-color);
    padding: 20px;
    margin-top: 20px;
    background-color: var(--tt-bg-main);
    min-height: 150px;
    line-height: 2.0;
    text-align: justify;
    font-family: Arial, sans-serif;
}

.word-correct {
    color: var(--tt-text-main);
}

.word-incorrect {
    color: var(--tt-fail);
    font-weight: bold;
    padding: 2px 0;
    cursor: help;
}

.correct-hint {
    color: #6c757d;
    font-weight: normal;
    font-size: 0.9em;
    margin-left: 5px;
}