@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@400;700&display=swap');

body {
    font-family: 'Noto Sans TC', sans-serif;
    background-color: #f0f2f5;
    color: #333;
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
}

.wrapper {
    display: flex;
    gap: 20px;
    width: 100%;
    max-width: 1200px;
    align-items: stretch; /* Change to stretch for equal height */
}

.left-panel {
    flex: 1;
    min-width: 400px;
    display: flex; /* For equal height */
}

.container {
    flex: 1; /* Make it flexible */
    width: 100%;
    max-width: 600px;
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px 30px;
    display: flex; /* For equal height */
    flex-direction: column;
}

#calendar-container {
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 20px;
    width: 100%;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.calendar-header h2 {
    margin: 0;
    font-size: 1.5em;
    color: #0056b3;
}

.calendar-header button {
    background: none;
    border: 1px solid #ccc;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    font-size: 1.2em;
}

.calendar-weekdays, .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    text-align: center;
}

.calendar-weekdays {
    font-weight: bold;
    color: #555;
    padding-bottom: 10px;
}

.calendar-grid {
    gap: 5px;
}

.calendar-day {
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    min-height: 100px;
    font-size: 0.9em;
    display: flex;
    flex-direction: column;
}

.calendar-day.not-current-month {
    color: #ccc;
    background-color: #f9f9f9;
}

.calendar-day .day-number {
    font-weight: bold;
    margin-bottom: 5px;
}

.calendar-day.today .day-number {
    color: #fff;
    background-color: #0056b3;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

.calendar-day.event-day {
    background-color: #e6f7ff;
}

.player-list-calendar {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8em;
    text-align: left;
}

.player-list-calendar li {
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 2px 4px;
    border-radius: 3px;
    color: #fff;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
}

header {
    text-align: center;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

header h1 {
    color: #0056b3;
    margin: 0;
}

header p {
    margin: 5px 0;
    color: #555;
}

#event-date {
    font-weight: bold;
    font-size: 1.1em;
    color: #d93025;
}

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

#signup-section, #player-list-section {
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
}

h2 {
    margin-top: 0;
    color: #0056b3;
    border-bottom: 2px solid #0056b3;
    padding-bottom: 5px;
    display: inline-block;
}

#status {
    font-size: 1.1em;
    font-weight: bold;
    margin-bottom: 15px;
}

.signup-form {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#name-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
}

#count-select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    background-color: #fff;
}

#signup-button {
    padding: 12px;
    font-size: 1.1em;
    font-weight: bold;
    color: #fff;
    background-color: #28a745;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

#signup-button:hover {
    background-color: #218838;
}

#signup-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#deadline-text {
    font-size: 0.9em;
    color: #777;
    text-align: center;
    margin-top: 10px;
}

#quick-names-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.quick-name-button {
    padding: 5px 10px;
    border: 1px solid #ccc;
    border-radius: 20px;
    background-color: #f0f0f0;
    cursor: pointer;
    transition: background-color 0.3s;
}

.quick-name-button:hover {
    background-color: #e0e0e0;
}

#history-controls {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}

#clear-history-button {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 0.8em;
    text-decoration: underline;
}

#clear-history-button:hover {
    color: #dc3545;
}

#player-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

#player-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #dee2e6;
}

#player-list li:last-child {
    border-bottom: none;
}

.player-name {
    font-weight: bold;
    margin-right: auto;
}

.player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.count-display {
    font-weight: bold;
    min-width: 40px;
    text-align: center;
}

.adjust-button {
    padding: 3px 8px;
    font-size: 1em;
    font-weight: bold;
    color: #fff;
    background-color: #17a2b8;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.cancel-button {
    padding: 5px 10px;
    font-size: 0.9em;
    color: #fff;
    background-color: #dc3545;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.cancel-button:hover {
    background-color: #c82333;
}

footer {
    text-align: center;
    margin-top: auto; /* Push footer to the bottom */
    padding-top: 20px;
    font-size: 0.9em;
    color: #888;
}

/* --- Participant Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    display: none; /* Hidden by default */
}

.modal-content {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    max-width: 450px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    transform: translateY(-20px);
    opacity: 0;
    transition: all 0.3s ease-out;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
    opacity: 1;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.modal-header h3 {
    margin: 0;
    color: #0056b3;
    font-size: 1.4em;
}

.modal-close-button {
    background: none;
    border: none;
    font-size: 2em;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

.modal-close-button:hover {
    color: #333;
}

.modal-player-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.modal-player-list li {
    padding: 8px 0;
    border-bottom: 1px dashed #eee;
    font-size: 1.1em;
    color: #555;
}

.modal-player-list li:last-child {
    border-bottom: none;
}


/* --- Responsive Design --- */
@media (max-width: 992px) {
    .wrapper {
        flex-direction: column;
        align-items: center;
    }

    .left-panel, .container {
        width: 100%;
        max-width: 600px; /* Same max-width for both on smaller screens */
    }

    .container {
        order: 1; /* Show signup form first */
    }

    .left-panel {
        order: 2; /* Show calendar second */
    }
}

@media (max-width: 768px) {
    #history-controls {
        justify-content: center;
        margin-bottom: 15px;
    }

    #clear-history-button {
        padding: 8px 12px;
        font-size: 0.9em;
    }

    body {
        padding: 10px;
    }

    .wrapper {
        gap: 10px;
    }

    .container, #calendar-container {
        padding: 15px;
    }

    .calendar-day {
        min-height: 80px;
    }

    .signup-form {
        flex-direction: column;
    }
}
