/* ================= RESET & GLOBAL ================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.amaliy-body {
    background: #1e1e1e; /* Dark theme for editor */
    color: #d4d4d4;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    transition: 0.2s;
    background: #3498db;
    color: white;
    font-family: inherit;
}

.btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

/* ================= SELECTION SCREEN ================= */
.full-screen-center {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 50px;
    overflow-y: auto;
    z-index: 10;
}

.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px;
    width: 100%;
}

.topic-card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 1px solid #e1e4e8;
}

.topic-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    border-color: #3498db;
}

.topic-card h3 {
    margin-bottom: 10px;
    color: #2c3e50;
    font-size: 1.2em;
}

/* ================= EDITOR SCREEN ================= */
.split-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #1e1e1e;
}

.amaliy-header {
    height: 60px;
    background: #252526;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}

.play-btn {
    background: #2ecc71;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    white-space: nowrap;
}

.play-btn:hover {
    background: #27ae60;
}

.editors-grid {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr; /* HTML, CSS, JS */
    gap: 1px;
    background: #333; /* Gap color */
    height: calc(100vh - 60px);
    overflow: hidden;
}

.editor-column {
    background: #1e1e1e;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 0; /* Prevent overflow */
}

.editor-header {
    padding: 10px 15px;
    font-size: 13px;
    font-weight: bold;
    background: #252526;
    border-bottom: 1px solid #333;
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}

.editor-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.typing-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 15px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 16px;
    line-height: 1.6;
    color: #d4d4d4;
    overflow-y: auto;
    white-space: pre-wrap;
    outline: none;
    border: 2px solid transparent;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: #1e1e1e;
}
::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 5px;
}
::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ================= TYPING CHARACTERS ================= */
.t-char {
    opacity: 0.5; /* Untyped chars */
    border-bottom: 2px solid transparent;
}

.t-char.correct {
    opacity: 1;
    color: #fff;
    text-shadow: 0 0 1px rgba(255,255,255,0.5);
}

.t-char.wrong {
    background: rgba(231, 76, 60, 0.4);
    color: #ff6b6b;
    opacity: 1;
}

.t-char.current {
    background: #3498db;
    color: white;
    opacity: 1;
    animation: blink 1s infinite;
}

@keyframes blink {
    50% { opacity: 0.7; }
}

/* ================= QUIZ & MODIFICATION MODES ================= */

/* Quiz Mode Hover Effect */
.typing-container.quiz-mode {
    cursor: pointer;
    /* Removed opacity change */
}

.code-line {
    padding: 2px 5px;
    display: block;
    width: 100%;
    transition: background 0.2s;
    min-height: 26px; /* Ensure empty lines are clickable */
    border-radius: 2px;
    /* Ensure text is fully visible */
    opacity: 1 !important; 
}

/* Ensure characters inside are also fully visible in quiz mode */
.typing-container.quiz-mode .t-char {
    opacity: 1 !important;
}

.typing-container.quiz-mode .code-line:hover {
    background-color: rgba(52, 152, 219, 0.2); /* Subtle blue hover */
    border: 1px solid rgba(52, 152, 219, 0.4);
}

/* Correct Line (Quiz Mode) */
.line-correct {
    background-color: rgba(46, 204, 113, 0.15) !important;
    border: 1px solid rgba(46, 204, 113, 0.5);
}

/* Wrong Line Animation */
.line-wrong {
    background-color: rgba(231, 76, 60, 0.2) !important;
    animation: shake 0.5s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
    100% { transform: translateX(0); }
}

.check-icon {
    float: right;
    font-size: 16px;
    color: #2ecc71;
    font-weight: bold;
    margin-left: 10px;
}

/* MINI PLAY BUTTON */
.mini-play-btn {
    float: right;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    font-size: 10px;
    cursor: pointer;
    margin-left: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mini-play-btn:hover {
    background: #2980b9;
}

/* ================= MODIFICATION INPUT ================= */
.code-input {
    background: #2d2d2d;
    color: #fff;
    border: 1px solid #3498db;
    border-radius: 3px;
    outline: none;
    font-family: inherit;
    font-size: inherit;
    padding: 2px 5px;
    margin: 0;
    width: 100%;
    display: block;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5);
}

.input-error {
    border-color: #e74c3c !important;
    box-shadow: 0 0 5px rgba(231, 76, 60, 0.5) !important;
    animation: shake 0.4s;
}

/* ================= MODAL ================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
}

.modal-window {
    background: white;
    width: 90%;
    height: 90%;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    box-shadow: 0 15px 30px rgba(0,0,0,0.3);
}

.modal-header {
    padding: 15px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    color: #999;
    padding: 0 10px;
}

.close-btn:hover {
    color: #e74c3c;
}

#resultFrame {
    flex: 1;
    border: none;
    width: 100%;
    background: white;
}













:root {
    --primary: #4361ee;
    --success: #2ec4b6;
    --danger: #e63946;
    --light: #f8f9fa;
    --dark: #212529;
    --bg: #edf2f4;
}

/* 1. NUSXALASHNI TAQIQLASH (User Select) */
body {
    -webkit-user-select: none; /* Chrome/Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    user-select: none; /* Standard */
    
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg);
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: var(--dark);
}

/* Umumiy konteyner */
#app-container {
    width: 100%;
    max-width: 900px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    overflow: hidden;
    min-height: 80vh;
    display: flex;
    flex-direction: column;
}

/* LOGIN EKRANI */
.full-screen-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px;
    text-align: center;
}

input[type="text"] {
    width: 100%;
    max-width: 400px;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    margin-top: 10px;
    box-sizing: border-box;
    font-family: monospace;
}

/* MAVZU TANLASH EKRANI */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    width: 100%;
    padding: 20px;
}

.topic-card {
    background: var(--light);
    border: 2px solid transparent;
    padding: 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: 0.3s;
    text-align: left;
}

.topic-card:hover {
    border-color: var(--primary);
    background: #eef2ff;
    transform: translateY(-2px);
}

/* DARS INTERFEYSI */
#lesson-interface {
    display: none; 
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.header-bar {
    background: var(--dark);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-body {
    padding: 30px;
    flex: 1;
    overflow-y: auto;
}

/* Elementlar */
h2 { color: var(--primary); border-bottom: 2px solid var(--light); padding-bottom: 15px; }

.theory-point {
    margin-bottom: 20px;
    border-left: 4px solid var(--primary);
    padding-left: 15px;
    background: #fdfdfd;
    padding: 15px;
    border-radius: 0 8px 8px 0;
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    margin-top: 20px;
    transition: 0.2s;
}
.btn:hover { opacity: 0.9; }

/* Testlar */
.option {
    display: block;
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    text-align: left;
    border: 2px solid #eee;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-family: monospace;
    color: #333;
}
.option:hover { border-color: var(--primary); }
.option.correct { background: var(--success); color: white; border-color: var(--success); }
.option.wrong { background: var(--danger); color: white; border-color: var(--danger); }
.disabled-options .option { pointer-events: none; }

/* Amaliy vazifa */
.code-preview {
    display: flex;
    gap: 20px;
    margin-top: 20px;
    flex-wrap: wrap;
}
.code-box, .result-box {
    flex: 1;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fafafa;
    min-width: 300px;
}
.result-box {
    background: white;
    border: 2px dashed var(--primary);
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #555;
    word-break: break-all;
}

#feedback {
    margin-top: 20px;
    font-weight: bold;
    padding: 15px;
    border-radius: 6px;
    display: none;
}
.feedback-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.feedback-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

.progress-container {
    height: 6px;
    background: #eee;
    width: 100%;
}
.progress-bar {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: 0.4s;
}

/* Til tugmalari */
.lang-switch-btn {
    background: white;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 20px;
    cursor: pointer;
    border-radius: 4px;
    font-weight: bold;
    margin: 0 5px;
    transition: 0.3s;
}
.lang-switch-btn.active { 
    background: var(--primary); 
    color: white; 
}

.hidden { display: none !important; }
code { background: #eef; padding: 2px 5px; border-radius: 4px; color: #d63384; }

/* --- 2. YOZISH REJIMI (TYPING STYLES) --- */
.typing-container {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 20px;
    line-height: 1.8;
    background: #212529; /* To'q fon */
    color: #7d7d7d; /* Yozilmagan harflar */
    padding: 20px;
    border-radius: 10px;
    margin-top: 15px;
    position: relative;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.5);
    user-select: none;
}

.t-char {
    padding: 0 1px;
    border-radius: 2px;
    transition: all 0.1s;
}

/* To'g'ri yozilgan (Yashil) */
.t-char.correct {
    color: #2ecc71;
    text-shadow: 0 0 5px rgba(46, 204, 113, 0.4);
}

/* Xato yozilgan (Qizil fon) */
.t-char.wrong {
    color: #fff;
    background-color: #e74c3c;
    animation: shake 0.3s;
}

/* Hozirgi kursor (Tagiga chiziq va yorqin) */
.t-char.current {
    background-color: rgba(52, 152, 219, 0.3);
    color: #fff;
    border-bottom: 3px solid #3498db;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-2px); }
    75% { transform: translateX(2px); }
}

/* --- AMALIY MASHG'ULOTLAR PAGE (amaliy.php) --- */
/* Override default centering for amaliy page if needed */
body.amaliy-body {
    display: block; /* Full width */
    background: #1e1e1e;
    color: #ccc;
    height: 100vh;
    overflow: hidden;
}

.split-view {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.editors-grid {
    display: flex;
    flex: 1;
    overflow: hidden;
    border-top: 1px solid #333;
}

.editor-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #333;
    min-width: 0; /* Flexbox text overflow fix */
    background: #1e1e1e;
    transition: flex 0.3s ease; /* Smooth resizing */
}

/* When typing inside, make it wider */
.editor-column:focus-within {
    flex: 2; /* 2x wider than others */
}

.editor-column:last-child {
    border-right: none;
}

.editor-header {
    background: #252526;
    color: #ccc;
    padding: 8px 15px;
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-content {
    flex: 1;
    position: relative;
    overflow: auto;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
}

/* Typing override for dark theme editor */
.editor-content .typing-container {
    margin: 0;
    border-radius: 0;
    min-height: 100%;
    background: transparent;
    box-shadow: none;
    padding: 10px;
    white-space: pre; 
    overflow: visible;
}

/* Play Button Header */
.amaliy-header {
    background: #2d2d2d;
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 10;
}

.play-btn {
    background: #2ecc71;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    transition: 0.2s;
}
.play-btn:hover { background: #27ae60; transform: scale(1.05); }

/* Modal Result */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }

.modal-window {
    width: 90%;
    height: 90%;
    background: white;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    transform: scale(0.9);
    transition: 0.3s;
}
.modal-overlay.active .modal-window { transform: scale(1); }

.modal-header {
    padding: 10px 20px;
    background: #f1f1f1;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}
.close-btn:hover { color: #e74c3c; }

iframe#resultFrame {
    flex: 1;
    border: none;
    width: 100%;
    background: white;
}

