/* CSS Variables & Global Reset */
:root {
    --bg-primary: #0f172a;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent-color: #38bdf8;
    --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --card-radius: 16px;
    --transition-speed: 0.3s;
    --highlight-green: #22c55e;
    --danger-red: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Poppins', sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    /* Center vertically on large screens */
    padding: 20px;
}

/* Background Animations */
.background-globes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.globe {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 10s infinite ease-in-out;
}

.globe-1 {
    width: 300px;
    height: 300px;
    background: #7c3aed;
    top: -50px;
    left: -50px;
    animation-delay: 0s;
}

.globe-2 {
    width: 400px;
    height: 400px;
    background: #2563eb;
    bottom: -100px;
    right: -100px;
    animation-delay: 2s;
}

.globe-3 {
    width: 250px;
    height: 250px;
    background: #db2777;
    /* Pinkish */
    top: 40%;
    left: 60%;
    animation-delay: 4s;
    opacity: 0.4;
}

@keyframes float {
    0% {
        transform: translate(0, 0);
    }

    50% {
        transform: translate(30px, -30px);
    }

    100% {
        transform: translate(0, 0);
    }
}

/* Main Container */
.main-container {
    width: 100%;
    max-width: 1200px;
    /* Increased width for better layout */
    z-index: 10;
}

header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInDown 0.8s ease-out;
}

.logo {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.logo i {
    font-size: 2rem;
    color: #38bdf8;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Layout */
.app-content {
    display: grid;
    grid-template-columns: 380px 1fr;
    /* Slightly wider form */
    gap: 30px;
}

@media (max-width: 900px) {
    .app-content {
        grid-template-columns: 1fr;
    }
}

/* Glass Card Style */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--card-radius);
    padding: 24px;
    box-shadow: var(--glass-shadow);
}

/* Input Form */
.form-card {
    position: sticky;
    top: 20px;
    animation: fadeInLeft 0.8s ease-out;
}

.form-card h2 {
    font-size: 1.25rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Term Section in Form */
.term-section {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.term-section h3 {
    font-size: 0.95rem;
    color: var(--accent-color);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group {
    margin-bottom: 15px;
}

.quiz-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 5px;
}

label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    color: white;
    font-size: 1rem;
    transition: all 0.2s;
    outline: none;
}

input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 25px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(56, 189, 248, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Results Panel */
.results-panel {
    animation: fadeInRight 0.8s ease-out;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.btn-text-danger {
    background: none;
    border: none;
    color: var(--danger-red);
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
    opacity: 0.8;
}

.btn-text-danger:hover {
    opacity: 1;
}

.courses-grid {
    display: grid;
    grid-template-columns: 1fr;
    /* Stack cards vertically for better detail view, or keep grid if space allows */
    gap: 20px;
}

@media(min-width: 1100px) {
    .courses-grid {
        grid-template-columns: 1fr 1fr;
        /* 2 columns on wide screens */
    }
}


/* Course Card */
.course-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 24px;
    position: relative;
    transition: transform 0.2s, background 0.2s;
}

.course-card:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-3px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding-bottom: 10px;
}

.course-title {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--text-primary);
    word-break: break-word;
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: color 0.2s;
}

.delete-btn:hover {
    color: var(--danger-red);
}

/* New Card Layout for Mid/Final */
.terms-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.term-block {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 10px;
}

.term-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--accent-color);
    margin-bottom: 10px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 5px;
}

.scores-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.score-item span {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.score-item strong {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.best-quiz-badge {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    padding: 8px;
    border-radius: 6px;
    text-align: center;
    color: var(--highlight-green);
}

.best-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 600;
    display: block;
    margin-bottom: 2px;
}

.best-value {
    font-size: 1.3rem;
    font-weight: 700;
}

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 16px;
    border: 1px dashed var(--glass-border);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

footer {
    text-align: center;
    margin-top: 50px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    opacity: 0.6;
}

/* Animations */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes listEnter {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.course-card {
    animation: listEnter 0.4s ease-out;
}