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

body {
    font-family: 'Noto Sans KR', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Section Styles */
section {
    background: white;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: #4a5568;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

/* Script Input Section */
.input-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

#scriptInput {
    width: 100%;
    min-height: 200px;
    padding: 20px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s ease;
}

#scriptInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.input-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-view {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #f7fafc;
    color: #4a5568;
    border: 2px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.btn-view {
    background: #f7fafc;
    color: #4a5568;
    border: 2px solid #e2e8f0;
    padding: 8px 16px;
}

.btn-view.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* Progress Section */
.progress-section {
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

/* Storyboard Controls */
.storyboard-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.view-options {
    display: flex;
    gap: 10px;
}

/* Storyboard Container */
.storyboard-container {
    min-height: 200px;
}

.storyboard-container.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 30px;
}

.storyboard-container.list-view {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Storyboard Shot Card */
.shot-card {
    border: 2px solid #e2e8f0;
    border-radius: 15px;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
}

.shot-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.1);
    border-color: #667eea;
}

.shot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shot-title {
    font-size: 1.2rem;
    font-weight: 600;
}

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

.shot-actions button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.shot-actions button:hover {
    background: rgba(255,255,255,0.3);
}

.shot-content {
    display: flex;
    height: 300px;
}

.shot-image {
    flex: 1;
    position: relative;
    overflow: hidden;
}

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

.image-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: #f7fafc;
    color: #4a5568;
}

.shot-details {
    flex: 1;
    padding: 20px;
    background: #f7fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.9rem;
}

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.detail-label {
    font-weight: 600;
    color: #4a5568;
    min-width: 80px;
    flex-shrink: 0;
}

.detail-value {
    color: #2d3748;
    flex: 1;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #9ca3af;
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: 20px;
}

.empty-state p {
    font-size: 1.1rem;
}

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

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 15px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 15px 15px 0 0;
}

.modal-header h3 {
    font-size: 1.4rem;
    font-weight: 600;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.close-btn:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 30px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #4a5568;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    section {
        padding: 20px;
    }
    
    .storyboard-container.grid-view {
        grid-template-columns: 1fr;
    }
    
    .shot-content {
        flex-direction: column;
        height: auto;
    }
    
    .shot-image {
        height: 200px;
    }
    
    .input-actions {
        flex-direction: column;
    }
    
    .storyboard-controls {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    .modal-content {
        margin: 10px;
        width: calc(100% - 20px);
    }
    
    .modal-body {
        padding: 20px;
    }
}

/* Loading Animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.fa-spin {
    animation: spin 1s infinite linear;
}

/* AI Image Settings */
.ai-image-settings {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 15px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 10px 30px rgba(240, 147, 251, 0.3);
}

/* API Status */
.api-status {
    margin-bottom: 15px;
    padding: 10px 15px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.status-indicator.online i {
    color: #4ade80;
    animation: pulse-green 2s infinite;
}

.status-indicator.offline i {
    color: #fbbf24;
    animation: pulse-yellow 2s infinite;
}

.status-indicator.warning i {
    color: #f59e0b;
    animation: pulse-orange 2s infinite;
}

.status-indicator.error i {
    color: #ef4444;
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-yellow {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-orange {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pulse-red {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* API Key Setup */
.setup-api-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.setup-api-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.api-key-section {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.api-key-input label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

.api-key-input input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 0.9rem;
}

.api-key-input input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.api-key-input input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.15);
}

.toggle-btn, .save-btn {
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.toggle-btn:hover, .save-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.save-btn {
    background: rgba(76, 175, 80, 0.8);
    border-color: rgba(76, 175, 80, 0.8);
}

.save-btn:hover {
    background: rgba(76, 175, 80, 1);
}

.api-key-input small {
    display: block;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
}

.api-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.test-api-btn {
    background: rgba(33, 150, 243, 0.8);
    color: white;
    border: 1px solid rgba(33, 150, 243, 0.8);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.test-api-btn:hover {
    background: rgba(33, 150, 243, 1);
}

.test-api-btn:disabled {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
    cursor: not-allowed;
}

.debug-btn {
    background: rgba(156, 39, 176, 0.8);
    color: white;
    border: 1px solid rgba(156, 39, 176, 0.8);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.debug-btn:hover {
    background: rgba(156, 39, 176, 1);
}

.debug-panel {
    margin-top: 15px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.debug-panel h5 {
    margin: 0 0 10px 0;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.9);
}

.debug-info {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

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

.copy-btn, .clear-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.3s ease;
}

.copy-btn:hover, .clear-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 480px) {
    .api-buttons {
        flex-direction: column;
        gap: 8px;
    }
    
    .debug-actions {
        flex-direction: column;
    }
}

.ai-image-settings h3,
.ai-image-settings h4 {
    color: white;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.ai-image-settings .setting-group label {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
}

.ai-image-settings .setting-group select,
.ai-image-settings .setting-group input {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    color: #4a5568;
}

.ai-image-settings .setting-group select:focus,
.ai-image-settings .setting-group input:focus {
    background: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

/* Reference Image Upload */
.reference-image-section {
    margin-top: 20px;
}

.image-upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.5);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.1);
}

.image-upload-area:hover {
    border-color: rgba(255, 255, 255, 0.8);
    background: rgba(255, 255, 255, 0.15);
}

.image-upload-area.drag-over {
    border-color: white;
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.02);
}

.upload-placeholder i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.8;
}

.upload-placeholder p {
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.upload-placeholder small {
    opacity: 0.7;
    font-size: 0.9rem;
}

.uploaded-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.uploaded-image {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    aspect-ratio: 1;
}

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

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

.uploaded-image .remove-btn:hover {
    background: white;
    transform: scale(1.1);
}

/* Style Presets */
.style-presets {
    margin-top: 20px;
}

.preset-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 15px;
}

.preset-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-align: center;
    min-height: 44px;
}

.preset-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
    transform: translateY(-2px);
}

.preset-btn.active {
    background: white;
    color: #f5576c;
    border-color: white;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(255, 255, 255, 0.3);
}

/* 특별한 스타일 버튼들 */
.preset-btn[data-style="hyperrealistic"]:hover {
    background: rgba(255, 215, 0, 0.3);
    border-color: rgba(255, 215, 0, 0.6);
    transform: translateY(-3px);
}

.preset-btn[data-style="dreamworks3d"]:hover {
    background: rgba(0, 191, 255, 0.3);
    border-color: rgba(0, 191, 255, 0.6);
    transform: translateY(-3px);
}

.preset-btn[data-style="dreamworks3d"].active {
    background: linear-gradient(135deg, #00bfff, #1e90ff);
    color: white;
    border-color: #00bfff;
}

.preset-btn[data-style="hyperrealistic"].active {
    background: linear-gradient(135deg, #ffd700, #ffb347);
    color: #333;
    border-color: #ffd700;
}

/* Camera Settings */
.camera-settings {
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
}

.camera-settings h3 {
    font-size: 1.2rem;
    color: #4a5568;
    margin-bottom: 15px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

.camera-settings h4 {
    font-size: 1rem;
    color: #4a5568;
    margin-bottom: 12px;
    margin-top: 15px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.setting-group label {
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
}

.setting-group select {
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    transition: border-color 0.3s ease;
}

.setting-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-toggle {
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    color: #4a5568;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
    margin-top: 10px;
}

.btn-toggle:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.btn-toggle.active i {
    transform: rotate(180deg);
}

.advanced-settings {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
    animation: slideDown 0.3s ease;
}

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

/* AI Image Settings Responsive */
@media (max-width: 768px) {
    .settings-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .camera-settings,
    .ai-image-settings {
        padding: 15px;
    }
    
    .setting-group select,
    .setting-group input {
        padding: 12px;
        font-size: 1rem;
    }
    
    .preset-buttons {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .preset-btn {
        font-size: 0.8rem;
        padding: 8px 10px;
        min-height: 40px;
    }
}

@media (max-width: 480px) {
    .preset-buttons {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .preset-btn {
        font-size: 0.9rem;
        padding: 12px 16px;
    }
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

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