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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

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

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo i {
    font-size: 2rem;
    color: #667eea;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: #666;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-btn:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

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

/* Main Content */
.main {
    padding: 2rem 0;
}

/* Cards */
.card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 2rem;
}

.card-header {
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-bottom: 1px solid #e2e8f0;
}

.card-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: #334155;
    margin-bottom: 0.5rem;
}

.card-header p {
    color: #64748b;
    font-size: 0.95rem;
}

.card-header .btn {
    margin-left: auto;
}

.card-body {
    padding: 2rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

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

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

.form-group select {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    font-family: inherit;
    background: white;
}

.input-hint {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #0369a1;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

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

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

.btn-secondary {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #e2e8f0;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Tab Content */
.tab-content {
    display: none;
}

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

/* Projects Grid */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.project-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.3s ease;
    cursor: pointer;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.project-id {
    background: #667eea;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.project-date {
    font-size: 0.875rem;
    color: #64748b;
}

.project-script {
    margin-bottom: 1rem;
    color: #374151;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #64748b;
}

.project-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

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

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #64748b;
    padding: 0.5rem;
    border-radius: 4px;
}

.modal-close:hover {
    background: #e2e8f0;
}

.modal-body {
    padding: 2rem;
    max-height: 70vh;
    overflow-y: auto;
}

/* Project Details */
.project-info {
    margin-bottom: 2rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.info-item {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
}

.info-label {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.25rem;
}

.info-value {
    font-weight: 500;
    color: #374151;
}

.scenes-section {
    margin-top: 2rem;
}

.scenes-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.scene-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
}

.scene-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.scene-order {
    background: #667eea;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.scene-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-pending {
    background: #fef3c7;
    color: #92400e;
}

.status-generating {
    background: #dbeafe;
    color: #1e40af;
}

.status-completed {
    background: #d1fae5;
    color: #065f46;
}

.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.scene-content {
    margin-bottom: 0.75rem;
    color: #374151;
    line-height: 1.5;
}

.scene-prompt {
    font-size: 0.875rem;
    color: #64748b;
    font-style: italic;
    margin-bottom: 0.75rem;
}

.scene-video {
    margin-top: 0.75rem;
}

.scene-video video {
    width: 100%;
    max-width: 300px;
    border-radius: 8px;
}

/* Loading */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2000;
}

.loading-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

.loading-spinner p {
    font-size: 1.125rem;
    color: #64748b;
}

/* Progress UI */
.progress-container {
    margin-top: 1rem;
    width: min(560px, 80vw);
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

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

.progress-messages {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0 0;
    color: #6b7280;
    font-size: 0.95rem;
}

.progress-messages li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.25rem 0;
}

.progress-messages li::before {
    content: '\2022';
    color: #667eea;
    font-weight: bold;
}

.progress-summary {
    margin-top: 0.5rem;
    color: #374151;
    font-size: 0.95rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #667eea;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    border-left-color: #10b981;
}

.toast.error {
    border-left-color: #ef4444;
}

.toast.warning {
    border-left-color: #f59e0b;
}

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

/* Hangfire Container */
.hangfire-container {
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        width: 100%;
        justify-content: center;
    }
    
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 1rem;
        max-width: calc(100vw - 2rem);
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* API Settings Styles */
.settings-section {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.settings-section h3 {
    color: #495057;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.settings-section h3 i {
    margin-right: 0.5rem;
    color: #6c757d;
}

.input-group {
    position: relative;
    display: flex;
}

.input-group input {
    flex: 1;
    border-radius: 4px 0 0 4px;
    border-right: none;
}

.input-group .btn {
    border-radius: 0 4px 4px 0;
    border-left: none;
    padding: 0.5rem 0.75rem;
}

.textarea-group {
    position: relative;
    display: flex;
}

.textarea-group textarea {
    flex: 1;
    border-radius: 4px 0 0 4px;
    border-right: none;
    resize: vertical;
}

.textarea-group .textarea-toggle {
    border-radius: 0 4px 4px 0;
    border-left: none;
    padding: 0.5rem 0.75rem;
    align-self: flex-start;
    margin-top: 0;
}

.form-hint {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
}

.form-hint i {
    margin-right: 0.25rem;
}

.form-hint a {
    color: #007bff;
    text-decoration: none;
}

.form-hint a:hover {
    text-decoration: underline;
}

.settings-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e9ecef;
}

.status-configured {
    color: #28a745;
}

.status-not-configured {
    color: #dc3545;
}

.credential-options {
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
}

.credential-method {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
    cursor: pointer;
    font-weight: 500;
}

.credential-method:last-child {
    margin-bottom: 0;
}

.credential-method input[type="radio"] {
    margin-right: 0.5rem;
}

.env-info {
    padding: 1rem;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    color: #155724;
}

.env-info code {
    background: #c3e6cb;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

.text-success {
    color: #28a745 !important;
}

/* API Setup Notification */
.api-setup-notification {
    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: 10000;
}

.notification-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}

.notification-content i.fa-exclamation-triangle {
    color: #ffc107;
    font-size: 1.5rem;
    margin-top: 0.25rem;
}

.notification-text {
    flex: 1;
}

.notification-text strong {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
}

.notification-text p {
    margin: 0;
    color: #666;
    line-height: 1.4;
}

.notification-content .btn {
    margin-left: 0.5rem;
    margin-top: 1rem;
}

/* Responsive adjustments for settings */
@media (max-width: 768px) {
    .settings-section {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .settings-actions {
        flex-direction: column;
    }
    
    .settings-actions .btn {
        width: 100%;
    }
}
