/* ===== Plan Builder ===== */

.plan-builder-wrap {
    user-select: none;
}

/* Title row: "Your Plan" + credit summary on the left, action buttons on the right. */
.plan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.plan-header h3 {
    margin: 0;
}

.plan-title {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
}

.plan-summary {
    font-size: 12px;
    color: #666;
}

.plan-summary-planned {
    color: #002b5c;
    font-weight: 600;
}

.plan-summary-ap {
    color: #2f6b48;
}

.plan-summary-total {
    font-weight: 600;
    margin-left: 2px;
}

.plan-summary-total.on-track { color: #2f6b48; }
.plan-summary-total.close    { color: #b18d03; }
.plan-summary-total.short    { color: #a94442; }

.plan-summary-remaining {
    color: #999;
    margin-left: 2px;
}

.plan-summary-remaining.on-track {
    color: #2f6b48;
}

.plan-actions {
    display: flex;
    align-items: center;
}

/* Leave room at the bottom of the page so the drawer (collapsed or expanded)
   never covers the last row of the plan grid. Tracks --drawer-height, which
   the resize JS sets on :root. */
body {
    padding-bottom: calc(var(--drawer-height, 30vh) + 40px);
    transition: padding-bottom 0.25s ease;
}

/* Collapsible palette drawer pinned to the bottom of the viewport.
   Height is controlled via --drawer-height (set by drag handle in JS). */
#palette-drawer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    border-top: 2px solid #002b5c;
    box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    height: var(--drawer-height, 30vh);
    max-height: 85vh;
    min-height: 50px;
    transition: height 0.25s ease;
}

/* While the user is actively dragging, skip the transition so it tracks the cursor */
#palette-drawer.resizing {
    transition: none;
}

#palette-drawer.collapsed {
    height: 50px;
}

#drawer-resize-handle {
    position: absolute;
    top: -4px;
    left: 0;
    right: 0;
    height: 8px;
    cursor: ns-resize;
    background: transparent;
    z-index: 2;
}

#drawer-resize-handle::after {
    content: "";
    display: block;
    width: 40px;
    height: 3px;
    background: #ccc;
    border-radius: 2px;
    margin: 2px auto 0;
}

#drawer-resize-handle:hover::after {
    background: #b18d03;
}

#palette-drawer-header {
    flex: 0 0 auto;
    height: 44px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    background: #002b5c;
    color: #fff;
    cursor: pointer;
    user-select: none;
    gap: 12px;
}

.drawer-title {
    font-weight: bold;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

#palette-search {
    flex: 1 1 auto;
    max-width: 360px;
    height: 28px;
    padding: 4px 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-radius: 3px;
    font-size: 12px;
    outline: none;
}

#palette-search::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

#palette-search:focus {
    background: rgba(255, 255, 255, 0.2);
    border-color: #b18d03;
}

#add-course-btn {
    background: rgba(177, 141, 3, 0.2);
    border: 1px solid rgba(177, 141, 3, 0.7);
    color: #fff;
    border-radius: 3px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

#add-course-btn:hover {
    background: rgba(177, 141, 3, 0.45);
    border-color: #b18d03;
}

#drawer-toggle {
    margin-left: auto;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.4);
    color: #fff;
    border-radius: 3px;
    padding: 3px 10px;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
}

#drawer-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

.drawer-chevron {
    display: inline-block;
    transition: transform 0.25s ease;
}

#palette-drawer.collapsed .drawer-chevron {
    transform: rotate(180deg);
}

#palette-drawer-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 16px;
}

/* Palette: groups flow horizontally as a responsive grid */
#palette {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 18px;
    align-items: start;
}

.palette-group {
    margin-bottom: 0;
}

.palette-group-label {
    font-weight: bold;
    text-transform: uppercase;
    font-size: 11px;
    color: #666;
    margin-bottom: 6px;
    border-bottom: 1px solid #ddd;
    padding-bottom: 3px;
}

/* Course card (used in palette and grid) */
.course-card {
    position: relative;
    background: #fff;
    border: 1px solid #ccc;
    border-left: 4px solid #002b5c;
    border-radius: 3px;
    padding: 6px 8px;
    margin-bottom: 5px;
    cursor: grab;
    font-size: 12px;
    transition: box-shadow 0.15s, transform 0.15s, opacity 0.15s;
}

.course-card:hover {
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.course-card:active {
    cursor: grabbing;
}

.course-card.dragging {
    opacity: 0.4;
}

.course-card.placeholder {
    border-left-style: dashed;
    background: #f8f8f0;
}

.course-card.ap-credited {
    opacity: 0.55;
    cursor: default;
    background: #eef5e9;
}

.course-card.ap-credited .course-card-title {
    text-decoration: line-through;
}

.course-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-bottom: 2px;
}

.course-card-code {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 10px;
    color: #555;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.course-card-category {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    padding: 1px 5px;
    border: 1px solid #ccc;
    border-radius: 2px;
    line-height: 1.3;
    background: #fff;
    white-space: nowrap;
}

.course-card-title {
    font-weight: 600;
    color: #002b5c;
    line-height: 1.25;
}

.course-card-meta {
    font-size: 10px;
    color: #888;
    margin-top: 2px;
}

.course-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    margin-top: 4px;
    padding-top: 4px;
    border-top: 1px dotted #e0e0e0;
}

.course-card-ap {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    font-size: 10px;
    color: #666;
    font-weight: normal;
    cursor: pointer;
    user-select: none;
    flex: 1 1 auto;
    min-width: 0;
}

.course-card-ap input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.course-card-icon-btn {
    flex: 0 0 auto;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 3px;
    color: #999;
    font-size: 12px;
    line-height: 1;
    padding: 2px 6px;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.15s, background 0.15s, color 0.15s, border-color 0.15s;
}

.course-card:hover .course-card-icon-btn {
    opacity: 1;
}

.course-card-icon-btn:hover,
.course-card-icon-btn:focus {
    background: rgba(0, 43, 92, 0.08);
    color: #002b5c;
    border-color: rgba(0, 43, 92, 0.25);
    outline: none;
}

.course-card-dup {
    font-size: 11px;
}

/* Customized cards get a subtle marker on the left border */
.course-card.customized {
    box-shadow: inset 2px 0 0 #b18d03;
}

/* Inline edit form */
.course-card.editing {
    cursor: default;
    background: #fffdf3;
    border-color: #b18d03;
}

.course-edit-code,
.course-edit-title {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 4px 6px;
    margin-bottom: 4px;
    font-size: 12px;
    font-family: inherit;
    background: #fff;
}

.course-edit-code {
    font-family: "SF Mono", Menlo, Consolas, monospace;
    font-size: 11px;
}

.course-edit-credits-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: #666;
    margin-bottom: 4px;
    font-weight: normal;
}

.course-edit-credits {
    width: 56px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 3px;
    padding: 3px 6px;
    font-size: 12px;
    background: #fff;
}

.course-edit-credits:focus {
    outline: none;
    border-color: #b18d03;
    box-shadow: 0 0 0 2px rgba(177, 141, 3, 0.15);
}

.course-edit-actions .course-edit-delete {
    color: #a94442;
}

.course-edit-actions .course-edit-delete:hover {
    color: #7a1a1a;
    text-decoration: underline;
}

.course-edit-code:focus,
.course-edit-title:focus {
    outline: none;
    border-color: #b18d03;
    box-shadow: 0 0 0 2px rgba(177, 141, 3, 0.15);
}

.course-edit-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.course-edit-actions .btn-xs {
    font-size: 10px;
    padding: 2px 8px;
    line-height: 1.4;
}

.course-edit-actions .course-edit-reset {
    margin-left: auto;
    color: #888;
    padding: 2px 4px;
}

.course-edit-actions .course-edit-reset:hover {
    color: #a94442;
    text-decoration: underline;
}

/* Validation states */
.course-card.invalid {
    border-color: #a94442;
    background: #f2dede;
}
.course-card.invalid .course-card-title {
    color: #a94442;
}

/* AP / Transfer Credit region: strip above the plan grid that holds
   courses marked as AP/transfer so they don't clutter the palette. */
#ap-region {
    border: 2px dashed #b18d03;
    border-radius: 10px;
    padding: 10px 14px 12px;
    background: #fdf7e2;
    margin-bottom: 24px;
}

.ap-region-label {
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #8a6d1f;
    margin-bottom: 8px;
}

#ap-region-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
}

#ap-region-cards .course-card {
    width: 220px;
    flex: 0 0 auto;
    cursor: default;
}

.ap-region-empty {
    font-size: 12px;
    font-style: italic;
    color: #8a6d1f;
    padding: 6px 2px;
}

/* Plan grid: outer 2x2 of year-blocks, each year-block is a 2-col
   (Fall, Spring) inner grid. Larger gap between year-blocks than within. */
#plan-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 40px;
    row-gap: 30px;
}

.year-block {
    border: 3px solid #ccc;
    border-radius: 10px;
    padding: 14px 16px 16px;
    background: #fafafa;
}

.year-label {
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #002b5c;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0, 43, 92, 0.15);
}

.year-semesters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* Pastel year colors: Freshman (sky blue), Sophomore (mint),
   Junior (butter yellow), Senior (rose). */
.year-block.year-1 { background: #eaf4fb; border-color: #a8cfe6; }
.year-block.year-1 .year-label { color: #2c5d7e; border-bottom-color: rgba(44, 93, 126, 0.25); }

.year-block.year-2 { background: #ecf7ef; border-color: #aed9bf; }
.year-block.year-2 .year-label { color: #2f6b48; border-bottom-color: rgba(47, 107, 72, 0.25); }

.year-block.year-3 { background: #fbf6e1; border-color: #e8d896; }
.year-block.year-3 .year-label { color: #8a6d1f; border-bottom-color: rgba(138, 109, 31, 0.25); }

.year-block.year-4 { background: #fbecef; border-color: #e7b6c0; }
.year-block.year-4 .year-label { color: #8a3a4d; border-bottom-color: rgba(138, 58, 77, 0.25); }

.semester-slot {
    border: 2px dashed #ccc;
    border-radius: 4px;
    padding: 8px;
    background: #fff;
    transition: background 0.15s, border-color 0.15s;
}

.course-slots {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 4px;
}

.course-slot-empty {
    border: 1px dashed #d5d5d5;
    border-radius: 3px;
    padding: 6px 8px;
    font-size: 10px;
    color: #bbb;
    text-align: center;
    font-style: italic;
    background: #fdfdfd;
    min-height: 28px;
    line-height: 16px;
}

.course-slot-empty.drag-over {
    background: #eef4ff;
    border-color: #002b5c;
    color: #002b5c;
}

.course-card.drag-over {
    outline: 2px solid #002b5c;
    outline-offset: 1px;
}

.semester-label {
    font-size: 10px;
    text-transform: uppercase;
    color: #888;
    margin-bottom: 5px;
    text-align: center;
}

.semester-credits {
    font-size: 10px;
    color: #888;
    text-align: right;
    margin-top: 4px;
    border-top: 1px dotted #ddd;
    padding-top: 3px;
}

.semester-credits.over-limit {
    color: #a94442;
    font-weight: bold;
}

/* Tooltip for validation errors */
.course-card[data-error]:hover::after {
    content: attr(data-error);
    position: absolute;
    top: 100%;
    left: 0;
    right: auto;
    margin-top: 4px;
    background: #a94442;
    color: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 11px;
    z-index: 100;
    max-width: 260px;
    width: max-content;
    white-space: normal;
    overflow-wrap: break-word;
    line-height: 1.35;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
