body {
    padding-bottom: 75px;
}

table#orderTable {
    table-layout: initial;
}

.card .free-text-input {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: left;
    font-size: 14px;
}

.free-text-input::placeholder {
    font-style: italic;
}

/* ヘッダー共通スタイル */
.main-header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    position: relative;
}

.header-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 600px;
}

.main-header h1 {
    margin: 0;
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.8px;
    line-height: 1.2;
}

.main-header .description {
    margin: 0;
    opacity: 0.9;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.2px;
}

.search-container {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-container input[type="text"] {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    flex: 1;
    max-width: 300px;
    min-width: 115px;
}

.search-container input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(11, 110, 246, 0.2);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.panels-container.search-mode {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.panels-container.search-mode .grid-tab-content.grid {
    display: contents;
}

@media (max-width: 1200px) {
    .panels-container.search-mode {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .panels-container.search-mode {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .panels-container.search-mode {
        grid-template-columns: 1fr;
    }
}

.search-empty-message {
    margin: 8px 0 16px;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--muted-color);
    background: #fafbff;
}

.tab {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    word-break: break-all;
}

.tab:hover {
    background: #f8f9fa;
}

.tab[aria-selected="true"] {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);

}

/* Grid - 4 columns */
.grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1200px) {
    .grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

/* Card */
.card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    transition: all 0.2s ease;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.unorderable-card {
    opacity: 0.6;
    background-color: #fcfcfc;
    border-color: #ddd;
}
.unorderable-card:hover {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05); /* Same as default */
    transform: none;
}

.unorderable-container {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}

.unorderable-message {
    color: #d9534f;
    font-weight: 700;
    font-size: 13px;
    display: inline-block;
}

.photo {
    width: 100%;
    height: 140px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fafbff;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    margin-bottom: 12px;
    font-size: 24px;
}

.name {
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    min-height: 2.2em;
    color: var(--text-color);
    word-break: break-all;
}

.meta {
    font-size: 12px;
    color: var(--muted-color);
    line-height: 1.5;
    margin-bottom: 12px;
    word-break: break-all;
}

.meta b {
    color: #444;
}

.order {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.qty {
    width: 72px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    text-align: right;
    font-size: 14px;
}

.qty:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(11, 110, 246, 0.2);
}

.hint {
    font-size: 11px;
    color: var(--muted-color);
    margin-top: 8px;
}

.btn-confirm {
    background: var(--primary-color);
    color: white;
}

.btn-confirm:hover {
    background: #0056b3;
}

.btn-cansel {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-cansel:hover {
    background: #f8f9fa;
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    background: #f8f9fa;
    border-radius: 8px 8px 0 0;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow: auto;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8f9fa;
    border-radius: 0 0 8px 8px;
}

.warn {
    color: var(--danger-color);
    font-weight: 700;
}

.total {
    font-weight: 800;
    background: #f8f9fa;
}

.hidden {
    display: none !important;
}

input.is-invalid {
    border-color: #dc3545;
}

.comment-container {
    background: var(--accent-color);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    justify-content: flex-end;
    position: relative;
}

#commentContent {
    flex: 1;
    margin-right: auto;
}

.comment-container p {
    margin: 0;
    color: #fff;
}

.comment-actions {
    margin-left: auto;
    position: sticky;
    top: 0;
    z-index: 100;
    align-self: flex-start;
}

.comment-toggle {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
}

.comment-toggle:hover {
    background: rgba(255, 255, 255, 0.28);
}

#commentContent.hidden {
    display: none;
}

.comment-container.collapsed {
    background: transparent;
    padding: 0;
    margin-bottom: 0;
    display: flex;
    justify-content: flex-end;
}

.comment-container.collapsed #commentContent {
    margin-right: 0;
}

.comment-container.collapsed .comment-actions {
    margin-left: 0;
    padding: 8px 0;
}

.comment-container.collapsed .comment-toggle {
    background: var(--accent-color);
    color: #fff;
    border: 1px solid var(--accent-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.comment-container.collapsed .comment-toggle:hover {
    background: var(--accent-color);
    opacity: 0.9;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.comment-toggle .toggle-text {
    display: inline;
}

.comment-toggle .toggle-icon {
    display: none;
    font-size: 13px;
    line-height: 1;
}

@media (max-width: 768px) {
    .header-left {
        max-width: 100%;
        margin: auto;
        text-align: center;
    }

    .main-header {
        padding-left: 15px;
        padding-right: 15px;
    }

    .comment-container {
        position: fixed;
        top: 98px;
        right: 16px;
        width: calc(100% - 32px);
        min-width: 280px;
        max-height: calc(100vh - 32px);
        overflow: visible;
        z-index: 1000;
        flex-direction: column;
        align-items: flex-end;
        gap: 0;
        background: transparent;
        padding: 0;
    }

    .comment-actions {
        position: absolute;
        top: 8px;
        right: 8px;
        margin-left: 0;
        z-index: 1001;
    }

    #commentContent {
        background: var(--accent-color);
        padding: 12px;
        padding-top: 48px;
        border-radius: 8px;
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 32px);
        overflow-y: auto;
        margin-top: 0;
    }

    .comment-toggle {
        padding: 8px;
        min-width: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .comment-toggle .toggle-text {
        display: none;
    }

    .comment-toggle .toggle-icon {
        display: inline-block;
    }

    .comment-container.collapsed {
        width: auto;
        min-width: auto;
        max-width: none;
    }

    .comment-container.collapsed #commentContent {
        display: none;
    }

    .comment-container.collapsed .comment-actions {
        position: absolute;
        top: 8px;
        right: 8px;
        padding: 0;
    }
}

#btnReset {
    background-color: #6c757d;
    color: #fff;
}

#btnSearch, #btnClearSearch {
    white-space: nowrap;
}

@media (max-width: 485px) {
    .comment-container .comment-actions {
        top: 5px !important;
        right: 8px !important;
    }

    .comment-toggle {
        min-width: 35px;
    }

    .comment-container {
        position: fixed;
        right: 10px;
        width: calc(100% - 20px);
    }
}

@media (max-width: 385px) {
    .search-container {
        display: block;
        margin-bottom: 30px;
    }

    .search-container #searchInput {
        width: 100%;
        max-width: 100%;
        float: left;
    }

    .search-container #btnSearch,
    .search-container #btnClearSearch {
        float: left;
        width: calc(50% - 5px);
        margin-top: 10px;
        padding: 8px 6px !important;
    }

    .search-container #btnSearch {
        margin-right: 10px;
    }

    .footer .actions .btn {
        padding: 10px;
        font-size: 13px;
    }
}

@media (max-width: 385px) {
    .footer .actions .btn {
        padding: 10px 8px;
        font-size: 12px;
    }
}

/* Free item styles */
.free-item {
    border: 2px solid #e3f2fd;
    background: linear-gradient(135deg, #f8f9ff 0%, #ffffff 100%);
}

.free-item .name {
    color: var(--primary-color);
    position: relative;
}

.free-item .name::after {
    content: "フリー";
    position: absolute;
    top: -2px;
    right: 0;
    background: var(--primary-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

.free-input {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.free-input label {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary-color);
}

.free-text {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--primary-color);
    border-radius: 6px;
    font-size: 14px;
    background: #f8f9ff;
}

.free-text:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(11, 110, 246, 0.2);
    background: white;
}

.free-text::placeholder {
    color: #999;
    font-style: italic;
}

.btn-confirm {
    background: var(--primary-color);
    color: white;
}

.btn-confirm:hover {
    background: #0056b3;
}

.btn-cansel {
    background: #fff;
    border: 1px solid var(--border-color);
    color: var(--text-color);
}

.btn-cansel:hover {
    background: #f8f9fa;
}

#orderTable {
    width: 100%;
    float: left;
}

#orderTable #order-items {
    width: 100%;
    float: left;
    box-sizing: border-box;
}

#orderTable #order-items .order-item {
    width: 100%;
    float: left;
    box-sizing: border-box;
    border: 1px solid #e9e9e9;
    margin-bottom: 15px;
    border-radius: 5px;
    padding: 10px 15px;
    background: #fdfdfd;
}

#orderTable #order-items .order-item h3 {
    width: 100%;
    float: left;
    box-sizing: border-box;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
}

#orderTable #order-items .order-item .order-item-row {
    width: 100%;
    float: left;
    box-sizing: border-box;
    font-size: 14px;
}

#orderTable #order-items .order-item .order-item-main {
    margin-top: 10px;
    margin-bottom: 10px;
    float: left;
    width: 100%;
    border-bottom: 1px solid #ededed;
    padding-bottom: 10px;
}

#orderTable #order-items .order-item .order-item-main .order-item-row {
    width: calc((100% / 3) - 5px);
    margin-right: 7.5px;
}

#orderTable #order-items .order-item .order-item-main .order-item-row:last-child {
    margin-right: 0;
}

#orderTable #order-items .order-item .order-item-row label {
    float: left;
    margin-right: 10px;
    font-weight: 500;
}

#orderTable #order-items .order-item .order-item-row span {
    float: left;
    white-space: nowrap;
}

#orderTable .order-sum {
    width: 100%;
    float: left;
    box-sizing: border-box;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
    text-align: right;
}

#orderTable .order-sum label {
    float: left;
    margin-right: 10px;
}

#orderTable .order-sum span {
    float: right;
}

@media (max-width: 380px) {
    #orderTable #order-items .order-item .order-item-main .order-item-row {
        width: calc(50% - 7.5px);
        margin-right: 7.5px;
    }
    #orderTable #order-items .order-item .order-item-main .order-item-row:last-child {
        margin-right: 7.5px;
    }
}
