/* =============================================================================
   DESIGN TOKENS
   ============================================================================= */

:root {
    /* Orange Palette */
    --orange-50: #fff7ed;
    --orange-100: #ffedd5;
    --orange-200: #fed7aa;
    --orange-300: #fdba74;
    --orange-400: #fb923c;
    --orange-500: #f97316;
    --orange-600: #ea580c;

    /* Stone Palette */
    --stone-50: #fafaf9;
    --stone-100: #f5f5f4;
    --stone-200: #e7e5e4;
    --stone-300: #d6d3d1;
    --stone-400: #a8a29e;
    --stone-500: #78716c;
    --stone-600: #57534e;
    --stone-700: #44403c;
    --stone-800: #292524;
    --stone-900: #1c1917;

    /* Semantic: Red */
    --red-50: #fef2f2;
    --red-100: #fee2e2;
    --red-200: #fecaca;
    --red-500: #ef4444;
    --red-600: #dc2626;

    /* Semantic: Emerald */
    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-200: #a7f3d0;
    --emerald-500: #10b981;
    --emerald-600: #059669;

    /* Brand Tokens */
    --primary: var(--orange-400);
    --primary-dark: var(--orange-500);
    --primary-light: var(--orange-200);

    /* Background Tokens */
    --bg: var(--orange-50);
    --card-bg: white;

    /* Text Tokens */
    --text: var(--stone-800);
    --text-secondary: var(--stone-500);

    /* Border Tokens */
    --border: var(--stone-300);
    --border-light: var(--stone-100);

    /* Shadow Tokens */
    --shadow:
        0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg:
        0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);

    /* Radius Tokens */
    --radius: 12px;
    --radius-sm: 8px;

    /* Grid Pattern */
    --grid-color: #ffedd588; /* orange-100 with opacity */
    --grid-size: 20px;
}

/* =============================================================================
   BASE STYLES
   ============================================================================= */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, sans-serif;
    background:
        linear-gradient(to right, var(--grid-color) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-color) 1px, transparent 1px);
    background-color: var(--bg);
    background-size: var(--grid-size) var(--grid-size);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

.hero-card,
.step-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

/* =============================================================================
   HERO / INFO CARD
   ============================================================================= */

.hero-card {
    padding: 2rem;
    margin-bottom: 2rem;
}

.hero-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 1rem;
}

.hero-description {
    color: var(--text-secondary);
    font-size: 1rem;
    line-height: 1.7;
    margin-bottom: 1rem;
}

.hero-description:last-child {
    margin-bottom: 0;
}

.hero-description .highlight {
    color: var(--primary-dark);
    font-weight: 600;
}

.btn-import-link {
    background: none;
    border: none;
    color: var(--primary-dark);
    font-size: inherit;
    font-family: inherit;
    line-height: inherit;
    font-weight: 600;
    padding: 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.btn-import-link:hover {
    color: var(--primary);
}

.university-badge {
    background: var(--stone-100);
    color: var(--stone-600);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    margin-right: 0.25rem;
    white-space: nowrap;
}

/* =============================================================================
   STEP CARDS (Shared Components)
   ============================================================================= */

.step-card {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.step-card.active {
    border-color: var(--primary);
}

.step-card.disabled {
    opacity: 0.6;
    pointer-events: none;
}

.step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.step-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
}

.step-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
}

/* specific to step 2 */

/* =============================================================================
   STEP 1: University & Semester Selection
   ============================================================================= */

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .form-row {
        grid-template-columns: 1fr 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

select,
input[type="text"] {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: white;
    transition: border-color 0.2s;
    width: 100%;
}

select:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

select:disabled {
    background: var(--border-light);
    cursor: not-allowed;
}

/* =============================================================================
   STEP 2: Course Selection
   ============================================================================= */
.course-selection {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 640px) {
    .course-selection {
        grid-template-columns: 1fr 1.5fr;
    }
}

.selected-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.selected-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.selected-count {
    color: var(--primary);
    font-weight: 600;
}

.selected-courses {
    max-width: none !important;
    min-width: auto !important;
    width: 100%;
}

@media (min-width: 640px) {
    .selected-courses {
        max-width: 320px;
        min-width: 220px;
    }
}

.course-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 100px;
    max-height: calc(38vh);
    overflow-y: auto;
    padding-right: 0.25rem;
}

.empty-state {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
    padding: 2rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
}

.course-chip {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--border-light);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    gap: 0.5rem;
}

.course-info {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1;
    min-width: 0;
}

.course-name {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.btn-remove {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: var(--red-100);
    color: var(--red-600);
}

/* Search Box (Step 2) */
.search-box {
    position: relative;
    margin-bottom: 0.75rem;
}

.search-box input {
    padding-left: 2.5rem;
}

.search-icon {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}

.search-results {
    background: var(--border-light);
    border-radius: var(--radius-sm);
    max-height: 400px;
    overflow-y: auto;
}

.results-header {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
    position: sticky;
    top: 0;
}

.results-list {
    padding: 0.25rem;
}

.result-item {
    padding: 0.75rem;
    background: white;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: all 0.15s;
    border: 2px solid transparent;
}

.result-item:hover {
    border-color: var(--primary-light);
}

.result-item.selected {
    border-color: var(--primary);
    background: var(--orange-50);
}

.result-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.result-name {
    font-weight: 500;
    font-size: 0.9375rem;
}

.result-id {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: monospace;
}

.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.meta-tag {
    font-size: 0.6875rem;
    background: var(--border-light);
    color: var(--text-secondary);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
}

/* -----------------------------------------------------------------------------
   STEP 2: Confirm Button
   ----------------------------------------------------------------------------- */

.confirm-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border);
    text-align: center;
}

.btn-clear {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.btn-clear:hover:not(:disabled) {
    color: var(--text);
}

.btn-clear:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-confirm {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow:
        0 4px 6px -1px var(--orange-300),
        0 2px 4px -1px var(--orange-200);
}

.btn-confirm:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow:
        0 8px 12px -1px var(--orange-300),
        0 4px 6px -2px var(--orange-200);
}

.btn-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =============================================================================
   STEP 3: Calendar Results
   ============================================================================= */

.calendar-result {
    padding: 1rem 0;
}

.platform-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.tab-btn:hover {
    background: var(--border-light);
}

.tab-btn.active {
    color: var(--primary);
    background: var(--orange-50);
}

.url-box {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.url-box input {
    flex: 1;
    font-family: monospace;
    font-size: 0.875rem;
    background: var(--border-light);
}

.btn-copy {
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-copy:hover {
    background: var(--primary-dark);
}

.tab-content p {
    color: var(--text-secondary);
}

/* -----------------------------------------------------------------------------
   STEP 3: Result Actions
   ----------------------------------------------------------------------------- */

.result-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.btn-back,
.btn-reset {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-back {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-back:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-reset:hover {
    border-color: var(--text-secondary);
    color: var(--text);
}

/* -----------------------------------------------------------------------------
   STEP 3: Open in Calendar Button
   ----------------------------------------------------------------------------- */

.btn-open {
    display: inline-block;
    background: var(--primary);
    color: white;
    text-decoration: none;
    padding: 1rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    transition: all 0.2s;
    box-shadow:
        0 4px 6px -1px var(--orange-300),
        0 2px 4px -1px var(--orange-200);
}

.btn-open:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow:
        0 8px 12px -1px var(--orange-300),
        0 4px 6px -2px var(--orange-200);
}

.alt-method {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 1rem;
}

.alt-method a {
    color: var(--primary);
    text-decoration: none;
}

.alt-method a:hover {
    text-decoration: underline;
}

/* =============================================================================
   TOAST NOTIFICATIONS
   ============================================================================= */

.toast-container {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    pointer-events: none;
    padding: 1rem;
}

.toast {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    min-width: 280px;
    max-width: 400px;
}

.toast.error {
    background: var(--red-50);
    border: 1px solid var(--red-200);
}

.toast.success {
    background: var(--emerald-50);
    border: 1px solid var(--emerald-200);
}

.toast.info {
    background: var(--orange-50);
    border: 1px solid var(--orange-200);
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.9375rem;
    color: var(--text);
}

.toast-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.toast-close:hover {
    background: var(--border-light);
}

/* =============================================================================
   IMPORT DIALOG
   ============================================================================= */

.import-dialog {
    border: none;
    border-radius: var(--radius);
    padding: 0;
    width: min(560px, calc(100% - 2rem));
    box-shadow: var(--shadow-lg);
    margin: auto;
}

.import-dialog::backdrop {
    background: rgba(28, 25, 23, 0.45);
}

.import-dialog-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.5rem;
    background: var(--card-bg);
}

.import-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.import-dialog-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.btn-dialog-close {
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.btn-dialog-close:hover {
    color: var(--text);
}

.import-dialog-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.import-dialog-hint {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.import-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.btn-secondary {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 0.6rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--text-secondary);
    color: var(--text);
}

/* =============================================================================
   UTILITIES
   ============================================================================= */

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}
