/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f5f5f5;
    color: #333;
    overflow-x: hidden;
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
    padding: 8px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    flex-wrap: wrap;
    gap: 8px;
}
.toolbar-left, .toolbar-center, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.app-title {
    font-size: 16px;
    font-weight: 700;
    color: #4285F4;
    margin-right: 12px;
}
.toolbar button {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
    white-space: nowrap;
}
.toolbar button:hover {
    background: #f0f4ff;
    box-shadow: 0 1px 3px rgba(66,133,244,0.15);
}
.checkbox-label, .zoom-label {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #555;
}
#zoomSlider { width: 100px; }

/* ===== Dropdown ===== */
.dropdown { position: relative; display: inline-block; }
.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    background: #fff;
    min-width: 180px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    border-radius: 8px;
    z-index: 100;
    overflow: hidden;
}
.dropdown:hover .dropdown-content { display: block; }
.dropdown-content a {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: #333;
    font-size: 13px;
    transition: background 0.1s;
}
.dropdown-content a:hover { background: #f0f4ff; }

/* ===== Tabs ===== */
.tabs {
    display: flex;
    background: #fff;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 16px;
}
.tab {
    padding: 10px 20px;
    border: none;
    background: none;
    font-size: 14px;
    font-weight: 500;
    color: #888;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.tab:hover { color: #4285F4; }
.tab.active {
    color: #4285F4;
    border-bottom-color: #4285F4;
    font-weight: 600;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Schedule ===== */
.schedule-wrapper {
    padding: 16px;
    overflow: auto;
    position: relative;
}
#scheduleCanvas {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    cursor: crosshair;
}

/* ===== ECTS Table ===== */
.ects-toolbar {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.ects-toolbar button {
    padding: 6px 14px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
}
.ects-toolbar button:hover { background: #f0f4ff; }

.categories-bar {
    padding: 4px 16px 8px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.cat-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #e8f0fe;
    color: #4285F4;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}
.cat-badge .remove-cat {
    cursor: pointer;
    font-size: 14px;
    color: #c00;
    margin-left: 2px;
}
.cat-badge .remove-cat:hover { color: #f00; }

.ects-table-wrapper {
    padding: 0 16px 16px;
    overflow-x: auto;
}
#ectsTable {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
#ectsTable th {
    background: #f0f4ff;
    padding: 10px 12px;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: #4285F4;
    border-bottom: 2px solid #dde5f7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#ectsTable th:first-child,
#ectsTable th:nth-child(2) {
    text-align: left;
}
#ectsTable td {
    padding: 6px 10px;
    border-bottom: 1px solid #eee;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
}
#ectsTable tr:nth-child(even) td { background: #fafafa; }
#ectsTable input[type="text"],
#ectsTable input[type="number"] {
    width: 100%;
    border: 1px solid transparent;
    padding: 4px 6px;
    font-size: 13px;
    border-radius: 4px;
    transition: border-color 0.15s;
    background: transparent;
}
#ectsTable input:focus {
    outline: none;
    border-color: #4285F4;
    background: #fff;
}
#ectsTable input[type="number"] { width: 100%; text-align: center; }
#ectsTable td.num-cell { text-align: center; }
#ectsTable .delete-btn {
    background: none;
    border: none;
    color: #c00;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}
#ectsTable .delete-btn:hover { background: #fee; }
#ectsTable tfoot td {
    background: #f0f7ff;
    font-weight: 600;
    border-top: 2px solid #dde5f7;
}

/* ===== Modal ===== */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}
.modal-header h3 { font-size: 16px; color: #333; }
.close-btn {
    background: none;
    border: none;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    padding: 0 4px;
}
.close-btn:hover { color: #333; }
.modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.modal-body label {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-top: 4px;
}
.modal-body input, .modal-body select, .modal-body textarea {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus {
    outline: none;
    border-color: #4285F4;
}
.time-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.time-inputs {
    display: flex;
    align-items: center;
    gap: 4px;
}
.time-inputs select { flex: 1; }
.time-inputs span { font-size: 16px; font-weight: bold; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #eee;
}
.btn-primary {
    padding: 8px 20px;
    background: #4285F4;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary:hover { background: #3367d6; }
.btn-secondary {
    padding: 8px 20px;
    background: #f5f5f5;
    color: #555;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.btn-secondary:hover { background: #eee; }

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
    z-index: 300;
    overflow: hidden;
    min-width: 160px;
}
.context-item {
    padding: 10px 16px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.1s;
}
.context-item:hover { background: #f0f4ff; }
.context-item.danger { color: #c00; }
.context-item.danger:hover { background: #fee; }
.context-menu hr { border: none; border-top: 1px solid #eee; margin: 0; }

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 999;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}
.toast.success { background: #34A853; }
.toast.error { background: #EA4335; }
.toast.info { background: #4285F4; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .toolbar { padding: 6px 10px; }
    .toolbar-center { display: none; }
    .app-title { font-size: 14px; }
    .modal-content { width: 95vw; }
    .schedule-wrapper { padding: 8px; }
}

/* Combo input */
.combo-input { position: relative; }
.combo-input input { width: 100%; }
