:root {
    --primary-color: #ff9800; /* 明るいオレンジ */
    --primary-hover: #f57c00;
    --bg-dark: #fffdf5; /* 暖かみのあるクリーム白 */
    --bg-surface: #ffffff; /* 純白 */
    --bg-surface-light: #fff8e1; /* さらに明るいクリーム色 */
    --text-main: #4a4a4a; /* 丸みのある濃いグレー */
    --text-muted: #9e9e9e;
    --border-color: #e0e0e0;
    --danger-color: #ff5252;
    --success-color: #4caf50;
    --shadow-sm: 0 4px 10px rgba(0,0,0,0.05);
    --shadow-md: 0 6px 15px rgba(0,0,0,0.08);
    --shadow-lg: 0 15px 35px rgba(0,0,0,0.12);
    --border-radius: 16px; /* 少し丸みを強調 */
    --border-radius-lg: 24px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Noto Sans JP', sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none; /* Disable text selection for touch feel */
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    background: none;
    color: inherit;
    font-family: inherit;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}

/* Header */
.app-header {
    height: 60px;
    background-color: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.table-info {
    background-color: var(--primary-color);
    color: #ffffff;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 900;
    font-size: 1.1rem;
    box-shadow: 0 2px 5px rgba(255, 177, 0, 0.3);
}

.header-title {
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.total-summary {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.total-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.total-price {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary-color);
}

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Category Sidebar */
.category-sidebar {
    width: 160px;
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 10px 0;
}

.category-item {
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: var(--transition);
    position: relative;
}

.category-item.active {
    color: var(--primary-color);
    background-color: rgba(255, 177, 0, 0.05);
}

.category-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background-color: var(--primary-color);
    box-shadow: 0 0 10px var(--primary-color);
}

.category-item i {
    font-size: 1.8rem;
}

.category-item span {
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
}

.category-item:active {
    background-color: var(--bg-surface-light);
}

/* Product Grid */
.product-grid {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    align-content: start;
    scroll-behavior: smooth;
}

.product-card {
    background-color: var(--bg-surface);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.product-card:active {
    transform: scale(0.97);
    box-shadow: 0 0 15px rgba(255, 177, 0, 0.4);
    border-color: var(--primary-color);
}

.product-image-container {
    width: 100%;
    height: 140px;
    background-color: var(--bg-surface-light);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.product-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.product-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.product-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 8px;
    line-height: 1.3;
}

.product-price {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-top: auto;
}

/* Cart Sidebar */
.cart-sidebar {
    width: 320px;
    background-color: var(--bg-surface);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.2);
}

.cart-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-surface-light);
}

.cart-header h2 {
    font-size: 1.1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.empty-cart-message {
    text-align: center;
    color: var(--text-muted);
    margin-top: 40px;
    font-size: 0.9rem;
}

.cart-item {
    background-color: var(--bg-surface-light);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid var(--border-color);
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.cart-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.cart-item-name {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.2;
    flex: 1;
    padding-right: 10px;
}

.cart-item-remove {
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 4px;
}

.cart-item-remove:active {
    color: var(--danger-color);
}

.cart-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cart-item-price {
    font-weight: 700;
    color: var(--primary-color);
}

.cart-item-qty {
    display: flex;
    align-items: center;
    background-color: var(--bg-dark);
    border-radius: 15px;
    overflow: hidden;
}

.cart-qty-btn {
    width: 30px;
    height: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-dark);
    color: var(--text-main);
}

.cart-qty-btn:active {
    background-color: var(--bg-surface);
}

.cart-qty-val {
    width: 30px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.cart-footer {
    padding: 20px;
    background-color: var(--bg-surface-light);
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 10px rgba(0,0,0,0.1);
}

.cart-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 15px;
}

.cart-total-price {
    font-size: 1.8rem;
    font-weight: 900;
    color: var(--primary-color);
}

.order-button {
    width: 100%;
    background-color: var(--primary-color);
    color: #ffffff;
    font-weight: 900;
    font-size: 1.1rem;
    padding: 16px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(255, 177, 0, 0.4);
}

.order-button:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 8px rgba(255, 177, 0, 0.4);
    background-color: var(--primary-hover);
}

.order-button:disabled {
    background-color: var(--bg-surface);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    border: 1px solid var(--border-color);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: var(--bg-surface);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    position: relative;
    transform: scale(0.9) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 90%;
    max-height: 90vh;
    overflow: hidden;
}

.modal-overlay.active .modal-content {
    transform: scale(1) translateY(0);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: rgba(0,0,0,0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    z-index: 10;
    color: white;
}

.modal-close:active {
    background-color: var(--danger-color);
}

/* Product Detail Modal */
.product-modal-content {
    width: 800px;
}

.product-detail-layout {
    display: flex;
    flex-direction: row;
    height: 500px;
}

.product-detail-image-container {
    flex: 1;
    background-color: var(--bg-surface-light);
    display: flex;
    justify-content: center;
    align-items: center;
}

.product-detail-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-detail-info {
    flex: 1;
    padding: 40px;
    display: flex;
    flex-direction: column;
}

#modal-product-name {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.modal-product-desc {
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 20px;
    flex: 1;
}

.modal-price {
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--primary-color);
    margin-bottom: 30px;
}

.quantity-control-container {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    background-color: var(--bg-surface-light);
    padding: 15px 20px;
    border-radius: var(--border-radius);
}

.quantity-label {
    font-size: 1.1rem;
    font-weight: 700;
}

.quantity-controls {
    display: flex;
    align-items: center;
    background-color: var(--bg-dark);
    border-radius: 25px;
    overflow: hidden;
    margin-left: auto;
}

.qty-btn {
    width: 50px;
    height: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    background-color: var(--bg-dark);
}

.qty-btn:active {
    background-color: var(--primary-color);
    color: #ffffff;
}

.qty-display {
    width: 50px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: 900;
}

.add-to-cart-button {
    background-color: var(--primary-color);
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 900;
    padding: 20px;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.add-to-cart-button:active {
    transform: scale(0.98);
    background-color: var(--primary-hover);
}

/* Order Confirmation Modal */
.order-modal-content {
    width: 600px;
    display: flex;
    flex-direction: column;
}

.order-confirmation-header {
    padding: 25px;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.order-confirmation-header h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.order-review-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 20px;
}

.review-item {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 1.1rem;
}

.review-item-name {
    flex: 1;
}

.review-item-qty {
    margin: 0 20px;
    color: var(--text-muted);
}

.review-item-price {
    font-weight: 700;
}

.order-confirmation-total {
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-surface-light);
    font-size: 1.2rem;
    font-weight: 700;
}

.final-total-price {
    font-size: 2rem;
    color: var(--primary-color);
}

.order-modal-actions {
    display: flex;
    padding: 20px;
    gap: 15px;
}

.cancel-order-button, .confirm-order-button {
    flex: 1;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: var(--border-radius);
}

.cancel-order-button {
    background-color: var(--bg-surface-light);
    border: 1px solid var(--border-color);
}

.cancel-order-button:active {
    background-color: var(--border-color);
}

.confirm-order-button {
    background-color: var(--primary-color);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(255, 152, 0, 0.4);
}

.confirm-order-button:active {
    transform: translateY(2px);
    box-shadow: 0 2px 5px rgba(255, 177, 0, 0.4);
}

/* Success Overlay */
.success-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-dark);
    z-index: 200;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.success-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.success-content {
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.success-overlay.active .success-content {
    transform: scale(1);
}

.success-icon {
    font-size: 6rem;
    color: var(--success-color);
    margin-bottom: 20px;
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) 0.2s both;
}

@keyframes popIn {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.success-content h2 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.success-content p {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.practice-note {
    font-size: 1rem !important;
    color: var(--primary-color) !important;
    margin-top: 20px;
    margin-bottom: 40px !important;
}

.back-to-home {
    background-color: var(--bg-surface-light);
    border: 1px solid var(--border-color);
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 30px;
    transition: var(--transition);
}

.back-to-home:active {
    background-color: var(--bg-surface);
    transform: scale(0.95);
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #c0c0c0;
}

/* Responsive adjustments */
@media (max-width: 900px) {
    .product-detail-layout {
        flex-direction: column;
        height: auto;
    }
    .product-detail-image-container {
        height: 250px;
    }
    .product-detail-info {
        padding: 20px;
    }
}
