* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

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

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

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

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

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

.mode-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px 30px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.95rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
}

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

.mode-btn.active {
    background: white;
    color: #667eea;
    border-color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.mode-btn.active[data-mode="video"] {
    color: #ff6b6b;
}

.mode-icon {
    font-size: 1.8rem;
}

.mode-label {
    font-size: 0.9rem;
    white-space: nowrap;
}

/* Mode Container */
.mode-container {
    display: none;
}

.mode-container.active {
    display: block;
}

main {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.input-section {
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: #333;
    font-size: 1rem;
}

textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.3s;
}

textarea:focus {
    outline: none;
    border-color: #667eea;
}

select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

select:focus {
    outline: none;
    border-color: #667eea;
}

.dimension-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.custom-dimensions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e1e8ed;
}

.custom-dimensions input {
    width: 120px;
    padding: 8px 12px;
    border: 2px solid #e1e8ed;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
}

.custom-dimensions span {
    color: #666;
    font-weight: 600;
}

.file-input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: stretch;
}

.file-input-container input[type="file"] {
    flex: 1;
    margin: 0;
}

.add-more-btn {
    padding: 10px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.3s;
    white-space: nowrap;
}

.add-more-btn:hover {
    background: #5a67d8;
}

.add-more-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.file-input-help {
    margin-bottom: 8px;
    font-size: 0.85rem;
    color: #666;
    padding: 6px 12px;
    background: #fff8dc;
    border-radius: 6px;
    border-left: 3px solid #ffd700;
}

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

input[type="file"]:hover {
    border-color: #667eea;
    background: #f0f3ff;
}

.image-preview {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.preview-item {
    position: relative;
    width: 120px;
    height: 120px;
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ff4757;
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.remove-btn:hover {
    transform: scale(1.1);
}

.generate-btn {
    width: 100%;
    padding: 16px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

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

.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.error-message {
    margin-top: 15px;
    padding: 12px 16px;
    background: #fee;
    color: #c33;
    border-radius: 8px;
    border-left: 4px solid #c33;
}

.conversation-section {
    margin-top: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 2px solid #e1e8ed;
}

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

.conversation-header h2 {
    color: #333;
    margin: 0;
    font-size: 1.5rem;
}

.new-conversation-btn {
    padding: 8px 16px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.new-conversation-btn:hover {
    background: #5a67d8;
}

.conversation-history {
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.conversation-item {
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.conversation-item.follow-up {
    border-left: 4px solid #667eea;
}

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

.conversation-timestamp {
    font-size: 0.8rem;
    color: #666;
}

.conversation-prompt {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.conversation-images {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.conversation-image {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.results-section {
    margin-top: 40px;
    padding-top: 40px;
    border-top: 2px solid #e1e8ed;
}

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

.results-header h3 {
    color: #333;
    margin: 0;
}

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

.suggest-btn {
    padding: 8px 16px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: transform 0.2s;
}

.suggest-btn:hover {
    transform: translateY(-1px);
}

.suggestions-section {
    margin-top: 25px;
    padding: 20px;
    background: #fff8dc;
    border-radius: 15px;
    border: 2px solid #ffd700;
}

.suggestions-section h4 {
    color: #333;
    margin-bottom: 15px;
}

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

.suggestion-card {
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.suggestion-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.suggestion-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.suggestion-prompt {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

.follow-up-section {
    margin-top: 25px;
    padding: 20px;
    background: #f0f3ff;
    border-radius: 15px;
    border: 2px solid #667eea;
}

.follow-up-section h4 {
    color: #333;
    margin-bottom: 15px;
}

.follow-up-section textarea {
    width: 100%;
    margin-bottom: 15px;
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-family: inherit;
    resize: vertical;
}

.continue-btn {
    width: 100%;
    padding: 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.3s;
}

.continue-btn:hover {
    background: #5a67d8;
}

.generated-text {
    padding: 16px;
    background: #f8f9fa;
    border-radius: 10px;
    margin-bottom: 20px;
    line-height: 1.6;
    color: #555;
}

.generated-images {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.generated-image-container {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.generated-image-container img {
    width: 100%;
    height: auto;
    display: block;
}

.download-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    padding: 8px 16px;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

.download-btn:hover {
    background: rgba(0,0,0,0.9);
}

.dimension-info {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.save-info {
    margin: 15px 0;
    padding: 12px 16px;
    background: #e8f5e8;
    border: 2px solid #4caf50;
    border-radius: 10px;
    animation: fadeIn 0.5s ease-in;
}

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

.save-icon {
    font-size: 1.2rem;
}

.save-text {
    color: #2e7d32;
    font-weight: 600;
}

.save-location {
    color: #1565c0;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    background: rgba(255,255,255,0.7);
    padding: 2px 6px;
    border-radius: 4px;
}

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

footer {
    margin-top: 30px;
    text-align: center;
}

.status {
    color: white;
    font-size: 0.9rem;
}

.status-ok {
    color: #4ade80;
}

.status-error {
    color: #fbbf24;
}

/* Video-Specific Styles */
.video-generate-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a52 100%);
}

.video-generate-btn:hover:not(:disabled) {
    box-shadow: 0 10px 30px rgba(255, 107, 107, 0.4);
}

.video-config-panel {
    padding: 20px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px solid #e1e8ed;
    margin-bottom: 20px;
}

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

.video-duration-info {
    text-align: center;
    padding: 10px;
    background: white;
    border-radius: 8px;
    color: #666;
    font-size: 0.9rem;
}

.conditional-input {
    margin-bottom: 20px;
}

.frame-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.video-preview-container {
    margin-top: 15px;
}

.video-preview-container video {
    width: 100%;
    max-height: 300px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.prompt-help {
    margin-top: 8px;
    font-size: 0.85rem;
    color: #666;
    padding: 8px 12px;
    background: #fff8dc;
    border-radius: 6px;
    border-left: 3px solid #ffd700;
}

.video-progress {
    margin-top: 20px;
    padding: 20px;
    background: #f0f9ff;
    border-radius: 12px;
    border: 2px solid #3b82f6;
}

.progress-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.progress-icon {
    font-size: 1.5rem;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.progress-text {
    color: #1e40af;
    font-weight: 600;
}

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

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    border-radius: 4px;
    animation: progressIndeterminate 1.5s linear infinite;
}

@keyframes progressIndeterminate {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.generated-videos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.video-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    background: #000;
}

.video-container video {
    width: 100%;
    height: auto;
    display: block;
}

.video-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    display: flex;
    gap: 10px;
    justify-content: center;
}

.video-btn {
    padding: 8px 16px;
    background: rgba(255,255,255,0.9);
    color: #333;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s;
}

.video-btn:hover {
    background: white;
    transform: translateY(-2px);
}

.video-metadata {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 6px 12px;
    background: rgba(0,0,0,0.7);
    color: white;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.retention-warning {
    margin-top: 8px;
    padding: 8px 12px;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #856404;
}

.video-follow-up-actions {
    display: flex;
    gap: 10px;
}

.video-follow-up-actions .continue-btn {
    flex: 1;
}

.continue-btn.secondary {
    background: #6c757d;
}

.continue-btn.secondary:hover {
    background: #5a6268;
}

.video-type-select {
    font-size: 1rem;
}

input[type="text"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    main {
        padding: 25px;
    }

    .generated-images {
        grid-template-columns: 1fr;
    }

    .mode-selector {
        flex-direction: column;
        gap: 10px;
    }

    .mode-btn {
        width: 100%;
    }

    .frame-inputs {
        grid-template-columns: 1fr;
    }

    .config-row {
        grid-template-columns: 1fr;
    }

    .generated-videos {
        grid-template-columns: 1fr;
    }

    .video-follow-up-actions {
        flex-direction: column;
    }
}

/* Authentication Styles */
.auth-section {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.auth-container {
    background: white;
    padding: 60px 50px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 450px;
    width: 90%;
}

.auth-container h2 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.8rem;
}

.auth-container p {
    color: #666;
    margin-bottom: 30px;
    line-height: 1.6;
}

.login-btn {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: white;
    color: #444;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.login-btn:hover {
    background: #f8f8f8;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.user-info {
    margin-top: 30px;
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 8px;
}

.user-picture {
    width: 50px;
    height: 50px;
    border-radius: 50%;
}

.user-details {
    flex: 1;
    text-align: left;
}

.user-details p {
    margin: 0;
    padding: 4px 0;
}

.logout-btn {
    padding: 8px 16px;
    background: #d32f2f;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.logout-btn:hover {
    background: #b71c1c;
}

/* Header user badge */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header-title {
    text-align: left;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 16px;
    border-radius: 25px;
    color: white;
}

.user-badge-picture {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.user-badge span {
    font-size: 14px;
    font-weight: 500;
}

.header-logout-btn {
    padding: 6px 14px;
    background: rgba(255, 255, 255, 0.3);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s;
}

.header-logout-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

@media (max-width: 768px) {
    .auth-container {
        padding: 40px 30px;
    }

    .header-content {
        flex-direction: column;
        gap: 15px;
    }

    .header-title {
        text-align: center;
    }

    .user-badge {
        width: 100%;
        justify-content: center;
    }
}