/* =============================================
   File: assets/css/theme.css
   Mô tả: Palette + component dùng chung cho TẤT CẢ các giao diện
          (LED, đội thi, thư ký, ban giám khảo, trang chủ)
   Quy chế: Hội thi "Thanh niên Trung đoàn với văn hóa giao thông" 2026
   ============================================= */

@import url('../vendor/fonts.css');

:root {
    /* Blues */
    --blue:         #1E6FE0;
    --blue-deep:    #0B3A91;
    --blue-darkest: #08265F;
    --blue-mid:     #1565C0;
    --blue-strong:  #0D47A1;
    --blue-border:  #6FA8FF;
    --blue-pale:    #B3D4FF;
    --blue-tint:    #DCE9FF;
    --blue-bg:      #f0f4f9;
    --blue-hover:   #e8f0fe;

    /* Gold — màu nhấn chính */
    --gold:         #E6A800;
    --gold-bright:  #FFD700;
    --gold-text:    #FFE14D;
    --gold-dark:    #5A3D00;

    /* Green */
    --green:        #2E7D32;
    --green-light:  #388E3C;
    --green-mint:   #69F0AE;
    --green-pale:   #B9F6CA;
    --green-bg:     #d4edda;
    --green-text:   #0f5132;

    /* Red */
    --red:          #E53935;
    --red-deep:     #C62828;
    --red-bright:   #dc3545;
    --red-dark:     #B71C1C;
    --red-pale:     #FFCDD2;
    --red-bg:       #f8d7da;
    --red-text:     #842029;

    /* Neutral */
    --ink:          #212529;
    --navy:         #0D2A5C;
    --grey-900:     #0B1A3E;
    --grey-800:     #1a2a4a;
    --grey-600:     #5c6b7e;
    --grey-400:     #ced4da;
    --grey-300:     #dee2e6;
    --grey-200:     #e9ecef;
    --grey-100:     #f8f9fa;
    --white:        #ffffff;

    /* Bố cục */
    --radius-card:  14px;
    --radius-btn:   30px;
    --shadow-card:  0 6px 18px rgba(0, 0, 0, .06);
    --shadow-btn:   0 4px 12px rgba(0, 0, 0, .18);

    /* Ghi đè Bootstrap — nút .btn-primary không còn #0d6efd lệch tông */
    --bs-primary:       #1E6FE0;
    --bs-primary-rgb:   30, 111, 224;
    --bs-link-color:    #1E6FE0;
    --bs-link-hover-color: #0B3A91;
}

/* =============================================
   NỀN TẢNG
   ============================================= */

body.theme-app {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    color: var(--grey-800);
    background: var(--blue-bg);
}

/* Màn hình lớn / kiosk: nền xanh gradient như LED */
body.theme-kiosk {
    font-family: 'Montserrat', 'Segoe UI', Arial, sans-serif;
    color: var(--white);
    background: radial-gradient(circle at 50% 0%, var(--blue) 0%, var(--blue-deep) 55%, var(--blue-darkest) 100%);
}

/* Bootstrap primary override — cần thiết vì dùng Bootstrap từ CDN */
.btn-primary {
    --bs-btn-bg: var(--blue);
    --bs-btn-border-color: var(--blue);
    --bs-btn-hover-bg: var(--blue-deep);
    --bs-btn-hover-border-color: var(--blue-deep);
    --bs-btn-active-bg: var(--blue-strong);
    --bs-btn-active-border-color: var(--blue-strong);
}
.bg-primary { background-color: var(--blue) !important; }
.text-primary { color: var(--blue) !important; }
.btn-outline-primary {
    --bs-btn-color: var(--blue);
    --bs-btn-border-color: var(--blue);
    --bs-btn-hover-bg: var(--blue);
    --bs-btn-hover-border-color: var(--blue);
    --bs-btn-active-bg: var(--blue-deep);
}

/* =============================================
   HỆ THỐNG NÚT DÙNG CHUNG
   Mọi nút hành động dùng .btn-ac + 1 biến thể ngữ nghĩa.
   Chống xuống dòng: nowrap + không co lại.
   ============================================= */

.btn-ac {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-btn);
    border: none;
    font-family: inherit;
    font-size: clamp(13px, 1.55vh, 16px);
    font-weight: 700;
    line-height: 1.25;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, filter .15s;
    box-shadow: var(--shadow-btn);
    text-decoration: none;
    /* Ưu tiên giữ nhãn trên 1 dòng, nhưng nếu chật thì xuống dòng
       bên trong nút thay vì tràn ra ngoài và bị cắt */
    white-space: normal;
    text-align: center;
    flex-shrink: 0;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
}
.btn-ac:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.06);
}
.btn-ac:active:not(:disabled) { transform: translateY(1px); }
.btn-ac:disabled,
.btn-ac.disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none !important;
    filter: grayscale(.35);
    box-shadow: none;
}

/* Hành động chính — LƯU / CHỐT / XÁC NHẬN (thống nhất 1 màu vàng) */
.btn-save {
    background: linear-gradient(135deg, var(--gold-bright), var(--gold));
    color: var(--grey-900);
    border: 1px solid var(--gold);
}
/* Bắt đầu / chuyển bước thuận */
.btn-go {
    background: linear-gradient(135deg, var(--green-light), var(--green));
    color: var(--white);
}
/* Bước thông tin / hiện nội dung */
.btn-info {
    background: linear-gradient(135deg, var(--blue), var(--blue-mid));
    color: var(--white);
}
/* Dừng / nguy hiểm / reset */
.btn-stop {
    background: linear-gradient(135deg, var(--red), var(--red-deep));
    color: var(--white);
}
/* Trung tính / phụ */
.btn-neutral {
    background: var(--white);
    color: var(--grey-800);
    border: 2px solid var(--grey-400);
    box-shadow: none;
}
.btn-neutral:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
/* Tối / nhấn mạnh */
.btn-dark-ac {
    background: var(--ink);
    color: var(--gold-text);
}

/* Cỡ nhỏ — dùng trong header card */
.btn-ac.btn-xs {
    padding: 5px 13px;
    font-size: clamp(11px, 1.3vh, 13px);
    box-shadow: none;
}

/* Hàng nút: tự xuống dòng theo NHÓM, mỗi nút không bị bẻ chữ */
.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* =============================================
   CARD
   ============================================= */

.card-k {
    background: var(--white);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    margin-bottom: 16px;
}
.card-k > .chd {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, var(--blue), var(--blue-deep));
    color: var(--white);
    font-size: clamp(13px, 1.6vh, 16px);
    font-weight: 800;
    letter-spacing: .3px;
}
.card-k > .chd.ch-green  { background: linear-gradient(135deg, var(--green), var(--green-light)); }
.card-k > .chd.ch-gold   { background: linear-gradient(135deg, var(--gold-bright), var(--gold)); color: var(--grey-900); }
.card-k > .chd.ch-red    { background: linear-gradient(135deg, var(--red-dark), var(--red-deep)); }
.card-k > .chd.ch-grey   { background: linear-gradient(135deg, #546E7A, #37474F); }
.card-k > .chd.ch-dark   { background: linear-gradient(135deg, var(--ink), #000); }
/* Đẩy nhóm phần tử về cuối header mà không dùng float */
.card-k > .chd .chd-end { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.card-k > .cbd { padding: 14px 16px; }

/* Card rỗng / thông báo */
.empty-note {
    color: var(--grey-600);
    font-style: italic;
    font-size: .92em;
    padding: 8px 0;
}

/* =============================================
   ĐỒNG HỒ
   ============================================= */

.timer-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 84px;
    padding: 4px 14px;
    border-radius: 10px;
    background: var(--red);
    color: var(--white);
    font-size: clamp(18px, 2.6vh, 30px);
    font-weight: 900;
    font-variant-numeric: tabular-nums;
    letter-spacing: 1px;
    flex-shrink: 0;
}
.timer-box.timer-grey { background: #607D8B; }
.timer-box.timer-ok   { background: var(--green); }
.timer-box.warn { background: #F9A825; color: var(--grey-900); }
.timer-box.over { background: var(--red-dark); }

/* =============================================
   NHÃN / CHIP TRẠNG THÁI
   ============================================= */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 13px;
    border-radius: 20px;
    font-size: clamp(11px, 1.4vh, 14px);
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.chip-online  { background: var(--green-bg); color: var(--green-text); }
.chip-offline { background: var(--red-bg);   color: var(--red-text); }
.chip-info    { background: var(--blue-hover); color: var(--blue-deep); }
.chip-warn    { background: #fff3cd; color: #664d03; }

/* =============================================
   NÚT CHỌN ĐÁP ÁN (dùng cho đội thi + LED)
   ============================================= */

.opt-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 18px;
    border-radius: 14px;
    border: 3px solid var(--grey-400);
    background: var(--grey-100);
    color: var(--grey-800);
    font-family: inherit;
    font-size: clamp(14px, 2vh, 20px);
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, border-color .15s, background .15s;
    min-height: 60px;
    position: relative;
}
.opt-btn .label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--blue);
    color: var(--white);
    font-weight: 900;
    flex-shrink: 0;
}
.opt-btn .text {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    line-height: 1.35;
}
.opt-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    border-color: var(--blue);
    box-shadow: 0 8px 18px rgba(30, 111, 224, .22);
}
.opt-btn:disabled { opacity: .55; cursor: not-allowed; }
.opt-btn.is-selected {
    border-color: var(--green);
    background: #d1e7dd;
    box-shadow: 0 0 20px rgba(46, 125, 50, .45);
}
.opt-btn.is-correct {
    border-color: var(--green-mint);
    background: linear-gradient(135deg, #FFEC8B, var(--gold-bright));
    color: var(--gold-dark);
    animation: blinkCorrect 0.8s ease-in-out infinite alternate;
}
.opt-btn.is-correct .label { background: var(--green); }
.opt-btn.is-dimmed { opacity: .35; filter: grayscale(.5); }
.opt-btn.is-wrong {
    border-color: var(--red-pale);
    background: #f8d7da;
    color: var(--red-text);
}
.opt-btn.is-wrong .label { background: var(--red); }

@keyframes blinkCorrect {
    from { box-shadow: 0 0 6px rgba(255, 225, 77, .5); }
    to   { box-shadow: 0 0 30px 6px rgba(105, 240, 174, .95); }
}

/* Lưới đáp án — minmax(0,1fr) để chuỗi dài không phá cột */
.opt-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
@media (max-width: 640px) {
    .opt-grid { grid-template-columns: minmax(0, 1fr); }
}

/* =============================================
   TAB / ĐIỀU HƯỚNG
   ============================================= */

.nav-pills { gap: 8px; margin: 8px 0; }
.nav-pills .nav-link {
    border-radius: var(--radius-btn);
    padding: 9px 18px;
    color: var(--grey-800);
    background: var(--white);
    font-weight: 700;
    font-size: clamp(12px, 1.5vh, 15px);
    border: 2px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.nav-pills .nav-link:hover:not(.active) { background: var(--blue-hover); color: var(--blue-deep); }
.nav-pills .nav-link.active { background: var(--blue); color: var(--white); box-shadow: var(--shadow-btn); }
.nav-pills .nav-link.sub-pill { font-size: clamp(11px, 1.3vh, 14px); padding: 6px 14px; }

/* Thanh trên cùng */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 20px;
    background: linear-gradient(135deg, var(--blue), var(--blue-darkest));
    color: var(--white);
    flex-shrink: 0;
}
.topbar h3 {
    margin: 0;
    font-size: clamp(15px, 2.1vh, 22px);
    font-weight: 900;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}
.topbar .logout {
    color: var(--white);
    text-decoration: none;
    font-weight: 700;
    font-size: clamp(12px, 1.5vh, 15px);
    padding: 6px 15px;
    border: 2px solid rgba(255, 255, 255, .55);
    border-radius: var(--radius-btn);
    white-space: nowrap;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.topbar .logout:hover { background: rgba(255, 255, 255, .16); }

/* =============================================
   Ô NHẬP ĐIỂM
   ============================================= */

.score-inp {
    text-align: center;
    font-weight: 800;
    font-size: clamp(14px, 1.8vh, 18px);
    font-variant-numeric: tabular-nums;
    padding: 6px 4px;
}
/* Lưới ô nhập điểm — số cột khai báo qua biến, không dùng min-width cứng */
.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 8px;
}
.score-cell { display: flex; flex-direction: column; gap: 3px; }
.score-cell > label {
    font-size: clamp(10px, 1.25vh, 12px);
    font-weight: 700;
    color: var(--grey-600);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.score-cell .max-note { font-weight: 600; color: var(--blue); }

/* =============================================
   BẢNG
   ============================================= */

.tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(12px, 1.5vh, 15px);
}
.tbl th {
    background: var(--grey-100);
    color: var(--grey-800);
    font-weight: 800;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 2px solid var(--grey-300);
    white-space: nowrap;
}
.tbl td {
    padding: 7px 10px;
    border-bottom: 1px solid var(--grey-200);
    vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--blue-hover); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.tbl .total { color: var(--green); font-weight: 900; }

/* Bảng xếp hạng */
.rank-1 { background: linear-gradient(90deg, rgba(255, 215, 0, .22), transparent); }
.rank-1 td:first-child { font-weight: 900; color: var(--gold); }

/* =============================================
   CẢNH BÁO
   ============================================= */

.alert-ac {
    display: block;
    padding: 11px 15px;
    border-radius: 10px;
    border-left: 5px solid var(--blue);
    background: var(--blue-hover);
    color: var(--grey-800);
    font-size: clamp(12px, 1.5vh, 15px);
    font-weight: 600;
    line-height: 1.55;
    margin-bottom: 12px;
}
/* Khi có icon/nút đi kèm thì mới dùng flex */
.alert-ac.with-icon {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-ac > b { font-weight: 800; }
.alert-ac.alert-warn { border-left-color: var(--gold); background: #fff8e1; }
.alert-ac.alert-ok   { border-left-color: var(--green); background: var(--green-bg); }
.alert-ac.alert-bad  { border-left-color: var(--red); background: var(--red-bg); }

/* Bảng điều khiển BGK: banner đề xuất điểm trừ chờ xác nhận */
.vote-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 10px;
    background: #fff8e1;
    border-left: 5px solid var(--gold);
    margin-bottom: 12px;
}
.vote-banner .vb-text { flex: 1 1 240px; min-width: 0; font-weight: 700; }
.vote-banner .vb-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* =============================================
   TIỆN ÍCH
   ============================================= */

.nowrap { white-space: nowrap; }
.min0 { min-width: 0; }
.row-flex { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.spacer { flex: 1; }

/* Thanh cuộn mảnh cho vùng nội dung */
.scroll-y { overflow-y: auto; overflow-x: hidden; }
.scroll-y::-webkit-scrollbar { width: 8px; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--grey-400); border-radius: 4px; }
