/* style.css (updated: brighten accordion hover color in dark mode) */

/* 基本スタイル */
html {
    height: 100%;
}

hr {
    border: none;
    height: 1px;
    background-color: #ddd;
    margin: 1rem 0;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0.75rem;
    background-color: #f8fafc;
    color: #333;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    touch-action: manipulation;
    overflow-x: hidden;
    height: 100%;
    overflow-y: auto;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 10px;
    text-align: left;
    overflow-y: visible;
    height: auto;
}

h3 {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
    margin: 1.5rem 0 1rem;
    text-align: left;
    border-bottom: 2px solid #4a90e2;
    padding-bottom: 0.5rem;
}

p {
    font-size: 1.1rem;
    margin: 0.75rem 0;
    text-align: left;
    word-wrap: break-word;
}

textarea {
    width: 100%;
    min-height: 100px;
    max-height: 30vh;
    padding: 0.75rem;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    background-color: #f8fafc;
    color: #333;
    font-family: Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    margin: 0.75rem 0;
    box-sizing: border-box;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    resize: vertical;
    white-space: pre-wrap;
}

input[type="text"], input[type="number"], input[type="password"], select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    font-size: 1.1rem;
    margin: 0.5rem 0;
    box-sizing: border-box;
    min-height: 48px;
    transition: border-color 0.3s ease;
    background-color: #f8fafc;
    color: #333;
    font-size: 16px; /* Androidでキーボード表示を安定させるための最小フォントサイズ */
}

input[type="text"]:focus, input[type="number"]:focus, input[type="password"]:focus, select:focus {
    border-color: #303f9f;
    outline: none;
    font-size: 16px; /* フォーカス時のズーム防止 */
}

input[type="text"]:disabled, input[type="number"]:disabled, input[type="password"]:disabled, select:disabled {
    background-color: #e8e8e8;
    color: #888;
    opacity: 0.7;
    cursor: not-allowed;
}

input[type="number"] {
    -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.button {
    width: 100%;
    margin: 0.75rem 0;
    padding: 0.75rem;
    background-color: #3f51b5;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: background-color 0.3s ease;
    min-height: 48px;
    text-align: center;
}

.button:hover:not(:disabled) {
    background-color: #303f9f;
}

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

.form-group {
    margin: 1rem 0;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

.form-row > * {
    min-width: 100%;
}

.accordion {
    background-color: #eee;
    color: #444;
    cursor: pointer;
    padding: 0.75rem;
    width: 100%;
    border: none;
    text-align: left;
    outline: none;
    font-size: 1.1rem;
    transition: background-color 0.3s ease;
    margin: 0.5rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-height: 48px;
}

.active {
    background-color: #ccc;
}

.accordion:hover {
    background-color: #ccc;
}

.panel {
    padding: 0.75rem;
    display: none;
    background-color: white;
    overflow: hidden;
    margin: 0.5rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    max-height: 40vh;
    overflow-y: auto;
}

.status-green { background-color: #d4edda; color: #155724; }
.status-red { background-color: #f8d7da; color: #721c24; }
.status-yellow { background-color: #fff3cd; color: #856404; }
.status-再開 { color: #155724; font-weight: bold; }
.status-一時停止 { color: #721c24; font-weight: bold; }
.status-手動 { color: #856404; font-weight: bold; }

.notification {
    padding: 0.75rem;
    margin: 0.75rem 0;
    border-radius: 8px;
    font-weight: 500;
    font-size: 1rem;
}

.notification.error { background-color: #f8d7da; color: #721c24; border-left: 4px solid #dc3545; }
.notification.success { background-color: #d4edda; color: #155724; border-left: 4px solid #28a745; }

.history-list {
    width: 100%;
    margin: 1rem 0;
    background-color: #fff;
    border-radius: 8px;
    overflow-x: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 0.75rem;
}

.history-list p {
    margin: 0.5rem 0;
    font-size: 1rem;
    white-space: nowrap;
}

.history-list .action-add {
    color: #28a745;
    font-weight: bold;
}

.history-list .action-remove {
    color: #dc3545;
    font-weight: bold;
}

.history-total {
    font-size: 1.2rem;
    font-weight: bold;
    margin: 1rem 0;
    padding: 0.75rem;
    background-color: #e9ecef;
    color: #333;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #4a90e2;
}

.table-container {
    overflow-x: auto;
    margin: 1rem 0;
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
}

.modal-content {
    background-color: #fefefe;
    margin: 10% auto;
    padding: 1rem;
    border: 1px solid #888;
    width: 90%;
    max-width: 400px;
    border-radius: 10px;
    text-align: center;
    color: #333;
}

.close {
    color: #aaa;
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    padding: 0.5rem;
}

.close:hover {
    color: black;
}

.modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1rem;
}

.modal-buttons .button {
    max-width: none;
    min-height: 48px;
}

.remainder {
    color: #dc3545;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ダークモードのスタイル */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #e0e0e0;
    }

    .container {
        background-color: transparent;
    }

    h3 {
        color: #e0e0e0;
        border-bottom: 2px solid #64b5f6;
    }

    p {
        color: #e0e0e0;
    }

    textarea {
        background-color: #2c2c2c;
        color: #e0e0e0;
        border: 2px solid #64b5f6;
    }

    input[type="text"], input[type="number"], input[type="password"], select {
        background-color: #2c2c2c;
        color: #e0e0e0;
        border: 2px solid #64b5f6;
    }

    input[type="text"]:disabled, input[type="number"]:disabled, input[type="password"]:disabled, select:disabled {
        background-color: #444;
        color: #888;
        opacity: 0.7;
    }

    .button {
        background-color: #3f51b5;
        color: #fff;
    }

    .button:hover:not(:disabled) {
        background-color: #303f9f;
    }

    .button:disabled {
        background-color: #555;
    }

    .accordion {
        background-color: #333;
        color: #e0e0e0;
    }

    .accordion:hover {
        background-color: #777; /* ホバー時の背景色をさらに明るく */
    }

    .active {
        background-color: #666; /* アクティブ時の背景色は変更せず */
    }

    /* 個別表示・履歴のアコーディオンの背景色は変更しない */
    .status-green { background-color: #d4edda; color: #155724; }
    .status-red { background-color: #f8d7da; color: #721c24; }
    .status-yellow { background-color: #fff3cd; color: #856404; }

    .panel {
        background-color: #2c2c2c;
        color: #e0e0e0;
    }

    .notification.error {
        background-color: #f8d7da;
        color: #721c24;
        border-left: 4px solid #dc3545;
    }

    .notification.success {
        background-color: #d4edda;
        color: #155724;
        border-left: 4px solid #28a745;
    }

    .history-total {
        background-color: #333;
        color: #e0e0e0;
        border-left: 4px solid #64b5f6;
    }

    .modal-content {
        background-color: #2c2c2c;
        color: #e0e0e0;
        border: 1px solid #555;
    }

    .close {
        color: #bbb;
    }

    .close:hover {
        color: #fff;
    }
}

/* デスクトップ向けのスタイル (768px以上) */
@media (min-width: 769px) {
    body {
        padding: 1.5rem;
        font-size: 1.1rem;
        overflow-y: auto;
        height: 100%;
    }

    .container {
        max-width: 800px;
        padding: 0 1.5rem;
        height: auto;
        overflow-y: visible;
    }

    h3 {
        font-size: 1.75rem;
        margin: 2rem 0 1.25rem;
    }

    p {
        font-size: 1.15rem;
    }

    .form-row {
        flex-direction: row;
        gap: 1rem;
        align-items: center;
    }

    .form-row > * {
        min-width: 0;
        flex: 1;
    }

    input[type="text"], input[type="number"], input[type="password"], select {
        font-size: 1.1rem;
        padding: 0.75rem;
    }

    .button {
        font-size: 1.15rem;
        padding: 0.75rem 1.5rem;
        max-width: 300px;
    }

    .accordion {
        font-size: 1.15rem;
        padding: 1rem;
    }

    .panel {
        max-height: 50vh;
        padding: 1rem;
    }

    textarea {
        font-size: 1.1rem;
        min-height: 120px;
        max-height: 35vh;
    }

    .modal-content {
        width: 80%;
        max-width: 500px;
        padding: 1.5rem;
    }

    .modal-content p {
        font-size: 1.2rem;
    }

    .close {
        font-size: 1.75rem;
    }

    .modal-buttons {
        flex-direction: row;
        gap: 1rem;
    }

    .history-list {
        font-size: 1.1rem;
        padding: 1rem;
    }

    .history-total {
        font-size: 1.25rem;
        padding: 1rem;
    }

    .notification {
        font-size: 1.1rem;
        padding: 1rem;
    }

    #adminAddForm, #userAddForm {
        display: flex;
        flex-direction: column;
        gap: 1rem;
    }

    #adminAddForm .form-row-upper, #userAddForm .form-row-upper {
        display: flex;
        flex-direction: row;
        gap: 1rem;
        align-items: center;
    }

    #adminAddForm .form-row-upper > *, #userAddForm .form-row-upper > * {
        flex: 1;
        min-width: 0;
    }

    #adminAddForm .form-row-lower, #userAddForm .form-row-lower {
        display: flex;
        flex-direction: row;
        gap: 1rem;
        align-items: center;
    }

    #adminAddForm .form-row-lower input[name="item"], #userAddForm .form-row-lower input[name="item"] {
        flex: 3;
    }

    #adminAddForm .form-row-lower input[name="quantity"],
    #adminAddForm .form-row-lower input[name="amount"], #userAddForm .form-row-lower input[name="quantity"],
    #userAddForm .form-row-lower input[name="amount"] {
        flex: 1;
    }

    #adminAddForm .button, #userAddForm .button {
        width: 100%;
        margin-top: 1rem;
    }
}

/* モバイル向けのスタイル (768px未満) */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
        font-size: 1rem;
    }

    .container {
        padding: 0 0.5rem;
        height: 100vh;
        overflow-y: auto;
    }

    h3 {
        font-size: 1.25rem;
        margin: 1rem 0 0.75rem;
    }

    p {
        font-size: 1rem;
    }

    .form-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .form-row > * {
        min-width: 100%;
    }

    input[type="text"], input[type="number"], input[type="password"], select {
        font-size: 16px;
        padding: 0.75rem;
        min-height: 48px;
    }

    .button {
        font-size: 1rem;
        padding: 0.75rem;
        min-height: 48px;
        max-width: 100%;
    }

    .accordion {
        font-size: 1rem;
        padding: 0.75rem;
        min-height: 48px;
    }

    .panel {
        padding: 0.75rem;
        max-height: 30vh;
    }

    textarea {
        font-size: 0.9rem;
        min-height: 80px;
        max-height: 25vh;
    }

    .modal-content {
        margin: 20% auto 0;
        width: 95%;
        max-width: 320px;
        padding: 1.25rem;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    }

    .modal-content p {
        font-size: 1.1rem;
        line-height: 1.5;
        margin-bottom: 1.25rem;
    }

    .close {
        font-size: 2rem;
        padding: 0.75rem;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 1rem;
    }

    .modal-buttons .button {
        font-size: 1.1rem;
        padding: 1rem;
        min-height: 56px;
    }

    .notification {
        font-size: 0.9rem;
        padding: 0.5rem;
    }

    .history-list {
        font-size: 0.9rem;
        padding: 0.75rem;
    }

    .history-total {
        font-size: 1.1rem;
        padding: 0.5rem;
    }
}