@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
    /* Backlog-inspired Palette */
    --primary-color: #2C9A7A;
    /* Teal Green */
    --primary-hover: #227d63;
    --accent-color: #f17c67;
    /* Coral/Orange for accents */

    --bg-color: #f4f7f6;
    /* Very light cool gray/green */
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-secondary: #666666;

    --border-radius: 6px;
    /* Backlog uses slightly tighter radii than 8px often, but 6-8 is good */
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);

    --success: #2C9A7A;
    --warning: #f0ad4e;
    --danger: #d9534f;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 900px;
    margin: 40px auto;
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid #e1e8ed;
}

/* Typography */
h1 {
    font-size: 24px;
    color: var(--text-color);
    margin-bottom: 24px;
    text-align: center;
    border-bottom: none;
    font-weight: 700;
}

h2 {
    font-size: 20px;
    margin-top: 30px;
    margin-bottom: 15px;
    font-weight: 700;
    color: var(--text-color);
    border-left: 5px solid var(--primary-color);
    padding-left: 10px;
}

p {
    margin-bottom: 15px;
    color: var(--text-secondary);
}

/* Forms */
.form-group {
    margin-bottom: 24px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 14px;
    color: var(--text-color);
}

input[type="text"],
input[type="time"],
input[type="datetime-local"],
input[type="date"],
input[type="password"],
textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d4dbe0;
    border-radius: 4px;
    /* Backlog inputs are often squared or slightly rounded */
    font-size: 15px;
    background-color: #fbfcfd;
    transition: all 0.2s ease;
    font-family: inherit;
}

input:focus,
textarea:focus {
    border-color: var(--primary-color);
    background-color: #fff;
    box-shadow: 0 0 0 3px rgba(44, 154, 122, 0.1);
    outline: none;
}

/* Custom "Box" for Time Picker */
.time-picker-box {
    background-color: #e6f6f2;
    /* Light primary tint */
    border: 1px solid #ccece6;
    padding: 10px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
}

.time-picker-box label {
    color: #1b634d;
}

/* Buttons */
.btn-primary {
    display: inline-block;
    width: 100%;
    padding: 14px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    /* Pill shape is common in modern SaaS marketing sites */
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.3s, transform 0.1s;
    text-align: center;
    box-shadow: 0 4px 6px rgba(44, 154, 122, 0.2);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(1px);
    box-shadow: none;
}

button.btn-remove {
    background: #e9eaec;
    color: #666;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
    pointer-events: auto;
    position: relative;
    z-index: 100;
}

button.btn-remove:hover {
    background: #dcdde0;
    color: #333;
}

/* Candidate List Row */
.candidate-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
    background: #fff;
    padding: 12px 16px;
    border: 1px solid #eee;
    border-radius: var(--border-radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

/* Table Styles */
.schedule-table-wrapper {
    overflow-x: auto;
    border: 1px solid #eee;
    border-radius: var(--border-radius);
}

.schedule-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    font-size: 14px;
}

.schedule-table th,
.schedule-table td {
    border-bottom: 1px solid #f0f0f0;
    padding: 7px 8px;
    text-align: center;
    vertical-align: middle;
}

.schedule-table th {
    background-color: #fafbfc;
    font-weight: 700;
    color: #555;
    border-right: 1px solid #f0f0f0;
}

.schedule-table th.date-header {
    background-color: var(--primary-color);
    color: white;
    border-right: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 120px;
    line-height: 1.4;
}

.schedule-table tr:last-child td {
    border-bottom: none;
}

/* Sticky First Column */
.schedule-table th:first-child,
.schedule-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background-color: #fff;
    /* Ensure it covers scrolling content */
    border-right: 2px solid #e0e0e0;
    /* clearer separation */
    width: 120px;
    min-width: 120px;
    max-width: 120px;
}

/* Ensure header corner stays consistent */
.schedule-table th:first-child {
    background-color: #fafbfc;
    z-index: 2;
    /* Header should be above body sticky cells if vertical scroll exists, though table wrapper handles x-scroll */
}

.schedule-table .score-row td:first-child {
    background-color: #fff9f0;
    /* Match score row background */
}

/* Symbols */
.symbol-o {
    color: var(--success);
    font-size: 1.4em;
}

.symbol-tri {
    color: var(--warning);
    font-size: 1.4em;
}

.symbol-x {
    color: var(--danger);
    font-size: 1.4em;
}

.score-row {
    background-color: #fff9f0;
    /* Light orange tint for score row */
    font-weight: bold;
    color: #333;
}

.star-icon {
    color: #f17c67;
    /* Backlog-ish accent color */
    font-size: 1.2em;
    margin-left: 4px;
}

/* Two-column layout for desktop */
.calendar-candidate-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

/* Responsive */
@media (max-width: 600px) {
    body {
        font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        background-color: var(--bg-color);
        color: var(--text-color);
        line-height: 1.6;
        padding: 5px;
        -webkit-font-smoothing: antialiased;
        font-size: 14px;
    }

    input,
    textarea,
    select,
    button {
        font-size: 13px !important;
    }

    .schedule-table {
        font-size: 12px;
        table-layout: fixed !important;
        width: auto !important;
        min-width: 0 !important;
    }

    .answer-table {
        width: 100% !important;
    }

    .schedule-table th,
    .schedule-table td {
        border-bottom: 1px solid #f0f0f0;
        padding: 8px 5px;
        text-align: center;
        vertical-align: middle;
    }

    /* すべての列を80px固定に - 最優先 */
    .schedule-table th,
    .schedule-table td {
        width: 80px !important;
        min-width: 80px !important;
        max-width: 80px !important;
        box-sizing: border-box !important;
    }

    /* Allow answer table (participant) to be flexible or wider */
    .answer-table th:not(:first-child),
    .answer-table td:not(:first-child) {
        width: auto !important;
        min-width: auto !important;
        max-width: none !important;
    }

    .container {
        padding: 20px 15px;
        margin: 10px;
    }

    h1 {
        font-size: 18px;
    }

    h2 {
        font-size: 18px;
    }

    .btn-primary {
        font-size: 13px;
        padding: 10px;
    }

    /* Center calendar and ensure it fits */
    .calendar-section {
        display: flex;
        justify-content: center;
        width: 100%;
        max-width: 100%;
        margin-bottom: 20px;
        overflow: hidden;
    }

    #calendar_picker {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    /* Hide the Flatpickr input element that causes left margin */
    #calendar_picker.flatpickr-input {
        display: none !important;
    }

    .flatpickr-calendar {
        width: 100% !important;
        max-width: 100% !important;
        background: #fff !important;
        border: 1px solid #e1e8ed !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
        border-radius: var(--border-radius) !important;
    }

    .flatpickr-months {
        width: 100% !important;
    }

    .flatpickr-innerContainer {
        width: 100% !important;
    }

    .flatpickr-rContainer {
        width: 100% !important;
    }

    .flatpickr-days {
        width: 100% !important;
    }

    .flatpickr-weekdays {
        width: 100% !important;
    }

    .dayContainer {
        width: 100% !important;
        min-width: unset !important;
        max-width: unset !important;
    }

    .flatpickr-day {
        max-width: calc(100% / 7) !important;
        flex-basis: calc(100% / 7) !important;
        height: 40px !important;
        line-height: 40px !important;
        margin: 0 !important;
        font-size: 14px !important;
    }

    .flatpickr-weekday {
        font-size: 12px !important;
    }

    /* Reduce candidate date font size on mobile */
    .candidate-date {
        font-size: 14px !important;
    }

    /* Stack calendar and candidates vertically on mobile */
    .calendar-candidate-wrapper {
        grid-template-columns: 1fr;
    }

    /* Stack admin actions (deadline extend, delete) on mobile */
    .admin-actions-wrapper {
        flex-direction: column !important;
        gap: 30px !important;
    }

    .admin-actions-wrapper>div {
        text-align: left !important;
    }

    /* Reduce answer buttons size on mobile */
    .answer-options {
        gap: 4px !important;
    }

    .answer-options label {
        padding: 5px 10px !important;
        min-width: 40px !important;
        border-radius: 12px !important;
        /* Slightly smaller radius for visual scale */
    }

    .answer-options .symbol-o,
    .answer-options .symbol-tri,
    .answer-options .symbol-x {
        font-size: 1.1em !important;
    }
}

/* URL Section Styles */
.url-section {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

.url-input-container {
    display: flex;
    gap: 10px;
    align-items: center;
}

.url-input-container input {
    flex-grow: 1;
    margin-bottom: 0;
}

.btn-copy {
    white-space: nowrap;
    width: auto;
    padding: 12px 20px;
    display: inline-block;
    /* Reuse btn-primary styles but ensure sizing */
}

/* Custom Radio Buttons for Answer Form */
.answer-options {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.answer-options label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.15s ease;
    background: #fff;
    font-weight: 500;
    min-width: 60px;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    /* Remove mobile tap highlight */
    outline: none !important;
    /* Force remove outline */
}

@media (hover: hover) {
    .answer-options label:hover {
        border-color: var(--primary-color);
        background: #f0f9f6;
        transform: translateY(-1px);
    }
}

.answer-options label:active {
    transform: translateY(0);
}

.answer-options input[type="radio"] {
    display: none;
}

/* Fix for persistent focus style on click */
.answer-options input[type="radio"]:focus,
.answer-options input[type="radio"]:active {
    box-shadow: none !important;
    outline: none !important;
}

.answer-options .radio-label {
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
}

/* Specific colors for each option when selected */
.answer-options label:has(input[value="2"]:checked) {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.answer-options label:has(input[value="1"]:checked) {
    background: var(--warning);
    border-color: var(--warning);
    color: #333;
}

.answer-options label:has(input[value="0"]:checked) {
    background: #95a5a6;
    border-color: #95a5a6;
    color: white;
}

/* Override parent label styles when checked */
.answer-options label:has(input:checked) {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Symbol visibility and colors */
.answer-options .symbol-o,
.answer-options .symbol-tri,
.answer-options .symbol-x {
    font-size: 1.3em;
    font-weight: bold;
}

/* Unselected state - colorful symbols */
.answer-options label .symbol-o {
    color: var(--success);
}

.answer-options label .symbol-tri {
    color: var(--warning);
}

.answer-options label .symbol-x {
    color: #95a5a6;
}

/* Selected state - white/dark symbols for contrast */
.answer-options label:has(input[value="2"]:checked) .symbol-o {
    color: white !important;
}

.answer-options label:has(input[value="1"]:checked) .symbol-tri {
    color: #333 !important;
}

.answer-options label:has(input[value="0"]:checked) .symbol-x {
    color: white !important;
}

/* Footer Styles */
.footer {
    text-align: center;
    padding: 30px 20px;
    margin-top: 60px;
    border-top: 1px solid #e1e8ed;
    color: #666;
    font-size: 13px;
}

.footer a {
    color: #666;
    text-decoration: underline;
    transition: color 0.2s;
}

.footer a:hover {
    color: var(--primary-color);
}

@media (max-width: 600px) {
    body {
        padding: 7px;
    }

    .container {
        margin: 20px auto;
        padding: 20px 12px;
        width: 100%;
        border-radius: 4px;
    }

    /* Default top pages (index.php) keep 18px */
    body.top-page h1 {
        font-size: 18px;
        margin-bottom: 24px;
    }

    /* Other pages (event.php, admin, etc) get 22px */
    body:not(.top-page) h1 {
        font-size: 22px;
        margin-bottom: 24px;
    }

    h2 {
        font-size: 20px;
        margin-bottom: 16px;
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: #2C9A7A;
    color: white;
    padding: 12px 24px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
}