:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #ec4899;
    --bg-color: #f8fafc;
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --card-bg: rgba(255, 255, 255, 0.85);
    --border-color: rgba(255, 255, 255, 0.6);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
    --gradient-1: #a78bfa;
    --gradient-2: #f472b6;
    --gradient-3: #22d3ee;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: float 20s infinite alternate;
}

.blob-1 {
    top: -10%;
    left: -10%;
    width: 600px;
    height: 600px;
    background: var(--gradient-1);
    animation-delay: 0s;
}

.blob-2 {
    bottom: -10%;
    right: -10%;
    width: 500px;
    height: 500px;
    background: var(--gradient-2);
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 40%;
    width: 400px;
    height: 400px;
    background: var(--gradient-3);
    animation-delay: -10s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(30px, 50px) scale(1.1);
    }
}

/* Container Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: auto 1fr;
    gap: 1.5rem;
    grid-template-areas:
        "header header"
        "main sidebar";
}

header {
    grid-area: header;
    text-align: center;
    padding: 2rem 0;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

header p {
    color: var(--text-secondary);
}

main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

aside {
    grid-area: sidebar;
}

/* Card Styles */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.card:hover {
    transform: translateY(-2px);
}

h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-main);
}

/* Upload Section */
.drop-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.4);
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.icon-container {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.browser-btn {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: underline;
}

.hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

/* List Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.controls-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.mobile-only {
    display: none;
}

.primary-btn {
    background: var(--primary-color);
    color: white;
}

.primary-btn:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.secondary-btn {
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.secondary-btn:hover {
    background: rgba(99, 102, 241, 0.05);
}

.danger-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

th {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
}

/* Desktop: Specific Column Widths */
th:nth-child(3),
td:nth-child(3) {
    width: 110px;
}

td input,
td select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    font-size: 0.95rem;
    transition: all 0.2s;
}

td input:focus,
td input:hover,
td select:focus,
td select:hover {
    background: white;
    border-color: #cbd5e1;
    outline: none;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #94a3b8;
    padding: 4px;
    border-radius: 4px;
}

.action-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    font-style: italic;
    display: none;
}

#course-list:empty+.empty-state {
    display: block;
}

/* Results Section */
.results-card {
    position: sticky;
    top: 2rem;
    height: fit-content;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.result-item:last-of-type {
    border-bottom: none;
}

.result-item.highlight {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(236, 72, 153, 0.1));
    margin: 1rem -1.5rem;
    padding: 1rem 1.5rem;
    border-bottom: none;
}

.label {
    color: var(--text-secondary);
}

.value {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
}

.highlight .value {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.calc-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    line-height: 1.4;
    background: rgba(0, 0, 0, 0.02);
    padding: 0.75rem;
    border-radius: 8px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "sidebar"
            "main";
        padding: 0.5rem;
        /* Reduced outer padding */
    }

    .upload-section {
        display: none;
    }

    .mobile-only {
        display: inline-block;
    }

    .card {
        padding: 0.75rem;
        /* Reduced card padding */
    }

    .results-card {
        position: static;
        order: -1;
    }

    header h1 {
        font-size: 1.75rem;
        /* Smaller title */
        margin-bottom: 0.25rem;
    }

    header {
        padding: 1rem 0;
    }

    .blob {
        width: 300px;
        height: 300px;
    }

    /* Mobile Table Optimizations */
    .section-header {
        flex-direction: column;
        align-items: stretch;
    }

    .controls-group {
        justify-content: space-between;
        margin-top: 0.5rem;
        gap: 0.25rem;
    }

    .btn {
        padding: 0.4rem 0.5rem;
        /* Smaller buttons */
        font-size: 0.8rem;
    }

    /* Tighter table layout */
    th,
    td {
        padding: 0.4rem 0.1rem;
        /* Minimal horizontal padding */
        font-size: 0.75rem;
        /* Smaller text */
        white-space: nowrap;
    }

    /* Column Width Management */
    /* Checkbox */
    th:nth-child(1),
    td:nth-child(1) {
        width: 20px;
    }

    /* Attribute (Type) */
    th:nth-child(3),
    td:nth-child(3) {
        width: 55px;
    }

    /* Credit */
    th:nth-child(4),
    td:nth-child(4) {
        width: 30px;
    }

    /* Score */
    th:nth-child(5),
    td:nth-child(5) {
        width: 40px;
    }

    /* Action */
    th:nth-child(6),
    td:nth-child(6) {
        width: 25px;
    }

    /* Course Name - takes remaining space */
    th:nth-child(2),
    td:nth-child(2) {
        width: auto;
        max-width: 80px;
        /* Force truncation constraints */
    }

    td input,
    td select {
        font-size: 0.75rem;
        padding: 0.25rem 0;
        width: 100%;
        text-align: center;
    }

    /* Specific input constraints */
    .input-name {
        text-align: left;
        width: 100%;
        min-width: 60px;
        /* Guarantee visual space */
    }
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.9);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 50px;
    font-size: 0.9rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.toast.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    background: white;
    width: 90%;
    max-width: 600px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transform: scale(1);
    transition: transform 0.3s ease;

    /* Mobile Scroll Fix */
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-overlay.hidden .modal {
    transform: scale(0.95);
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    /* Prevent shrinking */
}

/* ... */

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    /* Enable scroll */
    flex: 1;
    /* Occupy remaining space */
}

.step-group {
    margin-bottom: 1.5rem;
}

.step-group:last-child {
    margin-bottom: 0;
}

.step-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.copy-box {
    display: flex;
    gap: 0.5rem;
}

.copy-box textarea {
    flex: 1;
    height: 60px;
    /* Compact height for prompt */
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: #f8fafc;
}

textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

#json-input {
    min-height: 150px;
    font-family: monospace;
    /* Better for JSON */
}

/* Help Modal Styles */
.help-section {
    margin-bottom: 1.5rem;
}

.help-section h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
    font-size: 1.05rem;
}

.help-content ul {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--text-secondary);
}

.help-content li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

.warning-section {
    background: #fff4e5;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #f97316;
}

.warning-section h4 {
    color: #c2410c;
}

.warning-section ul {
    color: #9a3412;
}