/* =============================================
   Certificate System  —  Main Stylesheet
   C:\xampp\htdocs\cavalrycenter\View\Certificate\assets\css\style.css
   ============================================= */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ---------- Tokens ---------- */
:root {
    --navy:      #1e3a5f;
    --navy-dark: #152b47;
    --gold:      #c9a227;
    --gold-light:#f5e9c4;
    --green:     #0e9f6e;
    --red:       #dc2626;
    --gray-50:   #f9fafb;
    --gray-100:  #f3f4f6;
    --gray-200:  #e5e7eb;
    --gray-400:  #9ca3af;
    --gray-600:  #4b5563;
    --gray-800:  #1f2937;
    --white:     #ffffff;
    --radius:    12px;
    --shadow:    0 2px 12px rgba(0,0,0,.08);
    --shadow-md: 0 6px 24px rgba(0,0,0,.12);
}

body {
    font-family: 'Sarabun','Prompt','Kanit',system-ui,sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    font-size: 15px;
    line-height: 1.6;
    min-height: 100vh;
}

/* =============================================
   LOGIN PAGE
   ============================================= */
body.login-page {
    background: linear-gradient(145deg, var(--navy-dark) 0%, #2d6a9f 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-wrap {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 44px 40px 36px;
    box-shadow: 0 24px 64px rgba(0,0,0,.3);
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}
.login-emblem {
    font-size: 56px;
    line-height: 1;
    margin-bottom: 14px;
}
.login-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 6px;
}
.login-header p {
    font-size: 13px;
    color: var(--gray-600);
}

/* Alerts */
.alert {
    padding: 11px 15px;
    border-radius: 8px;
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 18px;
}
.alert-danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Form */
.field {
    margin-bottom: 22px;
}
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 7px;
}
.input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    font-size: 17px;
    letter-spacing: 2px;
    font-family: inherit;
    transition: border-color .2s;
    outline: none;
}
.input:focus   { border-color: var(--navy); }
.input-error   { border-color: var(--red); }
.field-hint {
    display: block;
    font-size: 11.5px;
    color: var(--gray-400);
    margin-top: 5px;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: var(--navy);
    color: var(--white);
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: background .2s;
}
.btn-login:hover { background: var(--navy-dark); }

.login-note {
    text-align: center;
    font-size: 12.5px;
    color: var(--gray-400);
    margin-top: 20px;
}

/* =============================================
   NAVBAR
   ============================================= */
.navbar {
    position: sticky;
    top: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 28px;
    height: 62px;
    background: var(--navy);
    box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.navbar-brand {
    font-size: 17px;
    font-weight: 700;
    color: var(--white);
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---- ข้อมูลผู้ใช้ด้านบนขวา ---- */
.navbar-user {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 50px;
    padding: 6px 16px 6px 10px;
    min-width: 0;
}

.user-avatar {
    font-size: 22px;
    flex-shrink: 0;
}

.user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}

.user-rank {
    font-size: 11px;
    color: var(--gold-light);
    font-weight: 600;
    letter-spacing: .5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-name {
    font-size: 14px;
    color: var(--white);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn-logout {
    flex-shrink: 0;
    padding: 7px 16px;
    border: 1.5px solid rgba(255,255,255,.4);
    border-radius: 8px;
    color: var(--white);
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.btn-logout:hover {
    background: rgba(255,255,255,.12);
    border-color: rgba(255,255,255,.7);
}

/* =============================================
   MAIN / CONTAINER
   ============================================= */
.page {
    padding: 32px 20px 48px;
    min-height: calc(100vh - 62px);
}
.container {
    max-width: 1080px;
    margin: 0 auto;
}

.page-header {
    margin-bottom: 24px;
}
.page-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--navy);
}
.page-header .sub {
    font-size: 13px;
    color: var(--gray-400);
    margin-top: 3px;
}

/* Section label (หมดอายุ) */
.section-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-600);
    margin: 32px 0 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-200);
}
.expired-label { color: var(--red); border-color: #fecaca; }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-box {
    text-align: center;
    padding: 80px 24px;
    color: var(--gray-600);
}
.empty-icon { font-size: 64px; margin-bottom: 16px; }
.empty-box h3 { font-size: 20px; color: var(--gray-800); margin-bottom: 8px; }
.empty-box p  { font-size: 14px; line-height: 1.8; }

/* =============================================
   CERTIFICATE GRID
   ============================================= */
.cert-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 18px;
}

/* =============================================
   CERTIFICATE CARD
   ============================================= */
.cert-card {
    background: var(--white);
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform .2s, box-shadow .2s;
}
.cert-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}
.cert-card.card-expired {
    opacity: .72;
    filter: grayscale(.3);
}

/* Card Head */
.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px 14px;
    background: linear-gradient(135deg, var(--navy) 0%, #2d6a9f 100%);
    color: var(--white);
}
.card-head-left {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.card-quiz {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--white);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.card-round {
    font-size: 12px;
    color: rgba(255,255,255,.72);
}

/* Score badge */
.score-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,.15);
    flex-shrink: 0;
    min-width: 68px;
    text-align: center;
}
.score-badge.pass { background: #d1fae5; color: #065f46; }
.score-badge.fail { background: #fee2e2; color: #991b1b; }
.score-num    { font-size: 19px; font-weight: 800; line-height: 1.1; }
.score-label  { font-size: 10px; opacity: .75; }
.score-status { font-size: 11px; font-weight: 600; margin-top: 2px; }

/* Card Body */
.card-body { padding: 16px 18px; flex: 1; }

.card-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy);
    margin-bottom: 10px;
}

.card-meta {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    color: var(--gray-600);
}
.meta-expired { color: var(--red);   font-weight: 600; }
.meta-valid   { color: var(--green); }

/* Card Foot */
.card-foot {
    padding: 12px 18px 16px;
    border-top: 1px solid var(--gray-100);
    background: var(--gray-50);
}

.btn-cert {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 18px;
    background: var(--navy);
    color: var(--white);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: background .15s;
    border: none;
    cursor: pointer;
}
.btn-cert:hover { background: var(--navy-dark); }
.btn-cert.btn-no-token {
    background: var(--gray-200);
    color: var(--gray-400);
    cursor: default;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 600px) {
    .navbar        { padding: 0 16px; height: 56px; }
    .navbar-brand  { font-size: 14px; }
    .user-info     { padding: 5px 10px 5px 8px; }
    .user-rank     { display: none; }
    .user-name     { font-size: 13px; }
    .btn-logout    { font-size: 12px; padding: 6px 10px; }

    .login-card    { padding: 32px 24px 28px; }
    .cert-grid     { grid-template-columns: 1fr; }
    .page          { padding: 20px 12px 40px; }
}
