/* ===========================================
   SCHEDULER-STYLE.CSS - Program Layıcı Specific Styles
   Base styles are in base.css
   =========================================== */

/* --- Scheduler Section --- */
.scheduler-section {
    padding: 20px 0 80px 0;
}

/* --- Scheduler Container Grid --- */
.scheduler-container {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 40px;
    align-items: start;
    transition: grid-template-columns 0.4s ease-in-out, gap 0.4s ease-in-out;
}

/* --- Left Panel Styles --- */
.available-courses-panel {
    background-color: var(--bg-color-grey);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    position: sticky;
    top: 100px;
    height: fit-content;
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: hidden;
    width: 350px;
    min-width: 350px;
    transition: transform 0.4s ease-in-out, opacity 0.4s ease-in-out;
    transform: translateX(0);
    opacity: 1;
}

.available-courses-panel h2 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.selection-step {
    margin-bottom: 1.5rem;
}

.selection-step label {
    display: block;
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.search-select-wrapper {
    position: relative;
}

#subject-search-input,
#subject-prefix-select,
#specific-course-select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    background-color: white;
    box-sizing: border-box;
}

#subject-search-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    color: var(--text-color-dark);
    background-color: #fff;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

#subject-prefix-select {
    position: relative;
    z-index: 1;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    margin-top: -1px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 1em;
    padding-right: 2.5em;
}

#subject-search-input:focus,
#subject-prefix-select:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(6, 42, 84, 0.1);
}

#crn-section-list-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--bg-color-light);
}

.placeholder-text {
    padding: 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.crn-section-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

.crn-section-item:last-child {
    border-bottom: none;
}

.crn-section-item:hover {
    background-color: var(--bg-color-grey);
}

.crn-info {
    display: flex;
    flex-direction: column;
}

.crn-info strong {
    color: var(--primary-color);
}

.crn-info span {
    font-size: 0.9rem;
    color: #555;
}

.add-course-btn {
    padding: 8px 16px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.add-course-btn:disabled {
    background-color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
}

/* --- Added Courses List --- */
.panel-divider {
    border: none;
    height: 1px;
    background-color: var(--border-color);
    margin: 2rem 0;
}

.added-courses-section h3 {
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

#added-courses-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

#added-courses-list li {
    background-color: var(--bg-color-grey);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: var(--transition);
}

#added-courses-list li:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#added-courses-list .placeholder-text {
    text-align: center;
    color: #888;
    font-style: italic;
    padding: 1rem;
    background-color: transparent;
    border: none;
}

#added-courses-list .course-info-text {
    font-size: 0.9rem;
    color: var(--text-color-dark);
}

#added-courses-list .drop-button {
    background-color: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

#added-courses-list .drop-button:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}

/* --- Visual Schedule Grid --- */
.schedule-wrapper {
    max-width: 100%;
    margin: 1rem 0;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.schedule-container {
    display: grid;
    grid-template-columns: 80px repeat(5, 1fr);
    --hour-height: 60px;
}

.schedule-header {
    display: contents;
}

.day-header {
    background-color: var(--primary-color);
    padding: 15px 5px;
    text-align: center;
    font-weight: 600;
    color: var(--text-color-light);
    border-right: 1px solid #dee2e6;
    border-bottom: 1px solid #dee2e6;
}

.day-header:first-of-type {
    grid-column: 2;
}

.day-header:last-of-type {
    border-right: none;
}

.schedule-body {
    display: contents;
}

.time-labels {
    grid-column: 1;
    position: relative;
    border-right: 1px solid #dee2e6;
    background-color: #fafafa;
}

.time-slot {
    position: absolute;
    width: 100%;
    text-align: right;
    padding-right: 10px;
    box-sizing: border-box;
    font-size: 0.75em;
    color: var(--text-muted);
    transform: translateY(-50%);
}

.time-slot.half-hour {
    font-size: 0.7em;
    color: #adb5bd;
}

.grid-container {
    position: relative;
    grid-column: 2 / -1;
}

.grid-line {
    position: absolute;
    left: 0;
    right: 0;
    border-bottom: 1px solid var(--border-color);
}

.grid-line.half-hour-line {
    border-bottom: 1px dashed var(--border-color);
}

.vertical-line {
    position: absolute;
    top: 0;
    bottom: 0;
    border-right: 1px solid #f1f3f5;
    z-index: 0;
}

/* --- Schedule Event --- */
.event {
    position: absolute;
    padding: 8px;
    margin: 0 4px;
    border-radius: 4px;
    font-size: 0.85em;
    color: white;
    overflow: hidden;
    box-sizing: border-box;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.event:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 20;
}

.event-title {
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.event-time {
    font-size: 0.8em;
    opacity: 0.9;
}

.event-crn {
    font-size: 0.8em;
    font-weight: 600;
    opacity: 0.9;
}

.event-location {
    font-size: 0.7em;
    opacity: 0.8;
    margin-top: 2px;
}

.event-mon {
    left: 0%;
    width: 20%;
}

.event-tue {
    left: 20%;
    width: 20%;
}

.event-wed {
    left: 40%;
    width: 20%;
}

.event-thu {
    left: 60%;
    width: 20%;
}

.event-fri {
    left: 80%;
    width: 20%;
}

/* --- Panel Toggle Button --- */
.panel-toggle-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 10;
    padding: 5px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: var(--transition);
}

.panel-toggle-btn:hover {
    color: var(--primary-color);
    background-color: #f0f0f0;
}

.open-panel-btn {
    position: fixed;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    background-color: var(--primary-color);
    color: var(--text-color-light);
    border: none;
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    padding: 10px 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    z-index: 1000;
    transition: var(--transition);
    opacity: 0;
    visibility: hidden;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.open-panel-btn.visible {
    opacity: 1;
    visibility: visible;
}

.open-panel-btn:hover {
    background-color: var(--primary-color-light);
    padding-right: 12px;
}

/* --- Panel Closed State --- */
.scheduler-container.panel-closed {
    grid-template-columns: 0px 1fr;
    gap: 0;
}

.scheduler-container.panel-closed .available-courses-panel {
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    min-width: 0;
    width: 0;
    padding: 0;
    border: none;
}

.schedule-table-wrapper {
    transition: margin-top 0.4s ease-in-out;
    margin-top: 0;
}

.scheduler-container.panel-closed .schedule-table-wrapper {
    margin-top: -2rem;
}

/* --- Custom Searchable Dropdown --- */
.custom-dropdown-wrapper {
    position: relative;
    width: 100%;
}

.dropdown-list {
    position: absolute;
    top: 105%;
    left: 0;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background-color: white;
    border: 1px solid #eee;
    border-radius: 8px;
    z-index: 1000;
    display: none;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.dropdown-list::-webkit-scrollbar {
    width: 8px;
}

.dropdown-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.dropdown-list::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.dropdown-list::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

.dropdown-item {
    padding: 12px 15px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-color-dark);
    border-bottom: 1px solid var(--bg-color-grey);
    transition: background-color 0.2s, color 0.2s;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background-color: var(--bg-color-grey);
    color: var(--secondary-color);
    font-weight: 500;
}

/* --- Responsive for Scheduler --- */
@media (max-width: 1024px) {
    .scheduler-container {
        grid-template-columns: 1fr;
    }

    .available-courses-panel {
        position: static;
        max-height: none;
        width: 100%;
        min-width: auto;
    }
}

/* Mobile Responsive for Schedule Grid */
@media (max-width: 768px) {
    .scheduler-section {
        padding: 15px 0 100px 0;
    }

    .page-title {
        font-size: 1.8rem;
    }

    /* Make schedule scrollable horizontally on mobile */
    .schedule-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .schedule-wrapper {
        min-width: 600px; /* Force minimum width for schedule table */
    }

    .schedule-container {
        --hour-height: 50px; /* Reduce hour height on mobile */
    }

    .day-header {
        font-size: 0.8rem;
        padding: 10px 3px;
    }

    .event {
        font-size: 0.75em;
        padding: 4px;
        margin: 0 2px;
    }

    .event-title {
        font-size: 0.85em;
    }

    .event-time,
    .event-crn,
    .event-location {
        font-size: 0.75em;
    }

    /* Panel adjustments for mobile */
    .available-courses-panel {
        padding: 1rem;
        border-radius: 8px;
    }

    .panel-toggle-btn {
        top: 5px;
        right: 5px;
        font-size: 0.8rem;
        padding: 4px 6px;
    }

    /* Open panel button adjustments */
    .open-panel-btn {
        top: auto;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%);
        border-radius: 8px;
        padding: 12px 20px;
        writing-mode: horizontal-tb;
        text-orientation: mixed;
        border: none;
    }

    .open-panel-btn:hover {
        transform: translateX(-50%) translateY(-2px);
        padding-right: 20px;
    }
}

@media (max-width: 480px) {
    .schedule-wrapper {
        min-width: 550px;
    }

    .event {
        font-size: 0.7em;
        padding: 3px;
    }

    .event-title {
        font-size: 0.8em;
    }

    .day-header {
        font-size: 0.7rem;
        padding: 8px 2px;
    }
}