/* Biến nội bộ */
.optic-neo-wrapper {
    --bg-white: #ffffff;
    --border-ink: 3px solid #111111;
    --shadow-solid: 5px 5px 0px #111111;
    --shadow-push: 2px 2px 0px #111111;
    
    /* Bảng màu Quang học */
    --clr-converge: #f4a261; /* Cam hội tụ */
    --clr-diverge: #2a9d8f;  /* Xanh phân kì */
    --clr-obj: #0077b6;      /* Xanh dương - Vật */
    --clr-img: #e63946;      /* Đỏ - Ảnh */
    --clr-bg: #f8f9fa;
    --clr-highlight: #e0fbfc;

    max-width: 850px;
    margin: 0 auto;
    font-family: system-ui, -apple-system, sans-serif;
    color: #111111;
    background: var(--clr-bg);
    padding: 20px;
    border: var(--border-ink);
    border-radius: 16px;
    box-shadow: 8px 8px 0px #111;
}

.optic-neo-wrapper * { box-sizing: border-box; }

/* Header */
.optic-neo-header { background: var(--clr-highlight); border: var(--border-ink); box-shadow: var(--shadow-solid); padding: 20px; border-radius: 12px; text-align: center; margin-bottom: 25px; }
.optic-neo-header h2 { margin: 0 0 10px 0; font-size: 1.8rem; font-weight: 900; text-transform: uppercase; color: #111;}
.optic-neo-header p { margin: 0; font-weight: 800; font-size: 0.95rem; color: #111; }

/* Form Styles */
.optic-neo-form { display: flex; flex-direction: column; gap: 20px; }
.optic-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.optic-group { display: flex; flex-direction: column; gap: 10px; }
.optic-group label { font-weight: 900; font-size: 1.05rem; color: #111; }

/* CSS FIX CHUẨN Ô INPUT & SELECT (Chống méo) */
.input-with-select { 
    display: flex; 
    flex-wrap: nowrap; 
    align-items: stretch;
    border: var(--border-ink); 
    border-radius: 12px; 
    box-shadow: 4px 4px 0px #111; 
    background: #fff; 
    overflow: hidden; 
    width: 100%;
}
.input-with-select input { 
    border: none !important; 
    border-radius: 0 !important; 
    box-shadow: none !important; 
    flex: 1; 
    width: 100%; 
    min-width: 50%; 
    padding: 16px 15px !important; 
    font-size: 1.3rem !important; 
    font-weight: 900;
    color: #111;
    outline: none;
}
.input-with-select select { 
    border: none; 
    border-left: 3px solid #111; 
    padding: 0 15px; 
    font-weight: 900; 
    font-size: 1.1rem; 
    background: #e9ecef; 
    outline: none; 
    cursor: pointer; 
    color: #111; 
    flex: 0 0 auto; 
    width: 90px; 
    text-align: center;
}
.input-with-select select:disabled { opacity: 1; color: #111; background: #e9ecef;}
.input-with-select input:focus { background: var(--clr-highlight); }

/* Toggle Quang Cụ */
.optic-radio-grid { display: flex; gap: 15px; }
.optic-radio-grid .radio-neo { flex: 1; cursor: pointer; }
.optic-radio-grid input { display: none; }
.optic-radio-grid .neo-content { display: flex; align-items: center; justify-content: center; text-align: center; padding: 14px; font-weight: 900; border: var(--border-ink); border-radius: 12px; background: var(--bg-white); box-shadow: 4px 4px 0px #111; transition: all 0.15s; font-size: 1.05rem; color: #111;}
.optic-radio-grid input[value="converging"]:checked + .neo-content { background: var(--clr-converge); color: #111; box-shadow: var(--shadow-push); transform: translate(2px, 2px); }
.optic-radio-grid input[value="diverging"]:checked + .neo-content { background: var(--clr-diverge); color: #fff; box-shadow: var(--shadow-push); transform: translate(2px, 2px); }

/* Helper Text (Chữ đen đậm) */
.optic-helper-black { font-size: 0.95rem; font-weight: 800; color: #111; background: #e9ecef; padding: 12px 15px; border-radius: 8px; border: 2px dashed #111; line-height: 1.5; }

/* Button */
.optic-neo-btn { padding: 18px; font-size: 1.2rem; font-weight: 900; background: #111; color: #fff; border: var(--border-ink); border-radius: 12px; box-shadow: 5px 5px 0px #444; cursor: pointer; text-transform: uppercase; transition: all 0.1s; margin-top: 5px; letter-spacing: 1px;}
.optic-neo-btn:active { box-shadow: 2px 2px 0px #444; transform: translate(3px, 3px); }

/* Result Layout */
.optic-neo-result { margin-top: 30px; padding-top: 25px; border-top: 4px dashed #111; display: flex; flex-direction: column; gap: 20px;}
.optic-neo-result.active { display: flex !important; animation: opticAnim 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }

.optic-result-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 15px; }
.optic-card { background: #fff; border: var(--border-ink); box-shadow: var(--shadow-solid); border-radius: 12px; padding: 20px 10px; text-align: center; display: flex; flex-direction: column; justify-content: center; align-items: center;}
.optic-card h4 { margin: 0 0 10px 0; font-size: 0.95rem; color: #111; font-weight: 900; text-transform: uppercase;}
.val-text { font-size: 2.2rem; font-weight: 900; color: #111; line-height: 1; margin-bottom: 10px;}
.val-text small { font-size: 1.2rem; font-weight: 900; margin-left: 2px;}

.tag-status { font-size: 0.9rem; font-weight: 800; background: #111; color: #fff; padding: 5px 12px; border-radius: 6px;}
.bg-virtual { background: var(--clr-diverge); color: #fff; }
.bg-real { background: var(--clr-converge); color: #111; }

/* Hướng dẫn giải Step-by-step */
.optic-solution-box { background: #fff; border: var(--border-ink); border-radius: 12px; padding: 20px; box-shadow: var(--shadow-solid);}
.optic-solution-box h3 { margin: 0 0 15px 0; font-size: 1.2rem; font-weight: 900; text-transform: uppercase; border-bottom: 3px solid #111; padding-bottom: 10px;}
.step-box { margin-bottom: 15px; padding-bottom: 15px; border-bottom: 2px dashed #ccc; }
.step-box:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none;}
.step-box strong { font-size: 1.05rem; color: #111; font-weight: 900;}
.step-box p { font-size: 1rem; font-weight: 700; color: #333; margin: 8px 0 0 0; }
.math-line { font-family: monospace, system-ui; font-size: 1.15rem !important; font-weight: 900 !important; color: #d00000 !important; background: #f8f9fa; padding: 8px; border-radius: 6px; border: 1px solid #ccc;}

/* CANVAS ĐỒ THỊ */
.optic-canvas-box { background: #fff; border: var(--border-ink); border-radius: 12px; padding: 20px; box-shadow: var(--shadow-solid); text-align: center;}
.optic-canvas-box h3 { margin: 0 0 15px 0; font-size: 1.2rem; font-weight: 900; text-transform: uppercase;}
#opticCanvas { width: 100%; max-width: 100%; height: auto; border: 2px solid #111; border-radius: 8px; background: #e9ecef;}

.canvas-legend { display: flex; justify-content: center; gap: 20px; margin-top: 15px; }
.lg-item { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 0.95rem; color: #111;}
.lg-color { width: 15px; height: 15px; border: 2px solid #111; border-radius: 3px; }
.bg-obj { background: var(--clr-obj); }
.bg-img { background: var(--clr-img); }
.bg-ray { background: #ffb703; }

@keyframes opticAnim { 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } }

@media (max-width: 700px) {
    .optic-form-grid, .optic-radio-grid { grid-template-columns: 1fr; }
    .optic-result-grid { grid-template-columns: 1fr; }
}
