/* =========================================================
   ĐÈN DẦU — Giao diện dùng chung cho nhap_qn.php / nhap_cn.php
   V1-1023 SỚ
   Chỉ chứa giao diện; không chứa logic đồng bộ dữ liệu.
   ========================================================= */

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    padding: 20px;
    background: #fff8ef;
    color: #333;
    font-family: "Times New Roman", serif;
}

.form-section {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

h1 {
    margin: 0 0 10px;
    color: #7a4b23;
    font-size: 28px;
    line-height: 1.25;
}

.note {
    max-width: 1000px;
    margin: 0 0 18px;
    color: #666;
    font-size: 15px;
    line-height: 1.5;
}

.group {
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: bold;
    color: #7a4b23;
}

input,
textarea,
select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #b9a38d;
    border-radius: 7px;
    background: #fff;
    color: #333;
    font: 18px "Times New Roman", serif;
}

input:focus,
textarea:focus,
select:focus {
    outline: 2px solid rgba(122, 75, 35, .18);
    outline-offset: 1px;
    border-color: #7a4b23;
}

textarea {
    min-height: 70px;
    resize: vertical;
    line-height: 1.45;
}

/* Ngày tháng / các nhóm 3 cột */
.row-date {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 18px;
}

.tin-chu {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 90px 90px;
    gap: 8px;
    margin-bottom: 8px;
}

.tin-chu input[type="number"] {
    width: 100%;
}

.nhom-tin-chu {
    margin-top: 10px;
}

/* Cặp Hán Nôm ↔ Quốc Ngữ */
.book-line {
    width: 100%;
}

.book-line .quoc-input {
    display: none;
}

/* Thanh chuyển chế độ trên trang nhap_cn */
.mode-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 18px;
}

.mode-bar button {
    padding: 8px 14px;
    border: 1px solid #b9a38d;
    border-radius: 7px;
    background: #fff;
    color: #333;
    font: 16px "Times New Roman", serif;
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.mode-bar button:hover {
    border-color: #7a4b23;
}

.mode-bar button.active {
    background: #7a4b23;
    color: #fff;
    border-color: #7a4b23;
}

/* Nút chuyển trang */
.btn-next {
    display: block;
    width: 100%;
    max-width: 1000px;
    margin: 28px auto 0;
    padding: 12px 20px;
    border: 0;
    border-radius: 8px;
    background: #7a4b23;
    color: #fff;
    font: bold 20px "Times New Roman", serif;
    cursor: pointer;
}

.btn-next:hover {
    opacity: .9;
}

.btn-next:focus-visible,
.mode-bar button:focus-visible {
    outline: 2px solid #7a4b23;
    outline-offset: 2px;
}

@media (max-width: 700px) {
    body {
        padding: 12px;
    }

    h1 {
        font-size: 24px;
    }

    /* Giữ các nhóm nhập trên cùng một hàng; kích thước tự co theo bề rộng màn hình. */
    .row-date {
        grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr) minmax(0, 1fr);
        gap: clamp(5px, 2vw, 10px);
    }

    .tin-chu {
        grid-template-columns: minmax(0, 1fr) clamp(56px, 17vw, 90px) clamp(62px, 18vw, 90px);
        gap: clamp(4px, 1.5vw, 8px);
    }

    .mode-bar {
        flex-wrap: wrap;
    }
}


/* =========================================================
   Thanh công cụ chung của module nhập
   Giữ cách hiển thị gần với toolbar cũ:
   - Một hàng ngang
   - 6 nút chia đều chiều rộng
   - Cỡ chữ tự co giãn theo màn hình bằng clamp()
   - Màu sắc / kiểu chữ thống nhất với giao diện Sớ cũ
   ========================================================= */
.nhap-toolbar {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto 8px;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: stretch;
    gap: clamp(2px, 0.35vw, 5px);
    padding: clamp(2px, 0.35vw, 5px);
    border: 1px solid #d2bda7;
    border-radius: clamp(5px, 0.6vw, 10px);
    background: #fff;
}

.nhap-tool {
    display: inline-flex;
    width: 100%;
    min-width: 0;
    min-height: clamp(32px, 3vw, 48px);
    padding: clamp(3px, 0.5vw, 8px) clamp(2px, 0.45vw, 8px);
    align-items: center;
    justify-content: center;
    border: 1px solid #7a4b23;
    border-radius: clamp(4px, 0.6vw, 10px);
    background: #fff8ef;
    color: #7a4b23;
    text-decoration: none;
    font-size: clamp(11px, 1.5vw, 20px);
    font-family: "Times New Roman", serif;
    font-weight: bold;
    line-height: 1.05;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.nhap-tool:hover {
    border-color: #7a4b23;
    background: #7a4b23;
    color: #fff;
}

.nhap-tool[aria-disabled="true"] {
    opacity: .55;
    cursor: default;
}

.nhap-tool[aria-disabled="true"]:hover {
    border-color: #7a4b23;
    background: #fff8ef;
    color: #7a4b23;
}

@media (max-width: 600px) {
    .nhap-toolbar {
        grid-template-columns: repeat(6, minmax(0, 1fr));
        gap: clamp(1px, 0.8vw, 4px);
        padding: clamp(2px, 0.8vw, 4px);
    }

    .nhap-tool {
        min-height: clamp(32px, 7vw, 45px);
        padding: clamp(2px, 0.8vw, 6px) 1px;
        font-size: clamp(9px, 3vw, 17px);
        line-height: 1.0;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .nhap-mode {
        min-height: 36px;
        font-size: 16px;
    }

    /* Các ô nhập dùng kích thước tỷ lệ theo màn hình, không xếp dọc. */
    input,
    textarea,
    select {
        padding: clamp(6px, 1.8vw, 8px) clamp(7px, 2.2vw, 10px);
        font-size: clamp(15px, 4.4vw, 18px);
    }

    .tin-chu input,
    .tin-chu select {
        min-width: 0;
    }
}

/* =========================================================
   Chuyển giữa Phần Quốc Ngữ / Phần Chữ Nho
   ========================================================= */
.nhap-mode-switch {
    width: 100%;
    max-width: 1000px;
    margin: 0 auto 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.nhap-mode {
    display: flex;
    min-height: clamp(32px, 3vw, 46px);
    align-items: center;
    justify-content: center;
    padding: clamp(4px, 0.5vw, 8px) clamp(6px, 0.8vw, 12px);
    border: 1px solid #b9a38d;
    border-radius: clamp(4px, 0.6vw, 8px);
    background: #fff;
    color: #7a4b23;
    font-size: clamp(13px, 1.5vw, 19px);
    font-family: "Times New Roman", serif;
    font-weight: bold;
    line-height: 1.05;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    user-select: none;
}

.nhap-mode.current {
    background: #7a4b23;
    border-color: #7a4b23;
    color: #fff;
    cursor: default;
}

.nhap-mode.other:hover {
    background: #fff8ef;
    border-color: #7a4b23;
}

/* Trên điện thoại: toolbar chạm đủ 100% viewport, không bị giới hạn
   bởi padding của body hay max-width của .form-section. */
@media (max-width: 600px) {
    body {
        padding: 12px;
    }

    .nhap-toolbar {
        width: 100vw;
        max-width: none;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        border-left: 0;
        border-right: 0;
        border-radius: 0;
    }

    .nhap-mode-switch {
        width: 100vw;
        max-width: none;
        margin-left: calc(50% - 50vw);
        margin-right: calc(50% - 50vw);
        padding: 0 4px;
    }

    .nhap-mode {
        min-height: 36px;
        font-size: clamp(13px, 3.5vw, 17px);
    }
}
