/* Basic Reset & Setup */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    line-height: 1.6;
}

#app {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

h1 {
    font-size: 1.8em;
    color: #333;
}

/* Buttons */
button {
    padding: 10px 15px;
    border: none;
    background-color: #5a67d8;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #434190;
}

/* Views */
.hidden {
    display: none;
}

/* Home View */
#body-parts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.body-part-btn {
    padding: 30px;
    font-size: 1.2em;
    font-weight: bold;
    text-transform: uppercase;
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;
}

.body-part-btn:hover {
    background-color: #e2e2e2;
}

/* Form View */
#workout-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

label {
    margin-bottom: 5px;
    font-weight: bold;
}

input, select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 1em;
}

/*
 * ブラウザのデフォルトのフォーカススタイル（オレンジ色の枠）を無効化し、
 * 代わりに枠線の色を変更してフォーカス状態を示す
 */
input:focus, select:focus {
    outline: none;
    border-color: #5a67d8;
}

#workout-form button {
    margin-top: 10px;
    padding: 12px;
    font-size: 1.1em;
    background-color: #38a169;
}

#workout-form button:hover {
    background-color: #2f855a;
}

.input-group {
    display: flex;
    align-items: stretch;
}

.input-group input {
    flex-grow: 1;
    text-align: center;
    min-width: 0; /* Prevent input from having a minimum width that causes overflow */
    border-radius: 0;
    /* Remove number input spinners */
    -moz-appearance: textfield;
}

.input-group input::-webkit-outer-spin-button,
.input-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.input-group input[readonly] {
    background-color: #f0f0f0;
    /* A light gray to indicate it's not editable */
    cursor: default;
    /* Change cursor to show it's not a text input */
}

.btn-stepper {
    width: auto;
    padding: 0 10px;
    flex-shrink: 0;
    background-color: #edf2f7;
    color: #4a5568;
    font-size: 1rem;
    font-weight: bold;
    border: 1px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-group .btn-stepper:first-child {
    border-right: none;
    border-radius: 5px 0 0 5px;
}
.input-group .btn-stepper:last-child {
    border-left: none;
    border-radius: 0 5px 5px 0;
}

.weight-slider {
    width: 100%;
    margin-top: 10px;
}

/* Temp Log in Form View */
#temp-log-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

#temp-log-container h2 {
    font-size: 1.5em;
    margin-bottom: 10px;
}

#temp-log-exercise-name {
    font-weight: bold;
    font-size: 1.1em;
    margin-bottom: 10px;
}

#temp-log-list {
    list-style: none;
}

#temp-log-list li {
    background-color: #f9f9f9;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 5px;
    border-left: 3px solid #38a169;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.delete-set-btn,
.delete-history-btn {
    padding: 5px 8px;
    font-size: 0.8em;
    background-color: #e53e3e;
    /* Red color */
    margin-left: 10px;
    flex-shrink: 0;
    /* Prevent button from shrinking */
}

.delete-set-btn:hover,
.delete-history-btn:hover {
    background-color: #c53030;
}

/* Finish workout button */
#finish-workout-btn {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    font-size: 1.1em;
    background-color: #dd6b20; /* Orange color for distinction */
}
#finish-workout-btn:hover {
    background-color: #c05621;
}

/* Toast Notification */
#toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(45, 55, 72, 0.9); /* ダークグレー、少し透過 */
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    z-index: 1000;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s, top 0.3s, visibility 0.3s;
    font-size: 0.9em;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

#toast.show {
    top: 40px;
    visibility: visible;
    opacity: 1;
}

/* History Filter Controls */
#history-filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: flex-end;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f0f0f0;
    border-radius: 5px;
}

#history-filter-controls .form-group {
    flex: 1 1 200px; /* Allow growing and shrinking, with a base width */
}

#history-filter-controls button {
    padding: 10px 15px;
    flex-shrink: 0;
}

#reset-filter-btn {
    background-color: #718096; /* Gray */
}
#reset-filter-btn:hover {
    background-color: #4a5568;
}

/* History Pagination */
#history-pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    gap: 15px;
}

#history-pagination-controls button {
    background-color: #718096;
}

#history-pagination-controls button:disabled {
    background-color: #cbd5e0;
    cursor: not-allowed;
}

#page-info {
    font-weight: bold;
}

/* History View */
#history-content .exercise-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

#history-content .exercise-header p {
    margin: 0;
}

/* History View - Accordion styles */
#history-content .date-entry {
    background: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 5px;
    margin-bottom: 15px;
}

#history-content summary {
    cursor: pointer;
    padding: 15px;
    font-weight: bold;
    list-style: none; /* Remove default marker */
    position: relative;
}

#history-content summary::-webkit-details-marker { display: none; }

#history-content summary:focus {
    outline: none;
}

#history-content summary::after {
    content: '▶';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%) rotate(0deg);
    transition: transform 0.2s;
    font-size: 0.8em;
    color: #777;
}

#history-content details[open] > summary::after {
    transform: translateY(-50%) rotate(90deg);
}

#history-content .date-header {
    font-size: 1.5em;
    color: #5a67d8;
}

#history-content .bodypart-header {
    font-size: 1.2em;
    text-transform: uppercase;
    color: #444;
    background-color: #fff;
    border-radius: 3px;
}

#history-content details[open] > .date-header {
    border-bottom: 1px solid #ddd;
}

#history-content .exercise-items-list > li {
    margin-bottom: 8px;
    background: #fff;
    padding: 8px;
    border-radius: 3px;
    border-left: 3px solid #5a67d8;
}

#history-content .bodypart-entry {
    margin-top: 10px;
}

#history-content .exercise-items-list {
    list-style: none;
    padding: 15px;
    background-color: #fff;
    border-radius: 0 0 3px 3px;
    margin: 0;
}

#history-content .bodyparts-container {
    padding: 0 15px 15px 15px;
}

#history-content .sets-list {
    list-style: none;
    padding-left: 15px;
}

#history-content .sets-list li {
    font-size: 0.95em;
    border-left: 3px solid #38a169;
}