/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

/* ===== CSS Variables ===== */
:root {
    --color-black: #1a1a1a;
    --color-dark: #2d2d2d;
    --color-pink: #d6006f;
    --color-pink-light: #e91e8c;
    --color-white: #ffffff;
    --color-cream: #faf8f5;
    --color-gray-light: #f5f5f5;
    --color-gray: #888888;
    --color-gray-dark: #666666;
    --color-error: #d64545;
    --color-success: #28a745;
    
    --font-main: 'Plus Jakarta Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    
    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 8px 30px rgba(0, 0, 0, 0.12);
    
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-main);
    font-weight: 400;
    line-height: 1.6;
    color: var(--color-dark);
    background-color: var(--color-cream);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== Header ===== */
.header {
    background-color: var(--color-black);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: var(--shadow-medium);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.logo-img {
    height: 50px;
    width: auto;
}

/* ===== Main Container ===== */
.main-container {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    width: 100%;
}

/* ===== Generator Section ===== */
.generator-section {
    background: var(--color-white);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--shadow-soft);
}

.main-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-black);
    text-align: center;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.sparkle-icon {
    display: inline-flex;
    align-items: center;
    margin-right: 0.35rem;
    color: var(--color-pink);
}

.sparkle-icon svg {
    width: 28px;
    height: 28px;
}

.main-subtitle {
    font-size: 0.9rem;
    color: var(--color-gray-dark);
    text-align: center;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.main-subtitle strong {
    color: var(--color-black);
    font-weight: 600;
}

.limit-note {
    font-size: 0.8rem;
    color: var(--color-gray);
    text-align: center;
    margin-bottom: 1rem;
    font-style: italic;
}

.input-area {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-dark);
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
}

.input-hint {
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--color-gray);
    font-style: italic;
}

.prompt-input-wrapper {
    position: relative;
    background-color: var(--color-white);
    border-radius: 12px;
}

.prompt-placeholder {
    position: absolute;
    top: 0.75rem;
    left: 1rem;
    right: 1rem;
    bottom: 0.75rem;
    font-size: 15px;
    color: #999;
    line-height: 1.5;
    pointer-events: none;
    transition: opacity var(--transition-fast);
    overflow: hidden;
}

.prompt-placeholder.hidden {
    opacity: 0;
}

.placeholder-highlight {
    color: var(--color-pink);
    font-weight: 600;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.input-hint-text {
    font-size: 0.8rem;
    color: var(--color-gray);
}

.input-counter {
    font-size: 0.8rem;
    color: var(--color-gray);
    text-align: right;
}

.input-counter.warning {
    color: var(--color-error);
}

.min-warning {
    color: var(--color-error);
    font-weight: 500;
}

.min-warning.hidden {
    display: none;
}

.generate-note {
    font-size: 0.8rem;
    color: var(--color-gray);
    text-align: center;
    margin-top: 0.75rem;
}

/* ===== Orientation Selector ===== */
.orientation-section {
    margin-top: 1.25rem;
}

.orientation-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-dark);
    margin-bottom: 0.75rem;
}

.orientation-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.orientation-card {
    background: var(--color-white);
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.orientation-card:hover {
    border-color: #bbb;
}

.orientation-card.selected {
    border-color: var(--color-pink);
    background: var(--color-white);
}

/* Card Preview - Frame visualization */
.card-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
}

.preview-frame {
    background: var(--color-gray-light);
    border: 2px solid #ccc;
    border-radius: 3px;
    position: relative;
    transition: all var(--transition-fast);
}

/* Horizontal frame - wider than tall */
.horizontal-preview .preview-frame {
    width: 48px;
    height: 32px; /* 3:2 ratio */
}

/* Vertical frame - taller than wide */
.vertical-preview .preview-frame {
    width: 32px;
    height: 48px; /* 2:3 ratio */
}

.orientation-card.selected .preview-frame {
    background: #f8f8f8;
    border-color: var(--color-pink);
}

/* Decorative lines inside frame */
.preview-frame::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50%;
    height: 35%;
    border: 1px dashed #bbb;
    border-radius: 1px;
    opacity: 0.5;
}

.orientation-card.selected .preview-frame::before {
    border-color: var(--color-pink);
    opacity: 0.6;
}

/* Card Info */
.card-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.card-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-dark);
}

.card-dimensions {
    font-size: 0.65rem;
    color: var(--color-gray);
}

.orientation-card.selected .card-title {
    color: var(--color-black);
}

/* Radio Button */
.card-radio {
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.orientation-card.selected .card-radio {
    border-color: var(--color-pink);
}

.radio-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: transparent;
    transition: all var(--transition-fast);
}

.orientation-card.selected .radio-dot {
    background: var(--color-pink);
}

/* Mobile adjustments for orientation cards */
@media (max-width: 360px) {
    .orientation-cards {
        gap: 0.4rem;
    }
    
    .orientation-card {
        padding: 0.5rem 0.4rem;
    }
    
    .horizontal-preview .preview-frame {
        width: 40px;
        height: 27px;
    }
    
    .vertical-preview .preview-frame {
        width: 27px;
        height: 40px;
    }
    
    .card-title {
        font-size: 0.65rem;
    }
    
    .card-dimensions {
        font-size: 0.55rem;
    }
}

.prompt-input {
    font-family: var(--font-main);
    font-size: 15px;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 12px;
    resize: none;
    min-height: 90px;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    background-color: transparent;
    width: 100%;
    line-height: 1.5;
    position: relative;
    z-index: 1;
}

.prompt-input:focus {
    outline: none;
    border-color: var(--color-pink);
    box-shadow: 0 0 0 3px rgba(214, 0, 111, 0.1);
}

.prompt-input::placeholder {
    color: transparent;
}

.generate-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 2rem;
    font-family: var(--font-main);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-white);
    background: linear-gradient(135deg, var(--color-pink) 0%, var(--color-pink-light) 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), opacity var(--transition-fast);
    box-shadow: var(--shadow-soft);
    width: 100%;
    min-height: 56px;
    -webkit-tap-highlight-color: transparent;
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.generate-btn:active:not(:disabled) {
    transform: translateY(1px) scale(0.98);
}

/* Subtle gradient animation on hover */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.generate-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--color-pink) 0%, var(--color-pink-light) 50%, var(--color-pink) 100%);
    background-size: 200% 200%;
    animation: gradientShift 2s ease infinite;
}

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

/* ===== Price Section ===== */
.price-section {
    background: var(--color-white);
    border-radius: 16px;
    padding: 1.5rem;
    margin-top: 1rem;
    box-shadow: var(--shadow-soft);
}

.price-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-black);
    text-align: center;
    margin-bottom: 0.25rem;
}

.price-subtitle {
    font-size: 0.8rem;
    color: var(--color-gray);
    text-align: center;
    margin-bottom: 1rem;
}

.price-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.price-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.price-table th,
.price-table td {
    padding: 0.75rem 0.5rem;
    text-align: center;
    border-bottom: 1px solid var(--color-gray-light);
}

.price-table th {
    background-color: var(--color-black);
    color: var(--color-white);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.price-table th:first-child {
    border-radius: 8px 0 0 0;
}

.price-table th:last-child {
    border-radius: 0 8px 0 0;
}

.price-table tbody tr:hover {
    background-color: var(--color-cream);
}

.price-table tbody tr:last-child td {
    border-bottom: none;
}

.price-table td:last-child {
    color: var(--color-pink);
    font-weight: 600;
}

/* ===== Loading Section ===== */
.loading-section {
    margin-top: 1rem;
    padding: 3rem 1.5rem;
    text-align: center;
    background: var(--color-white);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.loading-spinner {
    position: relative;
    width: 60px;
    height: 60px;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 3px solid transparent;
    border-top-color: var(--color-pink);
    border-radius: 50%;
    animation: spin 1.2s linear infinite;
}

.spinner-ring:nth-child(2) {
    width: 70%;
    height: 70%;
    top: 15%;
    left: 15%;
    border-top-color: var(--color-black);
    animation-duration: 1s;
    animation-direction: reverse;
}

.spinner-ring:nth-child(3) {
    width: 40%;
    height: 40%;
    top: 30%;
    left: 30%;
    border-top-color: var(--color-pink-light);
    animation-duration: 0.8s;
}

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

.loading-text {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-black);
}

.loading-subtext {
    font-size: 0.85rem;
    color: var(--color-gray);
}

/* Shimmer effect for loading */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(214, 0, 111, 0.05) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
    pointer-events: none;
    border-radius: 16px;
}

.loading-content {
    position: relative;
}

/* ===== Result Section ===== */
.result-section {
    margin-top: 1rem;
    background: var(--color-white);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: var(--shadow-medium);
    animation: fadeInUp 0.5s ease;
}

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

/* Image reveal animation */
@keyframes imageReveal {
    0% {
        opacity: 0;
        transform: scale(0.95);
        filter: blur(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1);
        filter: blur(0);
    }
}

.generated-image {
    animation: imageReveal 0.6s ease-out forwards;
}

/* Card selection bounce */
@keyframes selectBounce {
    0% { transform: scale(1); }
    50% { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.orientation-card.selected {
    animation: selectBounce 0.25s ease-out;
}

.result-header {
    background: var(--color-black);
    padding: 1rem;
}

.result-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--color-white);
    text-align: center;
}

.result-content {
    padding: 1rem;
}

.image-container {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: var(--color-gray-light);
    box-shadow: var(--shadow-soft);
}

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

/* Next Steps Section */
.next-steps {
    background: linear-gradient(135deg, var(--color-cream) 0%, #f0f0f0 100%);
    border-radius: 12px;
    padding: 1.25rem;
    margin-top: 1rem;
    border-left: 4px solid var(--color-pink);
    animation: slideInLeft 0.5s ease-out 0.3s both;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.next-steps-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-black);
    margin-bottom: 0.75rem;
}

.next-steps-list {
    margin: 0;
    padding-left: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.next-steps-list li {
    font-size: 0.9rem;
    color: var(--color-dark);
    line-height: 1.5;
}

.next-steps-list li strong {
    color: var(--color-black);
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* Staggered button entrance */
.action-buttons .action-btn {
    animation: fadeInUp 0.4s ease-out both;
}

.action-buttons .action-btn:nth-child(1) { animation-delay: 0.4s; }
.action-buttons .action-btn:nth-child(2) { animation-delay: 0.5s; }
.action-buttons .action-btn:nth-child(3) { animation-delay: 0.6s; }

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    border: 2px solid transparent;
    min-height: 52px;
    -webkit-tap-highlight-color: transparent;
}

/* Primary button - white with pink border, pink on hover */
.primary-btn {
    background-color: var(--color-white);
    color: var(--color-pink);
    border-color: var(--color-pink);
    font-weight: 600;
}

.primary-btn:hover,
.primary-btn:active {
    background-color: var(--color-pink);
    color: var(--color-white);
}

/* Secondary button - outline style */
.secondary-btn {
    background-color: transparent;
    color: var(--color-gray-dark);
    border-color: #ccc;
}

.secondary-btn:hover,
.secondary-btn:active {
    background-color: var(--color-gray-light);
    border-color: #aaa;
    color: var(--color-black);
}

/* ===== Error Section ===== */
.error-section {
    margin-top: 1rem;
    padding: 2rem 1.5rem;
    background: #fff5f5;
    border: 2px solid var(--color-error);
    border-radius: 16px;
    text-align: center;
}

.error-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.error-icon {
    font-size: 2.5rem;
}

.error-message {
    font-size: 0.95rem;
    color: var(--color-error);
}

.retry-btn {
    background-color: var(--color-error);
    color: var(--color-white);
    border-color: var(--color-error);
}

.retry-btn:hover,
.retry-btn:active {
    background-color: #b83a3a;
    border-color: #b83a3a;
}

/* ===== Footer ===== */
.footer {
    background-color: var(--color-black);
    padding: 1.5rem 1rem;
    text-align: center;
    margin-top: auto;
}

.footer-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.footer-text {
    font-size: 0.8rem;
    color: var(--color-gray);
}

.footer-link {
    font-size: 0.8rem;
    color: var(--color-pink);
    text-decoration: none;
}

.footer-link:hover {
    text-decoration: underline;
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

/* ===== Mobile Optimizations ===== */
@media (max-width: 480px) {
    .main-container {
        padding: 1rem 0.75rem;
    }
    
    .generator-section,
    .price-section {
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .main-title {
        font-size: 1.3rem;
    }
    
    .prompt-input {
        min-height: 85px;
        padding: 0.65rem 0.85rem;
    }
    
    .prompt-placeholder {
        top: 0.65rem;
        left: 0.85rem;
        right: 0.85rem;
        bottom: 0.65rem;
    }
    
    .input-area {
        gap: 0.5rem;
    }
    
    .orientation-section {
        margin-top: 0.5rem;
    }
    
    .input-footer {
        margin-top: 0.25rem;
    }
    
    .limit-note {
        margin-bottom: 0.5rem;
    }
    
    .generate-note {
        margin-top: 0.5rem;
    }
    
    .price-table th,
    .price-table td {
        padding: 0.6rem 0.4rem;
        font-size: 0.85rem;
    }
    
    .loading-section {
        padding: 2.5rem 1rem;
    }
    
    .result-content {
        padding: 0.75rem;
    }
    
    .action-btn {
        padding: 0.875rem;
        font-size: 0.9rem;
    }
}

/* Large screens */
@media (min-width: 768px) {
    .header-content {
        padding: 1rem 2rem;
    }
    
    .logo-img {
        height: 60px;
    }
    
    .main-container {
        padding: 2rem 1rem;
    }
    
    .generator-section,
    .price-section {
        padding: 2rem;
    }
    
    .main-title {
        font-size: 1.75rem;
    }
    
    .action-buttons {
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .action-btn {
        flex: 1;
        min-width: 140px;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .generate-btn:hover:not(:disabled),
    .action-btn:hover {
        transform: none;
    }
    
    .price-table tbody tr:hover {
        background-color: transparent;
    }
}

/* Safe area for notched phones */
@supports (padding: max(0px)) {
    .header {
        padding-top: max(0px, env(safe-area-inset-top));
    }
    
    .footer {
        padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
    }
}
