:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-color: #333;
    --error-color: #e74c3c;
    --success-color: #27ae60;
    --border-radius: 12px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

header {
    text-align: center;
    margin-bottom: 40px;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
}

header h1 {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.8rem;
}

section {
    margin-bottom: 30px;
}

h2 {
    font-size: 1.4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    border-left: 4px solid var(--accent-color);
    padding-left: 10px;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

.required {
    color: var(--error-color);
    font-size: 0.8rem;
    margin-left: 5px;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    box-sizing: border-box;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.item-details {
    background: #f9f9f9;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-top: 20px;
    transition: var(--transition);
}

.detail-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.detail-image {
    width: 200px;
    height: 200px;
    background: #eee;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.detail-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.detail-info {
    flex: 1;
    min-width: 250px;
}

.detail-info p {
    margin: 5px 0;
    display: flex;
    /* フレックスボックスで行揃え */
    align-items: flex-start;
    /* 上揃え（複数行の場合に備えて） */
}

.detail-info p strong {
    white-space: nowrap;
    /* ラベルが折り返されないようにする */
    margin-right: 5px;
    /* ラベルと値の間隔 */
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.full-width {
    grid-column: span 2;
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    width: 100%;
    margin-top: 20px;
    transition: var(--transition);
}

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
}

.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.hidden {
    display: none !important;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
        /* モバイルではパディングを減らす */
    }

    header {
        margin-bottom: 20px;
    }

    header h1 {
        font-size: 1.5rem;
        /* ヘッダー文字サイズ調整 */
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .full-width {
        grid-column: span 1;
    }

    .detail-image {
        width: 100%;
        height: auto;
        min-height: 200px;
        /* 高さを確保 */
    }

    .detail-info {
        width: 100%;
        margin-top: 10px;
        /* 画像との間隔 */
    }
}

/* Auto-complete suggestions */
.suggestions-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
}

.suggestions-list li {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

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

.suggestions-list li:hover,
.suggestions-list li.highlighted {
    background-color: #f5f7fa;
    color: var(--accent-color);
}

.suggestions-list li.loading-item {
    color: #999;
    cursor: default;
    background-color: transparent !important;
}

.error {
    border-color: var(--error-color) !important;
    background-color: #fce4e4 !important;
}

#detail-memo {
    white-space: pre-wrap;
    /* 改行を反映 */
}

/* User Picker Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

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

.modal-header h3 {
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

#user-list {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.user-option {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    font-size: 1rem;
}

.user-option:last-child {
    border-bottom: none;
}

.user-option:hover {
    background-color: #f5f5f5;
}

.user-top {
    color: black;
}

.user-normal {
    color: blue;
}

/* Hiding original select but keeping it for form data */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

#memo {
    height: 100px;
}