/**
 * portal.css — Student Portal Specific Styles
 * Extends shared/css/base.css
 */

/* CONTAINER */
.container { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 0.75rem; }
.container-full { max-width: 100%; padding: 0.75rem; }

/* HEADER */
header {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    padding: calc(0.6rem + var(--safe-top)) 1rem 0.6rem;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 100;
}
.header-brand {
    font-size: 1rem; font-weight: 700; display: flex; align-items: center;
    gap: 0.5rem; text-decoration: none;
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.header-brand svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--primary); }

/* GRIDS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
@media (max-width: 600px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-4 { grid-template-columns: 1fr 1fr; }
}

/* STAT CARDS */
.stat-card { background: #ffffff; border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.75rem; text-align: center; box-shadow: var(--glass); }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); display: block; margin: 0.15rem 0 0; }
.stat-label { font-size: 0.72rem; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }

/* MATRIX TABLE */
.matrix-table th { text-align: center; min-width: 78px; }
.matrix-table td { text-align: center; }
.matrix-table td.text-left { text-align: left; }
.tick-present { color: var(--success); font-size: 1.05rem; font-weight: 700; }
.tick-claimed { color: var(--accent); }
.tick-makeup { color: var(--makeup); }
.tick-makeup-warning { color: var(--warning); font-size: 1.05rem; font-weight: 700; }
.tick-pending { color: var(--warning); }
.tick-absent { color: rgba(220,38,38,0.2); font-size: 1.05rem; }
.tick-label { font-size: 0.67rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 80px; margin: 1px auto 0; color: var(--muted); }
.matrix-table th.sortable { cursor: pointer; user-select: none; }
.matrix-table th.sortable:hover { background: #e2e8f0 !important; }

/* VARIANT CHIPS */
.variant-chip { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.25rem 0.5rem; border-radius: 0.375rem; font-size: 0.78rem; font-weight: 500; cursor: default; border: 1px solid var(--border); background: #ffffff; color: var(--muted); }
.variant-chip.custom { background: #f0f9ff; border-color: #bae6fd; color: var(--accent); }
.variant-chip .del { cursor: pointer; opacity: 0.6; font-weight: 700; padding: 0 0.1rem; transition: opacity 0.15s; }
.variant-chip .del:hover { opacity: 1; color: var(--danger); }

/* HOME PAGE CARDS */
.home-option-card { background: #ffffff; border: 1px solid var(--border); border-radius: 0.5rem; padding: 1rem; box-shadow: var(--glass); }
.home-option-card h3 { font-size: 0.95rem; font-weight: 600; color: var(--text); margin-bottom: 0.5rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--border); }

/* LINK STUDENT */
.link-student { color: var(--primary); text-decoration: none; font-weight: 500; }
.link-student:hover { text-decoration: underline; color: var(--primary-hover); }

/* CLAIM PANEL */
.claim-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-top: 4px solid var(--primary);
    border-radius: 0.75rem;
    padding: 1.25rem;
    box-shadow: var(--glass);
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

/* SEGMENTED CONTROL */
.segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: 0.5rem;
    max-width: 320px;
    border: 1px solid var(--border);
}
.segment-btn {
    flex: 1;
    border: none;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}
.segment-btn.active {
    background: #ffffff;
    color: var(--text);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* CLAIM BUTTON */
.btn-claim {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
    box-shadow: 0 1px 2px rgba(37, 99, 235, 0.05);
    min-height: 32px;
}
.btn-claim:hover {
    background: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.1), 0 2px 4px -1px rgba(37, 99, 235, 0.06);
}
.btn-claim:active {
    transform: translateY(0);
}

/* UNMATCHED NAMES & STATUSES */
.unmatched-teams-name {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    background: #f8fafc;
    color: var(--text);
    padding: 0.35rem 0.6rem;
    border-radius: 0.375rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    display: inline-block;
    word-break: break-all;
    max-width: 100%;
}
.claim-status-pending {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
    font-size: 0.82rem;
    font-weight: 600;
}
.claim-others-warning {
    margin-top: 0.4rem;
    font-size: 0.75rem;
    color: #b45309;
    background: #fffbeb;
    border: 1px solid #fde68a;
    padding: 0.35rem 0.5rem;
    border-radius: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    line-height: 1.3;
}

/* MAKEUP INDICATOR in log */
.log-makeup-row { background: #f5f3ff !important; }

/* Mobile / Desktop matrix view */
@media (max-width: 640px) {
    .matrix-desktop { display: none; }
    .matrix-mobile { display: block; }
}
@media (min-width: 641px) {
    .matrix-desktop { display: block; }
    .matrix-mobile { display: none; }
}

/* STUDENT CARDS (mobile list) */
.student-card { background: #ffffff; border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.65rem 0.85rem; display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.35rem; text-decoration: none; color: inherit; transition: background 0.15s, border-color 0.15s; box-shadow: var(--glass); }
.student-card:hover { background: #eff6ff; border-color: #bfdbfe; }
.student-card-info { flex: 1; min-width: 0; }
.student-card-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }
.student-card-meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }
.student-card-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 0.2rem; flex-shrink: 0; }
.student-card-rate { font-size: 1rem; font-weight: 700; color: var(--text); }

/* ======================================
   COURSE DASHBOARD
   ====================================== */
.course-class-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}
.course-class-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    box-shadow: var(--glass);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 1.25rem;
    position: relative;
}
.course-class-card:hover {
    border-color: var(--primary);
    box-shadow: 0 10px 25px -5px rgba(37, 99, 235, 0.15), 0 8px 10px -6px rgba(37, 99, 235, 0.05);
    transform: translateY(-2px);
}
.course-class-icon-wrapper {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}
.course-class-card:hover .course-class-icon-wrapper {
    transform: scale(1.08);
}
.course-class-icon-wrapper svg {
    width: 26px;
    height: 26px;
}
.course-class-card-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
    line-height: 1.4;
}
.course-class-card-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin: -0.5rem 0 0;
}
.course-class-card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    width: 100%;
}
.class-card-btn-row {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}
.class-card-btn {
    flex: 1;
    min-width: 0;
    min-height: 38px;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    cursor: pointer;
    border: none;
    white-space: nowrap;
}
.class-card-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}
.btn-diemdanh {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.15);
}
.btn-diemdanh:hover {
    background: var(--primary-hover);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px -2px rgba(37, 99, 235, 0.25);
}
.btn-online {
    background: var(--teams-blue);
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(70, 80, 182, 0.15);
}
.btn-online:hover {
    background: var(--teams-blue-hover);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px -2px rgba(70, 80, 182, 0.25);
}
.btn-schedule {
    background: var(--sky-blue);
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(14, 165, 233, 0.15);
}
.btn-schedule:hover {
    background: var(--sky-blue-hover);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 6px 12px -2px rgba(14, 165, 233, 0.25);
}

@media (max-width: 480px) {
    .class-card-btn-row {
        flex-direction: column;
        gap: 0.4rem;
    }
    .class-card-btn {
        width: 100%;
        min-height: 36px;
    }
}

/* ======================================
   CLASS LANDING
   ====================================== */
.class-landing-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.class-action-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 0.625rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: #fff;
}
.class-action-card:hover {
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.class-action-learn { border-left: 4px solid var(--primary); }
.class-action-learn:hover { background: #eff6ff; border-color: #bfdbfe; border-left-color: var(--primary); }
.class-action-attendance { border-left: 4px solid var(--success); }
.class-action-attendance:hover { background: #ecfdf5; border-color: #a7f3d0; border-left-color: var(--success); }
.class-action-icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.class-action-learn .class-action-icon { background: #eff6ff; color: var(--primary); }
.class-action-attendance .class-action-icon { background: #ecfdf5; color: var(--success); }
.class-action-schedule .class-action-icon { background: #fffbeb; color: var(--warning); }
.class-action-icon svg { width: 20px; height: 20px; }
.class-action-text { flex: 1; }
.class-action-text h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.15rem; }
.class-action-text p { font-size: 0.8rem; color: var(--muted); }
.class-action-arrow { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; transition: transform 0.2s; }
.class-action-card:hover .class-action-arrow { transform: translateX(3px); color: var(--text); }
.class-action-schedule { border-left: 4px solid var(--warning); }
.class-action-schedule:hover { background: #fffbeb; border-color: #fde68a; border-left-color: var(--warning); }

/* ======================================
   LOGIN
   ====================================== */
.login-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem 0;
}
.login-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 4px 16px rgba(15,23,42,0.06);
}
.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.login-icon {
    width: 56px; height: 56px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    color: #fff;
}
.login-icon svg { width: 26px; height: 26px; }
.login-header h1 { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 0.3rem; }
.login-header p { font-size: 0.85rem; color: var(--muted); }
.login-form { margin-bottom: 1rem; }
.input-with-icon {
    position: relative;
}
.input-with-icon svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 16px; height: 16px;
    color: var(--muted);
    pointer-events: none;
}
.input-with-icon .form-control { padding-left: 2.5rem; }
.login-hint {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 0.375rem;
    font-size: 0.78rem;
    color: #0369a1;
    line-height: 1.4;
}
.btn-lg { padding: 0.65rem 1.25rem; font-size: 0.95rem; min-height: 44px; }

/* ======================================
   PROFILE
   ====================================== */
.profile-info-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: linear-gradient(135deg, #eff6ff, #f0f9ff);
    border: 1px solid #bfdbfe;
    border-radius: 0.625rem;
}
.profile-avatar {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.profile-avatar svg { width: 26px; height: 26px; }
.profile-details h2 { font-size: 1.05rem; font-weight: 700; color: var(--text); margin-bottom: 0.15rem; }
.profile-details p { font-size: 0.85rem; color: var(--text); margin-bottom: 0.1rem; }

.profile-classes-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.profile-class-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: border-color 0.15s;
}
.profile-class-item:hover { border-color: #93c5fd; }
.profile-class-info { flex: 1; min-width: 0; }
.profile-class-info h4 { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.profile-class-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}
.profile-class-rate { font-size: 1.2rem; font-weight: 700; }

/* Warning button */
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
    .course-class-grid { grid-template-columns: 1fr; }
    .profile-class-item { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .profile-class-stats { width: 100%; justify-content: space-between; }
    .login-card { padding: 1.25rem; }
}
