/* ============================================================
   LXNotes — CGPA Calculator Styles
   Uses CSS variables from main.css for consistent branding
   ============================================================ */

/* ── Hero ────────────────────────────────────────────────────── */
.cgpa-hero {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: #fff;
    padding: 3rem 0 2rem;
}

.cgpa-hero h1 { font-weight: 700; font-size: 2rem; }
.cgpa-hero p  { opacity: .88; font-size: 1rem; }

/* ── Tabs ─────────────────────────────────────────────────────── */
.cgpa-tabs {
    border-bottom: 2px solid var(--border-color);
    gap: .25rem;
}

.cgpa-tabs .nav-link {
    color: var(--text-muted);
    font-weight: 600;
    font-size: .9rem;
    border: 1px solid transparent;
    border-radius: 8px 8px 0 0;
    padding: .6rem 1.1rem;
    position: relative;
    transition: color .15s, background .15s;
}

.cgpa-tabs .nav-link:hover {
    color: var(--primary-color);
    background: rgba(12, 157, 191, .06);
}

.cgpa-tabs .nav-link.active {
    color: var(--primary-color);
    background: var(--bg-card);
    border-color: var(--border-color) var(--border-color) var(--bg-card);
    border-bottom-color: var(--bg-card);
}


/* ── Calculator Card ─────────────────────────────────────────── */
.cgpa-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: var(--shadow-soft);
    margin-bottom: 1.5rem;
}

.cgpa-card-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
    margin-bottom: 1.25rem;
    padding-bottom: .75rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.cgpa-card-title i { color: var(--primary-color); }

/* ── Dropdowns ───────────────────────────────────────────────── */
.cgpa-select-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .35rem;
}

/* ── Subject Table ───────────────────────────────────────────── */
.cgpa-subject-table { width: 100%; border-collapse: collapse; }

.cgpa-subject-table th {
    font-size: .78rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: .04em;
    padding: .6rem .75rem; border-bottom: 2px solid var(--border-color);
    background: var(--bg-light, #f8f9fa);
}

.cgpa-subject-table td {
    padding: .7rem .75rem; border-bottom: 1px solid var(--border-color);
    vertical-align: middle; font-size: .93rem; color: var(--text-main);
}

.cgpa-subject-table tr:last-child td { border-bottom: none; }
.cgpa-subject-table tr:hover td { background: rgba(12, 157, 191, .03); }

.cgpa-course-code { font-size: .78rem; color: var(--text-muted); display: block; }
.cgpa-subject-name { font-weight: 500; }

.cgpa-grade-select {
    min-width: 90px; font-size: .88rem; padding: .3rem .5rem;
    border: 1px solid var(--border-color); border-radius: 6px;
    background: var(--bg-card); color: var(--text-main);
    cursor: pointer; transition: border-color .15s;
}

.cgpa-grade-select:focus {
    border-color: var(--primary-color); outline: none;
    box-shadow: 0 0 0 3px rgba(12, 157, 191, .12);
}

.cgpa-gp-cell {
    font-weight: 600;
    color: var(--primary-color);
    font-size: .9rem;
    transition: color .15s;
}


/* ── Optional Subjects Section ───────────────────────────────── */
.cgpa-optional-header {
    background: rgba(255, 193, 7, .08);
    border: 1px solid rgba(255, 193, 7, .3);
    border-radius: 8px; padding: .5rem .9rem;
    font-size: .83rem; font-weight: 600; color: #856404;
    margin: .75rem 0 0; display: flex; align-items: center; gap: .4rem;
}

/* ── Calculate Button ────────────────────────────────────────── */
.btn-calculate {
    background: var(--primary-color); color: #fff; border: none;
    border-radius: 8px; padding: .75rem 2rem;
    font-size: 1rem; font-weight: 600; width: 100%;
    transition: background .2s, transform .1s; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
}

.btn-calculate:hover:not(:disabled) { background: var(--primary-hover); transform: translateY(-1px); }
.btn-calculate:disabled { opacity: .65; cursor: not-allowed; }

/* ── Grading Scale Table ─────────────────────────────────────── */
.grading-table { width: 100%; border-collapse: collapse; font-size: .9rem; }

.grading-table th {
    background: var(--bg-light, #f8f9fa); font-size: .78rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
    padding: .55rem .75rem; border-bottom: 2px solid var(--border-color);
}

.grading-table td { padding: .55rem .75rem; border-bottom: 1px solid var(--border-color); color: var(--text-main); }
.grading-table tr:last-child td { border-bottom: none; }

.grade-badge {
    display: inline-block; padding: .15rem .45rem; border-radius: 4px;
    font-weight: 700; font-size: .82rem;
    background: rgba(12, 157, 191, .1); color: var(--primary-color);
    min-width: 36px; text-align: center;
}

/* ── Result Modal ────────────────────────────────────────────── */
#resultModal .modal-dialog {
    width: auto;
    max-width: 95vw;
    min-width: min(680px, 95vw);
}

#resultModal .modal-content {
    width: fit-content;
    max-width: 95vw;
    margin: 0 auto;
}

.cgpa-result-header {
    background: linear-gradient(135deg, var(--secondary-color) 0%, var(--primary-color) 100%);
    color: #fff; padding: 1rem 1.5rem; border-radius: 8px 8px 0 0; text-align: center;
}

.cgpa-result-score  { font-size: 3rem; font-weight: 800; line-height: 1; color: #fff; }
.cgpa-result-label  { font-size: .9rem; opacity: .85; margin-top: .25rem; }
.cgpa-result-message { font-size: .95rem; font-weight: 600; margin-top: .5rem; opacity: .95; }

.cgpa-breakdown-table { width: 100%; border-collapse: collapse; font-size: .84rem; table-layout: fixed; }

.cgpa-breakdown-table th {
    background: var(--bg-light, #f8f9fa); font-size: .72rem; font-weight: 600;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: .03em;
    padding: .45rem .5rem; border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

/* Fixed column widths so table fits in col-md-8 */
.cgpa-breakdown-table col:nth-child(1),
.cgpa-breakdown-table th:nth-child(1) { width: 38%; }
.cgpa-breakdown-table th:nth-child(2) { width: 14%; }
.cgpa-breakdown-table th:nth-child(3) { width: 12%; }
.cgpa-breakdown-table th:nth-child(4) { width: 14%; }
.cgpa-breakdown-table th:nth-child(5) { width: 22%; }

.cgpa-breakdown-table td { padding: .45rem .5rem; border-bottom: 1px solid var(--border-color); color: var(--text-main); vertical-align: middle; }
.cgpa-breakdown-table td:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cgpa-breakdown-table tr:last-child td { border-bottom: none; }

.cgpa-optional-tag {
    font-size: .7rem; background: rgba(255, 193, 7, .15); color: #856404;
    border-radius: 3px; padding: .05rem .3rem; margin-left: .3rem; font-weight: 600;
}

.cgpa-result-footer {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: .75rem; padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-light, #f8f9fa); border-radius: 0 0 8px 8px;
}

.cgpa-result-date { font-size: .8rem; color: var(--text-muted); }

/* ── Download Button ─────────────────────────────────────────── */
.btn-download-result {
    background: #1a7f38; color: #fff; border: none; border-radius: 6px;
    padding: .45rem 1.1rem; font-size: .88rem; font-weight: 600;
    cursor: pointer; transition: background .2s;
    display: inline-flex; align-items: center; gap: .4rem;
}
.btn-download-result:hover { background: #156630; color: #fff; }

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

/* ── Empty State ─────────────────────────────────────────────── */
.cgpa-empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.cgpa-empty-state i { font-size: 2.5rem; margin-bottom: .75rem; display: block; opacity: .4; }

/* ── Cumulative CGPA Tab ─────────────────────────────────────── */
.cgpa-cumul-row { margin-bottom: .75rem; }

.cgpa-cumul-row-inner {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: 1rem; background: var(--bg-light, #f8f9fa);
    border: 1px solid var(--border-color); border-radius: 10px;
}

.cgpa-cumul-result {
    text-align: center; margin-top: 1.5rem;
    padding: 1.5rem; background: rgba(12, 157, 191, .06);
    border: 2px solid var(--primary-color); border-radius: 12px;
    animation: fadeIn .3s ease;
}

.cgpa-cumul-score { font-size: 3rem; font-weight: 800; color: var(--primary-color); line-height: 1; }

/* ── Target CGPA Tab ─────────────────────────────────────────── */
.cgpa-target-result-box {
    padding: 1.25rem; border-radius: 10px;
    background: rgba(12, 157, 191, .05);
    border: 1px solid rgba(12, 157, 191, .3);
    animation: fadeIn .3s ease;
}

.cgpa-target-stat  { font-size: 1.6rem; font-weight: 800; color: var(--primary-color); }
.cgpa-target-label { font-size: .75rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }


/* ── Fade animation ──────────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 767px) {
    .cgpa-hero h1      { font-size: 1.5rem; }
    .cgpa-card         { padding: 1.25rem; }
    .cgpa-result-score { font-size: 2.2rem; }
    .cgpa-cumul-score  { font-size: 2.2rem; }
    .cgpa-tabs .nav-link { font-size: .8rem; padding: .5rem .7rem; }

    .cgpa-cumul-row-inner { flex-wrap: wrap; }
    .cgpa-cumul-row-inner > div { width: calc(50% - .4rem); }

    .cgpa-subject-table thead { display: none; }
    .cgpa-subject-table tr    { display: block; padding: .6rem 0; border-bottom: 1px solid var(--border-color); }
    .cgpa-subject-table td    { display: flex; justify-content: space-between; align-items: center; padding: .3rem .5rem; border: none; font-size: .88rem; }
    .cgpa-subject-table td::before {
        content: attr(data-label);
        font-weight: 600; font-size: .78rem; color: var(--text-muted); flex-shrink: 0;
    }

    .cgpa-result-footer { flex-direction: column; align-items: stretch; }
    .cgpa-result-footer .d-flex { justify-content: center !important; }
}

/* ── Print Styles ────────────────────────────────────────────── */
@media print {
    /* Hide everything except the result card */
    nav, header, footer, .cgpa-hero,
    .cgpa-tabs, #cgpa-app > *:not(.modal),
    .btn-download-result, #btnPrint, #btnShareWhatsApp,
    #btnShareFacebook, #btnCopyLink, #btnAddToCumul,
    [data-bs-dismiss="modal"], .form-check,
    #resultSidebar { display: none !important; }

    body { background: #fff !important; }

    .modal { display: block !important; position: static !important; overflow: visible !important; }
    .modal-dialog { max-width: 100% !important; margin: 0 !important; box-shadow: none !important; }
    .modal-content { border: none !important; box-shadow: none !important; }
    .modal-body { padding: .5rem 1rem !important; overflow: visible !important; max-height: none !important; }

    /* Full-width table when sidebar is hidden */
    .col-md-8 { width: 100% !important; border-right: none !important; max-height: none !important; overflow: visible !important; }

    #resultCard { page-break-inside: avoid; }

    .cgpa-result-header {
        print-color-adjust: exact; -webkit-print-color-adjust: exact;
        border-radius: 0 !important;
    }

    .cgpa-breakdown-table { font-size: .8rem; }
    .cgpa-breakdown-table th, .cgpa-breakdown-table td { padding: .3rem .4rem; }
}
