@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Montserrat:ital,wght@0,400;0,500;0,600;0,700;1,600&display=swap');

:root {
    --color-bg: #f8f6f4;
    --color-card: #ffffff;
    --color-text: #1a1a1a;
    --color-text-secondary: #666666;
    --color-text-muted: #999999;
    --color-border: #e8e8e8;
    --color-border-hover: #d0d0d0;
    --color-accent: #FF4242;
    --color-accent-light: #FF9B9B;
    --color-accent-orange: #FF844C;
    --gradient-accent: linear-gradient(135deg, #FF4242 0%, #FF844C 50%, #FF9B9B 100%);
    --gradient-button: linear-gradient(90deg, #FF4242 0%, #FF844C 100%);
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-display: 'Montserrat', 'Inter', sans-serif;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.06);
    --shadow-button: 0 4px 16px rgba(255, 66, 66, 0.3);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

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

body {
    font-family: var(--font-main);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
    background-image: url('./public/background.png');
    background-repeat: repeat;
    background-position: top;
    background-size: 100% auto;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

.app-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 40px 24px;
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
    padding-bottom: max(40px, env(safe-area-inset-bottom));
}

/* Header */
.app-header {
    margin-bottom: 32px;
}

.app-header h1 {
    font-family: var(--font-display);
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
    margin-bottom: 8px;
}

.app-header h1 span {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-style: italic;
}

.app-header p {
    display: none;
}

.header-features {
    display: flex;
    gap: 24px;
    margin-top: 16px;
}

.header-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    color: var(--color-text-secondary);
}

.header-feature .check {
    width: 20px;
    height: 20px;
    background: var(--gradient-accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
}

.header-feature strong {
    color: var(--color-text);
    font-weight: 600;
}

/* Main Card Container */
.main-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 32px;
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 32px;
}

/* Left Section - Selection */
.selection-section {
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 16px;
}

/* Persona Slider */
.persona-slider {
    position: relative;
    max-width: 850px;
}

.personas-grid {
    display: flex;
    gap: 16px;
    overflow-x: scroll;
    overflow-y: hidden;
    padding: 4px 4px 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.personas-grid::-webkit-scrollbar {
    display: none;
}

.slider-arrow {
    position: absolute;
    top: 45px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    line-height: 1;
    color: var(--color-text);
    z-index: 10;
    transition: all 0.25s ease;
    padding: 0;
    opacity: 0;
}

.slider-arrow.visible {
    opacity: 1;
}

.slider-arrow:hover {
    background: #f5f5f5;
    border-color: var(--color-border-hover);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    transform: scale(1.05);
}

.slider-arrow:active {
    transform: scale(0.95);
}

.slider-arrow--left {
    left: -12px;
}

.slider-arrow--right {
    right: -12px;
}

.persona-card {
    flex-shrink: 0;
    width: 150px;
    cursor: pointer;
    text-align: center;
    position: relative;
}

.persona-image-wrapper {
    width: 150px;
    height: 150px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.2s ease;
    position: relative;
}

.persona-card:hover .persona-image-wrapper {
    border-color: var(--color-border-hover);
}

.persona-card.selected .persona-image-wrapper {
    border-color: var(--color-accent);
}

.persona-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.persona-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
    margin-top: 8px;
    line-height: 1.3;
}

.persona-indicator {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--color-card);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.persona-card.selected .persona-indicator {
    opacity: 1;
}

.persona-indicator::after {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--gradient-accent);
    border-radius: 50%;
}

/* Templates Grid */
.templates-grid {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 20px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 200px;
    position: relative;
}

.template-card:hover {
    border-color: var(--color-border-hover);
    background: #fafafa;
}

.template-card.selected {
    border-color: var(--color-accent);
    background: #fff5f5;
}

.template-icon {
    font-size: 1.5rem;
}

.template-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text);
    text-align: center;
}

.template-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 16px;
    height: 16px;
    background: var(--color-text);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.template-card.selected .template-indicator {
    opacity: 1;
}

/* Custom Text Template */
.template-card--custom {
    border-style: dashed;
}

.template-card--custom:hover,
.template-card--custom.selected {
    border-style: solid;
}

/* Right Section - Form */
.form-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-section .section-title {
    font-size: 1.25rem;
    margin-bottom: 4px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 14px 16px;
    font-size: 0.95rem;
    font-family: var(--font-main);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-card);
    color: var(--color-text);
    transition: all 0.2s ease;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-text-muted);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(255, 66, 66, 0.1);
}

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

.char-count {
    text-align: right;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: -4px;
}

/* Checkbox */
.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.checkbox-wrapper input[type="checkbox"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-wrapper input[type="checkbox"]:checked {
    background: var(--color-accent);
    border-color: var(--color-accent);
}

.checkbox-wrapper input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: 700;
}

.checkbox-wrapper span {
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

/* Preview Section */
.preview-section {
    background: #f8f8f8;
    border-radius: var(--radius-sm);
    padding: 16px;
    display: none;
}

.preview-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-text {
    font-size: 0.95rem;
    color: var(--color-text);
    line-height: 1.6;
    font-style: italic;
    min-height: 20px;
}

/* Buttons */
.btn {
    padding: 14px 24px;
    font-size: 0.95rem;
    font-family: var(--font-main);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--gradient-button);
    color: white;
    box-shadow: var(--shadow-button);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 66, 66, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

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

.btn-secondary {
    background: var(--color-card);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: #f5f5f5;
    border-color: var(--color-border-hover);
}

.btn-large {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
    border-radius: var(--radius-md);
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 24px;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-container p {
    font-size: 1rem;
    color: var(--color-text-secondary);
}

/* Video Result */
.video-result {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.video-container {
    background: var(--color-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-card);
}

.generated-video {
    width: 100%;
    display: block;
}

.video-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.video-actions .btn {
    min-width: 160px;
}

/* History Section */
.history-section {
    margin-top: 32px;
}

.history-section .section-title {
    margin-bottom: 16px;
}

.history-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 24px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    transition: all 0.2s ease;
}

.history-item:hover {
    background: #fafafa;
    border-color: var(--color-border-hover);
}

.history-item--processing,
.history-item--pending {
    position: relative;
    overflow: hidden;
}

.history-item--processing::after,
.history-item--pending::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 66, 66, 0.05), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}

.history-item--failed {
    border-color: #ffcdd2;
}

.history-item__image {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.history-item__content {
    flex: 1;
    min-width: 0;
}

.history-item__celeb {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
    margin-bottom: 2px;
}

.history-item__text {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.history-item__date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.history-item__status {
    flex-shrink: 0;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge--pending {
    background: #fff3e0;
    color: #e65100;
}

.status-badge--processing {
    background: #e3f2fd;
    color: #1565c0;
}

.status-badge--completed {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge--failed {
    background: #ffebee;
    color: #c62828;
}

.history-item__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.8rem;
}

.mini-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Video Modal */
.video-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    backdrop-filter: blur(8px);
}

.video-modal__content {
    position: relative;
    max-width: 800px;
    width: 100%;
    background: var(--color-card);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.video-modal__close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    color: var(--color-text);
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.video-modal__close:hover {
    background: #f5f5f5;
    transform: scale(1.05);
}

.video-modal__video {
    width: 100%;
    display: block;
}

/* Step sections - hide on new design */
.step-section {
    display: none;
}

.step-title {
    display: none;
}

.subsection-title {
    display: none;
}

/* Toggle section - integrated into form */
.toggle-section {
    display: none;
}

/* Responsive */

/* Tablet */
@media (max-width: 1024px) {
    .main-card {
        grid-template-columns: 1fr;
        gap: 28px;
    }

    .form-section {
        border-top: 1px solid var(--color-border);
        padding-top: 28px;
    }

    .persona-slider {
        max-width: 100%;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .app-container {
        padding: 20px 16px;
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
        overflow-x: hidden;
        max-width: 100vw;
    }

    .app-header {
        margin-bottom: 24px;
    }

    .app-header h1 {
        font-size: 1.6rem;
    }

    .app-header h1 br {
        display: none;
    }

    .header-features {
        flex-direction: column;
        gap: 8px;
        margin-top: 12px;
    }

    .header-feature {
        font-size: 0.85rem;
    }

    .main-card {
        padding: 20px 16px;
        border-radius: var(--radius-md);
        overflow-x: hidden;
    }

    .section-title {
        font-size: 1rem;
        margin-bottom: 12px;
    }

    .selection-section {
        gap: 24px;
        overflow: hidden;
    }

    /* Persona slider mobile */
    .persona-slider {
        margin: 0 -16px;
        padding: 0 16px;
        max-width: calc(100% + 32px);
        overflow: hidden;
    }

    .personas-grid {
        gap: 12px;
        padding: 4px 16px 8px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .persona-card {
        width: 90px;
    }

    .persona-image-wrapper {
        width: 90px;
        height: 90px;
    }

    .persona-name {
        font-size: 0.75rem;
        margin-top: 6px;
    }

    .persona-indicator {
        width: 16px;
        height: 16px;
        bottom: 2px;
        right: 2px;
    }

    .persona-indicator::after {
        width: 10px;
        height: 10px;
    }

    /* Hide slider arrows on mobile - use swipe */
    .slider-arrow {
        display: none;
    }

    /* Templates mobile */
    .templates-grid {
        gap: 8px;
        flex-wrap: nowrap;
        overflow-x: auto;
        margin: 0 -16px;
        padding: 4px 16px 8px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .templates-grid::-webkit-scrollbar {
        display: none;
    }

    .template-card {
        padding: 12px 14px;
        min-width: auto;
        flex-shrink: 0;
    }

    .template-icon {
        font-size: 1.3rem;
    }

    .template-name {
        font-size: 0.75rem;
        white-space: nowrap;
    }

    .template-indicator {
        width: 12px;
        height: 12px;
        top: 6px;
        right: 6px;
    }

    /* Form mobile */
    .form-section {
        gap: 16px;
    }

    .form-section .section-title {
        font-size: 1.1rem;
    }

    .form-group {
        gap: 6px;
    }

    .form-group label {
        font-size: 0.85rem;
    }

    .form-input,
    .form-textarea {
        padding: 12px 14px;
        font-size: 0.9rem;
        border-radius: 10px;
    }

    .form-textarea {
        min-height: 100px;
    }

    .checkbox-wrapper {
        gap: 8px;
    }

    .checkbox-wrapper input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }

    .checkbox-wrapper span {
        font-size: 0.85rem;
    }

    .btn-large {
        padding: 14px;
        font-size: 0.95rem;
        border-radius: var(--radius-sm);
    }

    /* Video actions */
    .video-actions {
        flex-direction: column;
        gap: 10px;
    }

    .video-actions .btn {
        width: 100%;
    }

    /* History mobile */
    .history-section {
        margin-top: 24px;
    }

    .history-card {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    .history-item {
        flex-wrap: wrap;
        padding: 12px;
        gap: 8px 12px;
    }

    .history-item__image {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }

    .history-item__content {
        flex: 1;
        min-width: calc(100% - 60px - 80px);
    }

    .history-item__celeb {
        font-size: 0.9rem;
    }

    .history-item__text {
        font-size: 0.8rem;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .history-item__date {
        font-size: 0.7rem;
    }

    .history-item__status {
        flex-shrink: 0;
    }

    .status-badge {
        padding: 4px 12px;
        font-size: 0.7rem;
    }

    .history-item__actions {
        display: flex;
        width: 100%;
        gap: 8px;
        margin-top: 4px;
    }

    .btn-small {
        padding: 10px 14px;
        font-size: 0.8rem;
        flex: 1;
        min-height: 44px;
    }

    /* Video modal mobile */
    .video-modal {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .video-modal__content {
        border-radius: var(--radius-sm);
    }

    .video-modal__close {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 8px;
        right: 8px;
    }

    /* Loading */
    .loading-container {
        min-height: 200px;
        gap: 20px;
    }

    .spinner {
        width: 40px;
        height: 40px;
    }

    .loading-container p {
        font-size: 0.9rem;
    }
}

/* Small mobile */
@media (max-width: 380px) {
    .app-container {
        padding: 16px 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .app-header h1 {
        font-size: 1.4rem;
    }

    .main-card {
        padding: 16px 12px;
    }

    .persona-slider {
        margin: 0 -12px;
        padding: 0 12px;
        max-width: calc(100% + 24px);
    }

    .personas-grid {
        padding: 4px 12px 8px;
    }

    .persona-card {
        width: 80px;
    }

    .persona-image-wrapper {
        width: 80px;
        height: 80px;
    }

    .templates-grid {
        margin: 0 -12px;
        padding: 4px 12px 8px;
    }

    .template-card {
        padding: 10px 12px;
        min-height: 44px;
    }

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

    .template-name {
        font-size: 0.7rem;
    }

    .btn-small {
        padding: 12px 14px;
        min-height: 44px;
    }
}

/* Ensure minimum touch targets on all mobile */
@media (max-width: 768px) {
    .template-card {
        min-height: 56px;
    }

    .persona-card {
        min-height: 44px;
    }

    .checkbox-wrapper {
        min-height: 44px;
        padding: 8px 0;
    }

    .form-input,
    .form-textarea {
        min-height: 48px;
    }
}
