/* =====================================================
   KTU Grade Checker — Style Sheet
   Clean, minimal, modern design
   ===================================================== */

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --text: #1a1d23;
    --text-secondary: #5f6878;
    --border: #e2e5eb;
    --accent: #4f46e5;
    --accent-light: #eef2ff;
    --accent-hover: #4338ca;
    --success: #059669;
    --success-bg: #ecfdf5;
    --warning: #d97706;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --info: #2563eb;
    --info-bg: #eff6ff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.07);
    --transition: .2s ease;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ---------- Layout ---------- */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main {
    max-width: 660px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 48px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---------- Header ---------- */
.header {
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,.88);
}

.header-inner {
    max-width: 660px;
    margin: 0 auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--accent);
}

.logo h1 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.02em;
}

.badge {
    font-size: .75rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-light);
    padding: 4px 10px;
    border-radius: 99px;
    letter-spacing: .02em;
}

/* ---------- Info Banner ---------- */
.info-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: var(--info-bg);
    border: 1px solid #bfdbfe;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: .85rem;
    color: #1e40af;
    line-height: 1.5;
    animation: fadeDown .4s ease;
}

.info-icon {
    flex-shrink: 0;
    margin-top: 1px;
    color: var(--info);
}

.info-text { flex: 1; }
.info-text strong { font-weight: 600; }

.info-close {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 1.2rem;
    color: #1e40af;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    opacity: .6;
    transition: opacity var(--transition);
}

.info-close:hover { opacity: 1; }

/* ---------- Card ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    animation: fadeUp .35s ease;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 20px;
    letter-spacing: -.01em;
}

/* ---------- Section Labels ---------- */
.section-label {
    font-size: .88rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
}

/* ---------- Mode Toggle ---------- */
.mode-toggle {
    display: flex;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 4px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
}

.mode-btn {
    flex: 1;
    padding: 8px;
    font-size: .85rem;
    font-weight: 600;
    text-align: center;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: calc(var(--radius-sm) - 2px);
    cursor: pointer;
    transition: all var(--transition);
}

.mode-btn.active {
    background: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.section-hint {
    font-size: .73rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ---------- Form ---------- */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group label {
    display: block;
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: .01em;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap input {
    width: 100%;
    padding: 10px 48px 10px 14px;
    font-size: .95rem;
    font-family: var(--font);
    font-weight: 500;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.input-wrap input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}

.input-wrap input::placeholder { color: #c1c5ce; }

.input-suffix {
    position: absolute;
    right: 12px;
    font-size: .8rem;
    font-weight: 500;
    color: var(--text-secondary);
    pointer-events: none;
}

.hint {
    font-size: .72rem;
    color: #9ca3af;
    margin-top: 4px;
}

/* ---------- Assignment Controls ---------- */
.assignment-controls {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.inline-group {
    flex: 1;
    min-width: 160px;
}

.small-input input {
    padding-right: 14px;
    max-width: 100px;
}

.assignments-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assignment-row {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeUp .25s ease;
}

.assignment-row .input-wrap {
    flex: 1;
}

.assignment-row .assignment-label {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 90px;
    white-space: nowrap;
}

.btn-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--danger-bg);
    color: var(--danger);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    transition: background var(--transition), transform .1s;
    flex-shrink: 0;
}

.btn-remove:hover {
    background: #fecaca;
    transform: scale(1.05);
}

/* ---------- Buttons ---------- */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 24px;
    padding: 12px 20px;
    font-size: .92rem;
    font-weight: 600;
    font-family: var(--font);
    color: #fff;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), transform .1s ease, box-shadow var(--transition);
    box-shadow: 0 1px 3px rgba(79,70,229,.25);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 12px rgba(79,70,229,.3);
}

.btn-primary:active {
    transform: scale(.985);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 14px;
    font-size: .82rem;
    font-weight: 600;
    font-family: var(--font);
    color: var(--accent);
    background: var(--accent-light);
    border: 1.5px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    white-space: nowrap;
}

.btn-secondary:hover {
    background: #e0e7ff;
    border-color: var(--accent);
}

/* ---------- Results ---------- */
.results-card {
    animation: fadeUp .4s ease;
}

.internal-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.summary-item {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 14px 10px;
    text-align: center;
}

.summary-label {
    font-size: .7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 4px;
}

.summary-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
}

.summary-value.total {
    color: var(--accent);
}

/* ---------- Table ---------- */
.table-wrap {
    overflow-x: auto;
    margin: 0 -4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .88rem;
}

thead th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    font-size: .76rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 11px 12px;
    border-bottom: 1px solid #f0f1f3;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr {
    transition: background var(--transition);
}

tbody tr:hover {
    background: #fafbfc;
}

/* ---------- Grade Pills ---------- */
.grade-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 26px;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.grade-s     { background: #dcfce7; color: #166534; }
.grade-aplus { background: #d1fae5; color: #065f46; }
.grade-a     { background: #ecfdf5; color: #047857; }
.grade-bplus { background: #e0f2fe; color: #075985; }
.grade-b     { background: #e0e7ff; color: #3730a3; }
.grade-cplus { background: #ede9fe; color: #5b21b6; }
.grade-c     { background: #fef3c7; color: #92400e; }
.grade-d     { background: #fed7aa; color: #9a3412; }
.grade-p     { background: #fde68a; color: #78350f; }
.grade-f     { background: #fee2e2; color: #991b1b; }

/* Status badges in results */
.status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
}

.status-easy      { background: #dcfce7; color: #166534; }
.status-possible  { background: #e0f2fe; color: #075985; }
.status-hard      { background: #fef3c7; color: #92400e; }
.status-impossible{ background: #fee2e2; color: #991b1b; }
.status-secured   { background: #d1fae5; color: #065f46; }

/* ---------- Notes ---------- */
.notes {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: .82rem;
    line-height: 1.5;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
}

.note-icon { flex-shrink: 0; margin-top: 1px; }

.note-pass    { background: var(--success-bg); color: #065f46; }
.note-warning { background: var(--warning-bg); color: #92400e; }
.note-danger  { background: var(--danger-bg);  color: #991b1b; }
.note-info    { background: var(--info-bg);    color: #1e40af; }

/* ---------- Reference Table ---------- */
.ref-table tbody td:first-child { width: 60px; }

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    padding: 20px 16px;
    font-size: .76rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

.dev-credits {
    margin-top: 8px;
    font-weight: 500;
}

.dev-credits a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition);
}

.dev-credits a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.separator {
    margin: 0 6px;
    opacity: 0.5;
}

/* ---------- Animations ---------- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Responsive ---------- */
@media (max-width: 520px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .internal-summary {
        grid-template-columns: 1fr 1fr;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .card { padding: 18px 14px; }

    thead th, tbody td {
        padding: 8px 8px;
        font-size: .82rem;
    }

    .assignment-row .assignment-label {
        min-width: 70px;
        font-size: .75rem;
    }
}
