/* ===== SAJU CARD GENERATOR PAGE ===== */

.card-page {
    background: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #1E3A8A 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    color: var(--white);
}

/* ===== HEADER ===== */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-lg);
    background: #F2EDE4;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.card-header .logo-link {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: #5D4E37;
}

.card-header .logo-icon { font-size: 1.5rem; border-radius: 8px; }
.card-header .logo-text { font-size: 1.2rem; font-weight: 700; }

.card-header .back-btn {
    padding: 8px 16px;
    background: rgba(93, 78, 55, 0.1);
    border: 1px solid rgba(93, 78, 55, 0.2);
    border-radius: var(--radius-sm);
    color: #5D4E37;
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-base);
    font-size: 0.9rem;
}

.card-header .back-btn:hover {
    background: rgba(93, 78, 55, 0.2);
}

/* ===== MAIN CONTAINER ===== */
.card-main {
    display: flex;
    gap: var(--spacing-lg);
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-md) var(--spacing-lg);
}

/* ===== LEFT: FORM PANEL ===== */
.card-form-panel {
    flex: 0 0 380px;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.form-card {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    backdrop-filter: blur(10px);
}

.form-card h2 {
    font-size: 1.1rem;
    margin-bottom: var(--spacing-sm);
    color: #A78BFA;
}

.card-form .form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.card-form .form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.card-form .form-group.full-width {
    flex: 1 1 100%;
}

.card-form label {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.card-form input,
.card-form select {
    padding: 10px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 0.95rem;
    font-family: var(--font-sans);
    transition: border-color var(--transition-base);
}

.card-form input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.card-form input:focus,
.card-form select:focus {
    outline: none;
    border-color: #A78BFA;
    background: rgba(255, 255, 255, 0.15);
}

.card-form select option {
    background: #1E1B4B;
    color: var(--white);
}

.gender-toggle {
    display: flex;
    gap: 8px;
}

.gender-toggle label {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
}

.gender-toggle input { display: none; }
.gender-toggle input:checked + span {
    color: var(--white);
}
.gender-toggle label:has(input:checked) {
    background: rgba(167, 139, 250, 0.3);
    border-color: #A78BFA;
    color: var(--white);
}

.btn-generate {
    width: 100%;
    padding: 14px;
    background: var(--gradient-button);
    border: none;
    border-radius: var(--radius-md);
    color: var(--white);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-sans);
}

.btn-generate:hover {
    background: var(--gradient-button-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== RIGHT: PREVIEW PANEL ===== */
.card-preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    min-width: 0;
}

/* Template Tabs */
.template-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.template-tab {
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-sm);
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-sans);
}

.template-tab:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
}

.template-tab.active {
    background: rgba(167, 139, 250, 0.3);
    border-color: #A78BFA;
    color: var(--white);
}

/* Canvas Preview */
.preview-wrapper {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 280px;
    position: relative;
}

.preview-canvas-container {
    transform-origin: top center;
}

#previewCanvas {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.preview-placeholder {
    text-align: center;
    color: rgba(255, 255, 255, 0.4);
    padding: var(--spacing-xl);
}

.preview-placeholder .placeholder-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-sm);
}

.preview-placeholder p {
    font-size: 1rem;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-action {
    flex: 1;
    min-width: 140px;
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    font-family: var(--font-sans);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-download {
    background: var(--gradient-button);
    color: var(--white);
    border: none;
}
.btn-download:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-share {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}
.btn-share:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-hashtag {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}
.btn-hashtag:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-action:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

/* ===== COMPATIBILITY PANEL ===== */
.compatibility-panel {
    display: none;
}

.compatibility-panel.visible {
    display: block;
}

.compatibility-panel .form-card {
    border-color: rgba(236, 72, 153, 0.3);
}

.compatibility-panel .form-card h2 {
    color: #F472B6;
}

/* ===== TOAST NOTIFICATION ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: rgba(30, 27, 75, 0.95);
    border: 1px solid rgba(167, 139, 250, 0.4);
    color: var(--white);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== LOADING SPINNER ===== */
.card-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-lg);
    gap: 12px;
    z-index: 10;
}

.card-loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(167, 139, 250, 0.2);
    border-top-color: #A78BFA;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.card-loading p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* ===== CARD HISTORY ===== */
.card-history-section {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg) var(--spacing-lg);
}

.card-history-section h3 {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
}

.card-history-list {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
}

.card-history-list::-webkit-scrollbar { height: 4px; }
.card-history-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.history-empty {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.85rem;
}

.history-card {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 8px;
    width: 130px;
    transition: all var(--transition-base);
}

.history-card:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(167, 139, 250, 0.4);
}

.history-thumb {
    width: 110px;
    height: auto;
    border-radius: 6px;
    object-fit: cover;
}

.history-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
}

.history-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.history-meta {
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.45);
}

.history-link {
    font-size: 0.85rem;
    text-decoration: none;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.history-link:hover {
    opacity: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .card-main {
        flex-direction: column;
        padding: var(--spacing-sm);
    }

    .card-form-panel {
        flex: none;
        width: 100%;
    }

    .card-preview-panel {
        width: 100%;
    }

    .template-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    .template-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .card-header {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .card-actions {
        flex-direction: column;
    }

    .btn-action {
        min-width: auto;
    }
}
