/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Helvetica Neue', Arial, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 40px;
    padding: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    color: #5d4037;
    font-size: 2.5rem;
    margin-bottom: 10px;
}

header p {
    color: #666;
    font-size: 1.1rem;
}

.guide-link {
    display: inline-block;
    margin-top: 15px;
    padding: 8px 20px;
    background: #8d6e63;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.95rem;
    transition: all 0.3s;
}

.guide-link:hover {
    background: #6d4c41;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(141,110,99,0.3);
}

main {
    display: grid;
    grid-template-columns: minmax(400px, 600px) 1fr;
    gap: 30px;
    align-items: start;
}

/* Control Panel Styles */
.control-panel {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    resize: horizontal;
    overflow-x: hidden;
    min-width: 400px;
    max-width: 800px;
}

.resize-handle:hover {
    background: rgba(141,110,99,0.2);
}

.input-section {
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee;
}

.input-section:last-child {
    border-bottom: none;
}

.input-section h2 {
    color: #5d4037;
    font-size: 1.3rem;
    margin-bottom: 15px;
}

input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 2px dashed #ccc;
    border-radius: 5px;
    background: #f9f9f9;
    cursor: pointer;
    transition: all 0.3s;
}

input[type="file"]:hover {
    border-color: #8d6e63;
    background: #fff;
}

.image-preview {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 5px;
    overflow: hidden;
    background: #f0f0f0;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-filename {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 5px;
    font-size: 0.75rem;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.image-preview-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255,255,255,0.9);
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #d32f2f;
    transition: all 0.3s;
}

.image-preview-item .remove-btn:hover {
    background: #fff;
    transform: scale(1.1);
}

/* Menu Table Styles */
.menu-table-container {
    margin-top: 15px;
    overflow-x: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.menu-edit-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.menu-edit-table thead {
    background: #f5f5f5;
}

.menu-edit-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: #5d4037;
    border-bottom: 2px solid #ddd;
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Column widths */
.menu-edit-table th:nth-child(1),
.menu-edit-table td:nth-child(1) {
    width: 20%;
    min-width: 120px;
}

.menu-edit-table th:nth-child(2),
.menu-edit-table td:nth-child(2) {
    width: 12%;
    min-width: 80px;
}

.menu-edit-table th:nth-child(3),
.menu-edit-table td:nth-child(3) {
    width: 30%;
    min-width: 150px;
}

.menu-edit-table th:nth-child(4),
.menu-edit-table td:nth-child(4) {
    width: 18%;
    min-width: 120px;
}

.menu-edit-table th:nth-child(5),
.menu-edit-table td:nth-child(5) {
    width: 15%;
    min-width: 100px;
}

.menu-edit-table th:nth-child(6),
.menu-edit-table td:nth-child(6) {
    width: 5%;
    min-width: 60px;
    text-align: center;
}

.menu-edit-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.table-input,
.table-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 0.9rem;
    font-family: inherit;
}

.table-input:focus,
.table-select:focus {
    outline: none;
    border-color: #8d6e63;
}

.delete-row-btn {
    padding: 5px 12px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s;
}

.delete-row-btn:hover {
    background: #d32f2f;
}

.table-actions {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.add-btn {
    padding: 10px 20px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
}

.add-btn:hover {
    background: #45a049;
}

.sample-btn {
    padding: 10px 20px;
    background: #ff9800;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
}

.sample-btn:hover {
    background: #f57c00;
}

.save-btn {
    padding: 10px 20px;
    background: #2196f3;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.3s;
}

.save-btn:hover {
    background: #1976d2;
}

.csv-actions {
    display: flex;
    gap: 10px;
}

.csv-btn {
    flex: 1;
    padding: 8px 16px;
    background: #fff;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.csv-btn:hover {
    background: #f5f5f5;
    border-color: #8d6e63;
    color: #8d6e63;
}

/* Currency Input Group */
.currency-input-group {
    display: flex;
    gap: 10px;
}

.currency-input-group input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.currency-preset {
    width: 120px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 0.9rem;
    background: #f9f9f9;
    cursor: pointer;
}

/* Layout Options */
.layout-options {
    margin-bottom: 30px;
}

.option-group {
    margin-bottom: 15px;
}

.option-group label {
    display: block;
    margin-bottom: 5px;
    color: #666;
    font-weight: 500;
}

.option-group select,
.option-group input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.primary-btn,
.secondary-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.primary-btn {
    background: #8d6e63;
    color: white;
}

.primary-btn:hover {
    background: #6d4c41;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(141,110,99,0.3);
}

.secondary-btn {
    background: #fff;
    color: #666;
    border: 1px solid #ddd;
}

.secondary-btn:hover:not(:disabled) {
    background: #f5f5f5;
}

.secondary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Preview Section */
.preview-section {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.preview-section h2 {
    color: #5d4037;
    font-size: 1.5rem;
    margin-bottom: 20px;
}

#menu-canvas-container {
    position: relative;
    background: #f9f9f9;
    border-radius: 5px;
    min-height: 600px;
    overflow: auto;
}

#menu-canvas {
    display: none;
}

.menu-preview {
    padding: 40px;
    min-height: 600px;
}

/* Menu Layout Styles */
.menu-grid {
    display: grid;
    gap: 30px;
}

.menu-item {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.menu-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.menu-item-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.menu-item-content {
    padding: 20px;
}

.menu-item-name {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 5px;
}

.menu-item-price {
    font-size: 1.1rem;
    color: #8d6e63;
    font-weight: 500;
    margin-bottom: 10px;
}

.menu-item-description {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.5;
}

.menu-category {
    margin-bottom: 40px;
}

.menu-category-title {
    font-size: 1.8rem;
    color: #5d4037;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #8d6e63;
}

/* Theme Variations */
.theme-modern .menu-item {
    border-radius: 0;
    box-shadow: none;
    border: 1px solid #eee;
}

.theme-rustic {
    background-color: #faf8f5;
}

.theme-rustic .menu-item {
    background: #fff9f0;
    border: 2px solid #d4a574;
}

.theme-minimal .menu-item {
    box-shadow: none;
    border: 1px solid #f0f0f0;
}

.theme-minimal .menu-item-content {
    padding: 15px;
}

/* Font Variations */
.font-gothic {
    font-family: 'Noto Sans JP', 'Helvetica Neue', Arial, 'Hiragino Kaku Gothic ProN', 'Meiryo', sans-serif;
}

.font-mincho {
    font-family: 'Noto Serif JP', 'Georgia', 'Times New Roman', 'Hiragino Mincho ProN', 'Yu Mincho', serif;
}

.font-mincho .menu-item-name,
.font-mincho .menu-category-title {
    font-weight: normal;
    letter-spacing: 0.05em;
}

.font-rounded {
    font-family: 'M PLUS Rounded 1c', 'Arial Rounded MT Bold', 'Hiragino Maru Gothic ProN', sans-serif;
}

.font-rounded .menu-item-name {
    font-weight: 700;
}

.font-handwriting {
    font-family: 'Klee One', 'Comic Sans MS', 'Tsukushi A Round Gothic', cursive;
}

.font-handwriting .menu-item-price {
    font-family: 'Noto Sans JP', Arial, sans-serif;
}

.font-handwriting .menu-item-name,
.font-handwriting .menu-category-title {
    font-weight: 600;
}

.font-pop {
    font-family: 'Noto Sans JP', 'Impact', 'Arial Black', 'Hiragino Kaku Gothic Std W8', sans-serif;
    font-weight: 700;
}

.font-pop .menu-item-name,
.font-pop .menu-category-title {
    font-weight: 700;
    letter-spacing: 0.1em;
}

.font-pop .menu-item-description {
    font-family: 'Noto Sans JP', 'Helvetica Neue', Arial, sans-serif;
    font-weight: normal;
}

.font-elegant {
    font-family: 'Noto Serif JP', 'Garamond', 'Baskerville', 'Hiragino Mincho ProN W6', 'Yu Mincho', serif;
}

.font-elegant .menu-item-name,
.font-elegant .menu-category-title {
    font-weight: 400;
    letter-spacing: 0.08em;
}

.font-elegant .menu-item-price {
    font-family: 'Noto Sans JP', 'Optima', 'Hiragino Kaku Gothic ProN', sans-serif;
    font-weight: 300;
}

/* Category Image Styles */
.category-image-item {
    margin-bottom: 20px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 5px;
}

.category-image-item label {
    display: block;
    font-weight: 500;
    margin-bottom: 10px;
    color: #5d4037;
}

.category-image-input {
    width: 100%;
    padding: 8px;
    border: 1px dashed #ccc;
    border-radius: 5px;
    background: white;
    cursor: pointer;
    margin-bottom: 10px;
}

.category-image-preview {
    position: relative;
    display: inline-block;
}

.category-image-preview img {
    display: block;
    border: 2px solid #ddd;
}

.category-image-preview .remove-btn {
    position: absolute;
    top: -10px;
    right: -10px;
    background: #fff;
    border: 1px solid #ddd;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #d32f2f;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Category Layout with Images */
.category-content {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.category-image-side {
    flex-shrink: 0;
    width: 250px;
}

.category-image-side img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    object-fit: cover;
    aspect-ratio: 1;
}

.menu-items-container {
    flex: 1;
    min-width: 0;
}

/* List Layout Adjustments */
.menu-list {
    padding: 20px 0;
}

.list-item {
    transition: background-color 0.3s;
}

.list-item:hover {
    background-color: #f5f5f5;
    border-radius: 8px;
    padding-left: 10px;
    margin-left: -10px;
    margin-right: -10px;
    padding-right: 10px;
}

/* Select Image Button */
.select-image-btn {
    padding: 8px 16px;
    background: #8d6e63;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    margin: 10px 0;
}

.select-image-btn:hover {
    background: #6d4c41;
    transform: translateY(-1px);
}

/* Image Gallery Modal */
.image-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 10px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    width: 90%;
}

.modal-content h3 {
    margin-bottom: 20px;
    color: #5d4037;
}

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border: 3px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
}

.gallery-item:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.gallery-item.selected {
    border-color: #8d6e63;
    box-shadow: 0 0 0 2px #8d6e63;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.close-modal-btn {
    width: 100%;
    padding: 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s;
}

.close-modal-btn:hover {
    background: #e0e0e0;
}

/* Responsive Table */
@media (max-width: 768px) {
    .menu-edit-table {
        font-size: 0.85rem;
    }
    
    .menu-edit-table th,
    .menu-edit-table td {
        padding: 6px 4px;
    }
    
    .table-input,
    .table-select {
        font-size: 0.85rem;
        padding: 4px 6px;
    }
    
    .delete-row-btn {
        padding: 4px 8px;
        font-size: 0.8rem;
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    main {
        grid-template-columns: 1fr;
    }
    
    .control-panel {
        position: static;
        max-height: none;
        resize: none;
        max-width: 100%;
        width: 100% !important;
    }
    
    .resize-handle {
        display: none;
    }
    
    .category-content {
        flex-direction: column;
        gap: 20px;
    }
    
    .category-image-side {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .menu-grid {
        grid-template-columns: 1fr !important;
    }
}