/* ============================================================
   刷课助手 — Design System
   Palette: Indigo / Coral / Mint / Amber / Slate
   Fonts: Plus Jakarta Sans (display), Inter (body), JetBrains Mono (data)
   ============================================================ */

/* --- Variables --- */
:root {
    --indigo: #5B4FE0;
    --indigo-light: #7B71E8;
    --indigo-dark: #4A3FCC;
    --coral: #FF6B6B;
    --coral-light: #FF8E8E;
    --mint: #3DD9A0;
    --mint-light: #E8FBF2;
    --amber: #F5A623;
    --amber-light: #FFF5E0;
    --slate: #94A3B8;
    --slate-light: #CBD5E1;
    --bg: #F1F3F8;
    --card: #FFFFFF;
    --text: #1A1A2E;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;
    --border: #E2E8F0;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 4px 24px rgba(91, 79, 224, 0.07);
    --shadow-hover: 0 8px 32px rgba(91, 79, 224, 0.12);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --font-display: 'Plus Jakarta Sans', sans-serif;
    --font-body: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

input, button, select { font-family: inherit; }

.mono { font-family: var(--font-mono); }

/* --- Focus visible --- */
:focus-visible {
    outline: 2px solid var(--indigo);
    outline-offset: 2px;
}

/* --- Reduce motion --- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
/* ============================================================
   Login Page
   ============================================================ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #5B4FE0 0%, #1A1A2E 100%);
    position: relative;
    overflow: hidden;
    padding: 20px;
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
    animation: cardIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo {
    margin-bottom: 16px;
    display: inline-block;
}

.login-header h1 {
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.login-error {
    background: #FFF0F0;
    border: 1px solid var(--coral-light);
    color: var(--coral);
    border-radius: var(--radius-xs);
    padding: 10px 14px;
    font-size: 14px;
    margin-bottom: 20px;
    text-align: center;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.login-form input:focus {
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(91, 79, 224, 0.12);
    outline: none;
}

.login-form input::placeholder { color: var(--text-muted); }

/* Background shapes */
.login-bg-shapes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
}

.shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
}

.shape-1 {
    width: 400px; height: 400px;
    background: var(--coral);
    top: -100px; right: -100px;
    animation: float 8s ease-in-out infinite;
}

.shape-2 {
    width: 300px; height: 300px;
    background: var(--mint);
    bottom: -80px; left: -80px;
    animation: float 10s ease-in-out infinite reverse;
}

.shape-3 {
    width: 200px; height: 200px;
    background: var(--amber);
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation: float 12s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(20px, -20px); }
}
/* ============================================================
   Buttons
   ============================================================ */

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--indigo) 0%, var(--indigo-light) 100%);
    color: #fff;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
}

.btn-primary:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(91, 79, 224, 0.3);
}

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

.btn-login { width: 100%; padding: 14px; font-size: 16px; }

.btn-ghost {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: var(--radius-xs);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-ghost:hover {
    border-color: var(--coral);
    color: var(--coral);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition), background var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--coral);
    background: rgba(255, 107, 107, 0.08);
}

.inline-form { display: inline; }
/* ============================================================
   Top Bar
   ============================================================ */

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.topbar-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-user {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ============================================================
   Dashboard Layout
   ============================================================ */

.dashboard {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 64px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 16px;
}
/* ============================================================
   Query Section
   ============================================================ */

.query-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow);
    margin-bottom: 28px;
}

.query-form {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.query-inputs {
    display: flex;
    gap: 14px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}

.query-inputs .form-group {
    flex: 1;
    min-width: 180px;
}

.query-inputs label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.query-inputs .optional {
    color: var(--text-muted);
    font-weight: 400;
}

.query-inputs input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.query-inputs input:focus {
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(91, 79, 224, 0.1);
    outline: none;
}

.query-inputs input::placeholder { color: var(--text-muted); }

.btn-query {
    min-width: 100px;
    height: 42px;
    flex-shrink: 0;
}

/* Loading dots */
.dot-pulse {
    display: inline-flex;
    gap: 4px;
}

.dot-pulse::before,
.dot-pulse::after,
.dot-pulse {
    position: relative;
}

.btn-loading {
    display: inline-flex;
    gap: 5px;
    align-items: center;
}

.btn-loading .dot-pulse,
.btn-loading .dot-pulse::before,
.btn-loading .dot-pulse::after {
    width: 6px;
    height: 6px;
    background: #fff;
    border-radius: 50%;
    display: inline-block;
    animation: dotPulse 1.2s infinite ease-in-out;
}

.btn-loading .dot-pulse::before {
    content: '';
    animation-delay: -0.3s;
    margin-right: 5px;
}

.btn-loading .dot-pulse::after {
    content: '';
    animation-delay: 0.3s;
    margin-left: 5px;
}

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40%           { opacity: 1; transform: scale(1); }
}
/* ============================================================
   Select Input
   ============================================================ */

.query-inputs select {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2394A3B8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.query-inputs select:focus {
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px rgba(91, 79, 224, 0.1);
    outline: none;
}

/* ============================================================
   Result Section (multi-course)
   ============================================================ */

.result-section {
    margin-bottom: 28px;
    animation: fadeUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.result-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}

.result-count {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 500;
}

.result-message {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}

.result-message.error {
    background: #FFF0F0;
    border: 1px solid var(--coral-light);
    color: var(--coral);
}

/* Course card grid */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 14px;
}

.course-card {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition), box-shadow var(--transition);
    animation: cardFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.course-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

/* Completed card gets a subtle green left border */
.course-card.course-completed {
    border-left: 4px solid var(--mint);
}

.course-card.course-in_progress {
    border-left: 4px solid var(--amber);
}

.course-card.course-not_started {
    border-left: 4px solid var(--slate-light);
}

.ccard-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.ccard-name {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Progress bar */
.ccard-bar {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.ccard-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.ccard-bar-completed {
    background: linear-gradient(90deg, var(--mint) 0%, #2BC48A 100%);
}

.ccard-bar-in_progress {
    background: linear-gradient(90deg, var(--indigo) 0%, var(--coral) 100%);
}

.ccard-bar-not_started {
    background: var(--slate-light);
}

/* Bottom stats row */
.ccard-bottom {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.ccard-percent {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.ccard-stat {
    font-size: 12px;
    color: var(--text-muted);
}

.ccard-stat strong {
    color: var(--text-secondary);
    font-weight: 600;
}

/* ============================================================
   Status Pills
   ============================================================ */

.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
}

.status-completed, .status-pill[data-status="completed"] {
    background: var(--mint-light);
    color: #0D9668;
}

.status-in_progress, .status-pill[data-status="in_progress"] {
    background: var(--amber-light);
    color: #B8860B;
}

.status-not_started, .status-pill[data-status="not_started"] {
    background: #F1F5F9;
    color: var(--slate);
}

/* ============================================================
   History Section (batch list)
   ============================================================ */

.history-section {
    margin-top: 8px;
}

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

.history-item {
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 14px 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: transform var(--transition), box-shadow var(--transition);
}

.history-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.hitem-info {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
    font-size: 14px;
}

.hitem-platform {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--indigo);
    font-size: 14px;
}

.hitem-school {
    color: var(--text);
    font-weight: 500;
}

.hitem-user {
    color: var(--text-secondary);
}

.hitem-count {
    color: var(--text-muted);
    font-size: 13px;
}

.hitem-time {
    color: var(--text-muted);
    font-size: 12px;
}

.hitem-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 12px;
}

.history-empty {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 15px;
}

/* ============================================================
   Checkbox (custom)
   ============================================================ */

.ccard-check-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.ccard-check {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: inline-block;
    transition: all var(--transition);
    position: relative;
}

.ccard-check:checked + .checkmark {
    background: var(--indigo);
    border-color: var(--indigo);
}

.ccard-check:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* ============================================================
   Order Button
   ============================================================ */

.btn-order {
    margin-left: auto;
    padding: 4px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--coral);
    background: none;
    border: 1.5px solid var(--coral);
    border-radius: 20px;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn-order:hover {
    background: var(--coral);
    color: #fff;
}

.btn-order:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.btn-order-done {
    background: var(--mint);
    border-color: var(--mint);
    color: #fff;
}

.btn-order-done:hover {
    background: var(--mint);
    border-color: var(--mint);
}

/* ============================================================
   Batch Order Bar
   ============================================================ */

.batch-bar {
    margin-top: 16px;
    background: var(--card);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    box-shadow: var(--shadow);
    border: 1.5px solid var(--indigo-light);
}

.batch-bar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    font-size: 14px;
    color: var(--text);
}

.batch-bar-inner strong {
    color: var(--indigo);
    font-family: var(--font-mono);
}

.batch-bar-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ============================================================
   Toast
   ============================================================ */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}

.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success { background: var(--mint); color: #fff; }
.toast-error   { background: var(--coral); color: #fff; }
.toast-warning { background: var(--amber); color: var(--text); }
.toast-info    { background: var(--indigo); color: #fff; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
    .query-form {
        flex-direction: column;
    }

    .query-inputs {
        flex-direction: column;
    }

    .query-inputs .form-group {
        min-width: 100%;
    }

    .btn-query {
        width: 100%;
    }

    .course-grid {
        grid-template-columns: 1fr;
    }

    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .hitem-actions {
        align-self: flex-end;
    }

    .dashboard {
        padding: 20px 16px 48px;
    }

    .query-section {
        padding: 20px;
    }

    .login-card {
        padding: 36px 24px;
    }

    .batch-bar-inner {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .topbar-title {
        font-size: 16px;
    }

    .ccard-name {
        font-size: 14px;
    }

    .course-card {
        padding: 14px 16px;
    }

    .ccard-bottom {
        flex-wrap: wrap;
        gap: 8px;
    }
}
