/* --- Base and Layout --- */
:root {
    --header-bg: linear-gradient(90deg, #43cea2 0%, #185a9d 100%);
    --primary-action-bg: #185a9d; --primary-action-hover: #43cea2;
    --bg-light: #f4f7f6; --bg-white: #ffffff; --text-dark: #333;
    --text-light: #fff; --border-color: #e0e0e0; --shadow: 0 4px 12px rgba(0,0,0,0.08);
}
body { margin: 0; padding-top: 65px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg-light); color: var(--text-dark); }
.container { max-width: 1400px; margin: 20px auto; padding: 0 15px; }

/* --- Header --- */
.main-header { display: flex; align-items: center; background: var(--header-bg); padding: 0 16px; color: var(--text-light); position: fixed; top: 0; left: 0; right: 0; height: 65px; z-index: 1000; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.main-header h1 { flex: 1; text-align: center; margin: 0; font-size: 1.4rem; font-weight: 600; }
.home-btn, .github-btn { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text-light); font-weight: 500; background: rgba(255,255,255,0.1); padding: 8px 12px; border-radius: 100px; transition: background 0.2s; white-space: nowrap; }
.home-btn:hover, .github-btn:hover { background: rgba(255,255,255,0.2); }

/* --- Controls & Setup Section --- */
#controls-section { background: var(--bg-white); padding: 20px; border-radius: 12px; box-shadow: var(--shadow); margin-bottom: 30px; }
.top-controls { display: flex; justify-content: flex-end; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); padding-bottom: 20px; }
#recover-btn { background: #eef; color: var(--primary-action-bg); border: 1px solid #ccd; padding: 10px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
#recover-btn:hover { background: #dde; }
.control-group { margin-bottom: 20px; }
.group-title { font-size: 1.2rem; font-weight: 600; color: var(--text-dark); border-bottom: 2px solid var(--primary-action-bg); padding-bottom: 8px; margin-bottom: 15px; display: block; }
.form-row, #event-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 15px; }
#controls-section label { display: flex; flex-direction: column; font-weight: 500; font-size: 0.9rem; flex-grow: 1; min-width: 150px; }
#controls-section input, #controls-section select { margin-top: 5px; padding: 10px; border-radius: 6px; border: 1px solid var(--border-color); font-size: 1rem; background: #f9f9f9; width: 100%; box-sizing: border-box; }
#controls-section input[type="file"] { padding: 8px; }
#controls-section input[type="color"] { padding: 2px; height: 44px; width: 44px; min-width: 44px; }
#controls-section button { padding: 10px 22px; background: var(--primary-action-bg); color: var(--text-light); border: none; border-radius: 6px; font-weight: 600; cursor: pointer; transition: background 0.2s; height: 44px; }
#controls-section button:hover { background: var(--primary-action-hover); }

/* Image Preview Styles */
#image-preview-container { position: relative; margin-top: 10px; max-width: 300px; }
#image-preview { max-width: 100%; border-radius: 8px; border: 1px solid var(--border-color); }
#remove-image-btn { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0,0,0,0.6); color: white; border: none; font-size: 16px; line-height: 24px; text-align: center; cursor: pointer; }

.time-input-wrapper { display: flex; align-items: center; gap: 5px; }
.time-input-wrapper input { flex-grow: 1; }
.time-picker-btn { height: 44px; width: 44px; min-width: 44px; padding: 0; background: none; border: none; cursor: pointer; color: var(--primary-action-bg); opacity: 0.7; transition: opacity 0.2s; display: flex; align-items: center; justify-content: center; }
.time-picker-btn:hover { opacity: 1; }

/* --- Timetable Display Section --- */
#timetable-display { background: var(--bg-white); padding: 20px; border-radius: 12px; box-shadow: var(--shadow); }
.display-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 15px; margin-bottom: 20px; }
.display-header h2 { margin: 0; }
.table-controls { display: flex; gap: 10px; flex-wrap: wrap; }
.table-controls button { background: #eef; color: var(--primary-action-bg); border: 1px solid #ccd; padding: 8px 16px; border-radius: 6px; font-weight: 500; cursor: pointer; transition: all 0.2s; }
.table-controls button:hover { background: #dde; }
.table-controls button.primary-action { background: var(--primary-action-bg); color: var(--text-light); font-weight: bold; border: none; }
.table-controls button.primary-action:hover { background: var(--primary-action-hover); }
.table-controls button:disabled { background: #ccc; cursor: not-allowed; }
#empty-message { text-align: center; color: #888; font-size: 1.2rem; padding: 40px 0; }

#timetable-grid-container { overflow-x: auto; }
.week-grid { margin-bottom: 30px; min-width: 800px; page-break-inside: avoid; }
.week-title { font-size: 1.2rem; color: var(--primary-action-bg); }
.timetable-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.timetable-table th { background: #f2f2f2; padding: 10px; font-weight: 600; text-align: left; border-bottom: 2px solid var(--border-color); }
.timetable-table th .date-number { font-size: 0.85rem; font-weight: 400; color: #666; margin-left: 8px; background: #e7e7e7; padding: 2px 5px; border-radius: 4px; }
.timetable-table td { border: 1px solid var(--border-color); vertical-align: top; height: 100px; padding: 5px; }
.event-block { color: white; padding: 8px; border-radius: 6px; font-size: 0.85rem; margin-bottom: 5px; position: relative; box-shadow: 0 2px 4px rgba(0,0,0,0.15); transition: transform 0.2s; overflow: hidden; page-break-inside: avoid; }
.event-block:hover { transform: scale(1.03); z-index: 10; }
.event-content { display: flex; flex-direction: column; }
.event-content strong, .event-content span, .event-content em { word-wrap: break-word; }
.delete-event-btn { position: absolute; top: 2px; right: 4px; border: none; background: rgba(0,0,0,0.2); color: white; border-radius: 50%; width: 18px; height: 18px; cursor: pointer; font-size: 14px; line-height: 18px; text-align: center; opacity: 0; transition: opacity 0.2s; }
.event-block:hover .delete-event-btn { opacity: 1; }

#extra-notes-container { margin-top: 20px; page-break-inside: avoid; }
#extra-notes { width: 100%; box-sizing: border-box; min-height: 100px; padding: 10px; border-radius: 6px; border: 1px solid var(--border-color); font-size: 1rem; }
footer { text-align: center; padding: 20px; color: #888; border-top: 1px solid #e0e0e0; margin-top: 30px; }
footer a { color: var(--primary-action-bg); text-decoration: none; font-weight: 500; }

.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 2000; display: flex; align-items: center; justify-content: center; }
.modal-content { background: var(--bg-white); padding: 25px; border-radius: 12px; box-shadow: 0 5px 15px rgba(0,0,0,0.3); width: 90%; max-width: 400px; }
.modal-content h3 { margin-top: 0; }
.time-picker-row { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.hidden { display: none !important; }

.no-print { display: none !important; }

@media (max-width: 768px) {
    .main-header { padding: 0 8px; }
    .main-header h1 { font-size: 1.2rem; }
    .github-text, .home-text { display: none; }
    .home-btn, .github-btn { padding: 8px; }
    #controls-section, #timetable-display { padding: 15px; }
    .display-header { flex-direction: column; align-items: flex-start; }
}
