/* CSS Variables for Theme */
:root {
    --primary-color: #4A90E2;
    --secondary-color: #7B68EE;
    --success-color: #5CB85C;
    --danger-color: #D9534F;
    --warning-color: #F0AD4E;
    --dark-color: #2C3E50;
    --light-color: #ECF0F1;
    --text-color: #333333;
    --text-light: #666666;
    --border-color: #DDD;
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 8px rgba(0,0,0,0.15);
    --shadow-lg: 0 8px 16px rgba(0,0,0,0.2);
    --border-radius: 8px;
    --transition: all 0.3s ease;
    --header-height: 60px;
    --sidebar-width: 250px;
}

/* Image Preview Styles */
.image-preview-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    padding: 15px;
    border: 2px dashed var(--border-color);
    border-radius: var(--border-radius);
    background-color: #f9f9f9;
    min-height: 80px;
    transition: border-color 0.3s ease;
}

.image-preview-container:empty::after {
    content: "画像をドラッグ&ドロップするか、ファイル選択ボタンを使用してください";
    color: var(--text-light);
    font-style: italic;
    align-self: center;
    text-align: center;
    width: 100%;
}

.template-images-preview:empty::after {
    content: "「画像を追加」ボタンで参考画像を追加するか、ここに画像をドラッグ&ドロップしてください";
    color: var(--text-light);
    font-style: italic;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
    padding: 20px;
}

.preview-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: white;
    box-shadow: var(--shadow-sm);
}

.preview-image {
    width: 80px;
    height: 80px;
    object-fit: cover;
}

/* Template Images Preview */
.template-images-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #f9f9f9;
    min-height: 60px;
}

.template-image-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: white;
    box-shadow: var(--shadow-sm);
}

.template-settings {
    margin-top: 15px;
    padding: 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    background-color: #f8f9fa;
}
    border-radius: 4px;
    margin-bottom: 5px;
}

.preview-name {
    font-size: 12px;
    color: var(--text-light);
    text-align: center;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-image {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background-color: var(--danger-color);
    color: white;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.remove-image:hover {
    background-color: #c9302c;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #F5F7FA;
    min-height: 100vh;
}

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

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
}

.app-title {
    font-size: 24px;
    font-weight: bold;
    letter-spacing: -0.5px;
}

.nav-menu {
    display: flex;
    gap: 10px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-size: 14px;
    font-weight: 500;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

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

/* Main Content */
.main-content {
    margin-top: var(--header-height);
    padding: 30px 0;
    min-height: calc(100vh - var(--header-height));
}

/* Content Sections */
.content-section {
    display: none;
    animation: fadeIn 0.3s ease;
}

.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.section-header h2 {
    font-size: 28px;
    color: var(--dark-color);
}

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

/* Cards */
.card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h3 {
    font-size: 18px;
    margin-bottom: 15px;
    color: var(--dark-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 8px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    outline: none;
}

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

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

.btn-primary:hover:not(:disabled) {
    background: #3A7BC8;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--light-color);
    color: var(--text-color);
}

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

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

.btn-success:hover:not(:disabled) {
    background: #4CAE4C;
}

.btn-lg {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
}

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

.btn-danger:hover:not(:disabled) {
    background: #C9302C;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    cursor: pointer;
    margin-bottom: 0;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.help-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--text-light);
}

/* Dialogs Container */
.dialogs-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    min-height: 200px;
}

.dialog-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    transition: var(--transition);
}

.dialog-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.dialog-title {
    font-weight: bold;
    color: var(--primary-color);
}

.dialog-actions {
    display: flex;
    gap: 5px;
}

.dialog-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: var(--light-color);
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    font-size: 16px;
}

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

.dialog-content {
    margin-bottom: 15px;
}

.dialog-input {
    width: 100%;
    min-height: 100px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    resize: vertical;
    font-family: inherit;
    font-size: 14px;
}

.dialog-preview {
    background: #F8F9FA;
    padding: 10px;
    border-radius: var(--border-radius);
    font-size: 12px;
    color: var(--text-light);
}

.dialog-preview strong {
    color: var(--text-color);
}

.dialogs-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/* Gallery Container */
.gallery-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.view-toggle {
    display: flex;
    gap: 5px;
}

.view-btn {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--border-radius);
}

.view-btn:hover {
    background: var(--light-color);
}

.view-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.gallery-filters {
    display: flex;
    gap: 10px;
}

.gallery-filters .form-control {
    width: auto;
    min-width: 150px;
}

.gallery-container {
    min-height: 400px;
    margin-bottom: 30px;
}

.gallery-container.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.gallery-item {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    cursor: pointer;
    position: relative;
}

.gallery-item:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-lg);
}

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

.gallery-item-info {
    padding: 10px;
}

.gallery-item-title {
    font-weight: bold;
    margin-bottom: 5px;
}

.gallery-item-meta {
    font-size: 12px;
    color: var(--text-light);
}

.gallery-item-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: var(--transition);
}

.gallery-item:hover .gallery-item-actions {
    opacity: 1;
}

.gallery-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 20px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--light-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Generation Progress */
.generation-progress {
    margin-top: 20px;
}

.progress-item {
    padding: 15px;
    background: #F8F9FA;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
}

.progress-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-item-title {
    font-weight: bold;
}

.progress-status {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

.progress-status.pending {
    background: var(--warning-color);
    color: white;
}

.progress-status.generating {
    background: var(--primary-color);
    color: white;
}

.progress-status.completed {
    background: var(--success-color);
    color: white;
}

.progress-status.error {
    background: var(--danger-color);
    color: white;
}

/* Prompts List */
.prompts-list {
    max-height: 500px;
    overflow-y: auto;
}

.prompt-item {
    padding: 15px;
    background: #F8F9FA;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
}

.prompt-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.prompt-item-title {
    font-weight: bold;
    color: var(--primary-color);
}

.prompt-text {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-color);
    white-space: pre-wrap;
}

.prompt-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Settings */
.settings-container {
    max-width: 800px;
}

.settings-group {
    margin-bottom: 30px;
}

.prompts-container {
    max-width: 1200px;
    margin: 0 auto;
}

.storage-info {
    margin-bottom: 20px;
}

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

.template-list {
    margin-bottom: 20px;
}

.template-item {
    padding: 15px;
    background: #F8F9FA;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.template-name {
    font-weight: bold;
}

.template-actions {
    display: flex;
    gap: 5px;
}

/* Notifications */
.notification-container {
    position: fixed;
    top: calc(var(--header-height) + 20px);
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: white;
    padding: 15px 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.notification.success {
    border-left: 4px solid var(--success-color);
}

.notification.error {
    border-left: 4px solid var(--danger-color);
}

.notification.warning {
    border-left: 4px solid var(--warning-color);
}

.notification.info {
    border-left: 4px solid var(--primary-color);
}

.notification-icon {
    font-size: 20px;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: bold;
    margin-bottom: 2px;
}

.notification-message {
    font-size: 14px;
    color: var(--text-light);
}

.notification-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    animation: fadeIn 0.3s ease;
}

.modal {
    background: white;
    border-radius: var(--border-radius);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 20px;
    font-weight: bold;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Storyboard View */
.gallery-container.storyboard-view {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.storyboard-item {
    display: flex;
    gap: 20px;
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.storyboard-item-image {
    width: 300px;
    height: 200px;
    object-fit: cover;
    border-radius: var(--border-radius);
}

.storyboard-item-content {
    flex: 1;
}

.storyboard-item-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.storyboard-item-dialog {
    background: #F8F9FA;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
}

.storyboard-item-prompt {
    font-size: 14px;
    color: var(--text-light);
    font-style: italic;
}

/* Timeline View */
.gallery-container.timeline-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    padding-left: 40px;
}

.gallery-container.timeline-view::before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    display: flex;
    gap: 20px;
    position: relative;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -30px;
    top: 20px;
    width: 12px;
    height: 12px;
    background: var(--primary-color);
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: var(--shadow-sm);
}

.timeline-date {
    position: absolute;
    left: -120px;
    top: 15px;
    font-size: 12px;
    color: var(--text-light);
    font-weight: bold;
}

.timeline-content {
    flex: 1;
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .dialogs-container {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
    
    .gallery-container.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .section-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .gallery-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .gallery-filters {
        flex-direction: column;
    }
    
    .gallery-filters .form-control {
        width: 100%;
    }
    
    .dialogs-container {
        grid-template-columns: 1fr;
    }
    
    .gallery-container.grid-view {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
    
    .storyboard-item {
        flex-direction: column;
    }
    
    .storyboard-item-image {
        width: 100%;
    }
    
    .modal {
        width: 95%;
    }
    
    .notification-container {
        left: 10px;
        right: 10px;
    }
    
    .notification {
        min-width: auto;
        max-width: none;
    }
}

/* Accessibility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* API Status Styles */
.api-status .status {
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

.api-status .status.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.api-status .status.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.api-status .status.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.api-status .status.info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Print Styles */
@media print {
    .header,
    .nav-menu,
    .section-actions,
    .gallery-controls,
    .gallery-actions,
    .notification-container {
        display: none;
    }
    
    .main-content {
        margin-top: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #000;
    }
}