body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    background-color: #f8f9fa;
    color: #343a40;
    padding: 20px 0;
}

.container {
    max-width: 95%;
    margin: 0 auto;
    background: #ffffff;
    padding: 25px;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    position: relative;
    z-index: 1;
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2.2em;
    font-weight: 700;
}

.planner-header-info {
    background-color: #eef1f5;
    padding: 20px;
    margin-bottom: 30px;
    border-radius: 8px;
    border: 1px solid #d6dde7;
    text-align: left;
    font-size: 0.95em;
    line-height: 1.7;
}

.planner-header-info p {
    margin-top: 0;
    margin-bottom: 12px;
    color: #495057;
}
.planner-header-info p:last-child {
    margin-bottom: 0;
}

.planner-header-info a {
    color: #007bff;
    font-weight: 500;
    text-decoration: none;
}
.planner-header-info a:hover {
    text-decoration: underline;
    color: #0056b3;
}

.planner-header-info strong {
    color: #c0392b;
    font-weight: 600;
}

.controls { display: flex; justify-content: center; gap: 15px; margin-bottom: 30px; padding: 18px; background-color: #e9ecef; border-radius: 8px; box-shadow: inset 0 1px 4px rgba(0,0,0,0.07); }
.controls button { padding: 12px 25px; font-size: 1em; font-weight: 600; border: none; border-radius: 6px; cursor: pointer; transition: background-color 0.2s ease, transform 0.1s ease; display: flex; align-items: center; }
.controls button:not(.warn-btn) { background-color: #007bff; color: white; }
.controls button:not(.warn-btn):hover { background-color: #0056b3; transform: translateY(-2px); }
.controls button:not(.warn-btn):active { transform: translateY(0); }
.controls .warn-btn { background-color: #dc3545; color: white; }
.controls .warn-btn:hover { background-color: #c82333; transform: translateY(-2px); }
.controls .warn-btn:active { transform: translateY(0); }

#planner-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 25px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
}

.semester-row {
    background-color: #ffffff;
    padding: 0 0 0 20px;
    display: flex;
    align-items: center;
    gap: 25px;
}

.semester-row:not(:last-child) {
    border-bottom: 1px solid #dee2e6;
}

.semester-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    flex-shrink: 0;
    padding: 10px 0;
}
.semester-title { font-size: 1.4em; font-weight: 700; color: #212529; }
.semester-controls { display: flex; align-items: center; gap: 15px; }
.semester-credits { font-size: 1em; color: #495057; font-weight: 500; }
.semester-controls button { background: none; border: none; color: #6c757d; cursor: pointer; font-size: 1.1em; padding: 5px; border-radius: 4px; transition: color 0.2s, background-color 0.2s; }
.semester-controls button:hover { color: #dc3545; background-color: #f8d7da; }

.semester-courses-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    min-height: auto;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px dashed #ced4da;
    padding: 15px 20px 15px 15px;
    flex-grow: 1;
}

.course-slot {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px 15px;
    box-sizing: border-box;
    position: relative;
    cursor: grab;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease, transform 0.1s ease;
    flex-shrink: 0;
}
.course-slot:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.08); transform: translateY(-2px); }
.course-slot:active { cursor: grabbing; transform: translateY(0); }
.course-slot.conflict { border-left: 5px solid #dc3545; background-color: #f8d7da; }
.course-header { display: flex; justify-content: space-between; align-items: flex-start; font-weight: 700; font-size: 1em; color: #212529; margin-bottom: 5px; }
.course-header-icons { display: flex; gap: 8px; align-items: center; }

.course-title {
    font-size: 0.9em;
    color: #495057;
    flex-grow: 1;
    margin-bottom: 8px;
    line-height: 1.4;
    white-space: nowrap;
}
.course-credits { font-size: 0.85em; color: #6c757d; align-self: flex-end; font-weight: 500; }
.remove-btn, .info-icon, .warning-icon { cursor: pointer; font-size: 1em; padding: 3px; border-radius: 3px; transition: color 0.2s, background-color 0.2s; }
.remove-btn { color: #6c757d; }
.remove-btn:hover { color: #dc3545; background-color: rgba(220, 53, 69, 0.1); }
.info-icon { color: #007bff; }
.info-icon:hover { color: #0056b3; background-color: rgba(0, 123, 255, 0.1); }
.warning-icon { display: none; color: #dc3545; }
.course-slot.conflict .warning-icon { display: inline-block; }

.add-course-to-semester-slot {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8em;
    color: #28a745;
    cursor: pointer;
    border: 2px dashed #28a745;
    background-color: #d4edda;
    min-width: 60px;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 8px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    flex-shrink: 0;
}
.add-course-to-semester-slot:hover { background-color: #c3e6cb; border-color: #218838; }

#add-semester-btn { display: flex; align-items: center; justify-content: center; margin: 30px auto; padding: 15px 30px; font-size: 1.1em; font-weight: 600; background-color: #17a2b8; color: white; border: none; border-radius: 8px; cursor: pointer; transition: background-color 0.2s ease, transform 0.1s ease; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
#add-semester-btn:hover { background-color: #138496; transform: translateY(-2px); }
#add-semester-btn:active { transform: translateY(0); }

#summary { text-align: right; font-weight: bold; font-size: 1.2em; margin-top: 30px; padding-top: 20px; border-top: 1px solid #e9ecef; color: #212529; }

.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6); }
.modal-content { background-color: #fefefe; margin: 10% auto; padding: 30px; border: 1px solid #adb5bd; width: 90%; max-width: 600px; border-radius: 10px; position: relative; box-shadow: 0 8px 25px rgba(0,0,0,0.25); }
.close-button { color: #6c757d; float: right; font-size: 32px; font-weight: bold; line-height: 1; cursor: pointer; transition: color 0.2s; }
.close-button:hover, .close-button:focus { color: #212529; text-decoration: none; }
#courseSearch { width: calc(100% - 24px); padding: 12px; margin-bottom: 20px; border: 1px solid #ced4da; border-radius: 6px; font-size: 1em; }
#courseList { list-style-type: none; padding: 0; max-height: 400px; overflow-y: auto; border: 1px solid #e9ecef; border-radius: 6px; background-color: #fff; }
#courseList li { padding: 12px 18px; border-bottom: 1px solid #f0f2f5; cursor: pointer; transition: background-color 0.2s; font-size: 0.95em; color: #495057; }
#courseList li:hover { background-color: #e9ecef; }
#courseList li:last-child { border-bottom: none; }

#custom-tooltip { position: absolute; background-color: #343a40; color: white; padding: 12px 18px; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.25); z-index: 3000; font-size: 0.9em; line-height: 1.5; max-width: 320px; opacity: 0; transition: opacity 0.2s ease-in-out; pointer-events: none; display: none; }
#custom-tooltip.custom-tooltip-visible { display: block; opacity: 1; }
.custom-tooltip-hidden { display: none !important; opacity: 0 !important; }
#custom-tooltip h4 { margin-top: 0; margin-bottom: 10px; font-size: 1.1em; color: #f8f9fa; border-bottom: 1px solid #495057; padding-bottom: 8px; }
#custom-tooltip ul { list-style-type: none; padding-left: 0; margin-bottom: 0; }
#custom-tooltip ul li { padding: 4px 0; }

.sortable-ghost { opacity: 0.4; background: #e6f7ff; border: 1px dashed #99d6ff; }
.sortable-chosen { cursor: grabbing !important; box-shadow: 0 6px 20px rgba(0,0,0,0.15); transform: scale(1.05); }

.back-link {
    position: absolute;
    top: 25px;
    left: 25px;
    text-decoration: none;
    color: #495057;
    font-weight: 600;
    font-size: 1rem;
    z-index: 10;
    transition: color 0.2s ease;
}

.back-link:hover {
    text-decoration: underline;
    color: #007bff;
}


@media screen and (max-width: 768px) {
    body {
        padding: 10px 0;
    }

    .container {
        padding: 15px;
        max-width: 100%;
    }

    h1 {
        font-size: 1.8em;
    }
    
    .planner-header-info {
        padding: 15px;
    }

    .controls {
        flex-wrap: wrap;
        padding: 15px;
    }
    
    .back-link {
        top: 15px;
        left: 15px;
        padding: 5px;
    }

    .semester-row {
        flex-direction: column;
        align-items: stretch;
        padding: 15px;
        gap: 15px;
    }

    .semester-header {
        align-items: center;
        padding: 0;
        width: 100%;
    }

    .semester-courses-container {
        padding: 15px;
        min-height: 100px;
    }

    .course-title {
        white-space: normal;
    }
    
    .course-slot {
        flex-grow: 1;
    }

    #summary {
        text-align: center;
    }

    .modal-content {
        width: 95%;
        margin: 20px auto;
        padding: 20px;
    }
}