/* SP Card Designer - Frontend Styles */

.spcd-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    color: #333;
}

/* Two-column layout */
.spcd-wrapper--two-column {
    max-width: 1400px;
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 30px;
    padding: 24px;
    box-sizing: border-box;
}

.spcd-wrapper--two-column .spcd-header {
    display: none; /* Hide header in two-column mode as it takes vertical space */
}

/* Left column - Form */
.spcd-wrapper--two-column .spcd-form,
.spcd-wrapper--two-column .spcd-limit-reached {
    grid-column: 1;
}

/* Right column - Canvas */
.spcd-wrapper--two-column .spcd-canvas-placeholder,
.spcd-wrapper--two-column .spcd-error {
    grid-column: 2;
}

/* Canvas placeholder */
.spcd-canvas-placeholder {
    display: none;
}

/* Show canvas in two-column mode */
.spcd-wrapper--two-column .spcd-canvas-placeholder {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    background: linear-gradient(135deg, #fafbfc 0%, #f3f4f6 100%);
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 20px;
    animation: spcd-border-dash 20s linear infinite;
    background-size: 200% 200%;
    height: 600px;
}

@keyframes spcd-border-dash {
    0% {
        background-position: 0% 0%;
    }
    50% {
        background-position: 100% 100%;
    }
    100% {
        background-position: 0% 0%;
    }
}

/* When canvas has gallery, change layout (using class for better browser support) */
.spcd-wrapper--two-column .spcd-canvas-placeholder.spcd-canvas--active {
    display: block;
    padding: 20px;
    box-sizing: border-box;
    max-height: none;
    height: auto;
    overflow-y: auto;
    align-items: flex-start;
}

/* Also show canvas in single-column mode when it has cards */
.spcd-canvas-placeholder.spcd-canvas--active {
    display: block !important;
    background: #fafbfc;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 20px;
}

.spcd-canvas-content {
    text-align: center;
    width: 100%;
}

/* Ensure canvas content is properly centered in two-column mode */
.spcd-wrapper--two-column .spcd-canvas-content {
}

.spcd-canvas-icon {
    color: #9ca3af;
    margin-bottom: 24px;
    transition: transform 0.3s ease;
}

.spcd-canvas-placeholder:hover .spcd-canvas-icon {
    transform: scale(1.05);
}

.spcd-canvas-title {
    font-size: 20px;
    font-weight: 600;
    color: #4e657b;
    margin: 0 0 12px 0;
}

.spcd-canvas-text {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
    line-height: 1.6;
}

/* Header */
.spcd-header {
    text-align: center;
    margin-bottom: 30px;
}

.spcd-title {
    font-size: 28px;
    font-weight: 700;
    color: #4e657b;
    margin: 0 0 10px 0;
}

.spcd-subtitle {
    font-size: 16px;
    color: #555;
    margin: 0 0 5px 0;
}

.spcd-note {
    font-size: 13px;
    color: #888;
    font-style: italic;
    margin: 0;
}

/* Form */
.spcd-form {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
}

/* Fields */
.spcd-field {
    margin-bottom: 14px;
}

.spcd-field label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: #374151;
}

.spcd-field input[type="text"],
.spcd-field input[type="email"],
.spcd-field input[type="tel"],
.spcd-field input[type="url"],
.spcd-field textarea,
.spcd-field select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 15px;
    color: #333;
    background: #fff;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.spcd-field input:focus,
.spcd-field textarea:focus,
.spcd-field select:focus {
    outline: none;
    border-color: #4e657b;
    box-shadow: 0 0 0 2px rgba(78, 101, 123, 0.15);
}

.spcd-required {
    color: #c51aa0;
}

.spcd-optional-tag {
    font-weight: 400;
    color: #9ca3af;
    font-size: 13px;
}

/* Optional fields section */
.spcd-optional-fields {
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.5);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
}

.spcd-optional-label {
    font-weight: 600;
    font-size: 14px;
    color: #374151;
    margin-bottom: 10px;
}

/* Toggle switch */
.spcd-toggle-field {
    margin-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
}

.spcd-toggle-field:last-child {
    border-bottom: none;
}

.spcd-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
    gap: 10px;
    user-select: none;
}

.spcd-toggle-checkbox {
    display: none;
}

.spcd-toggle-slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    background-color: #d1d5db;
    border-radius: 11px;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.spcd-toggle-slider::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background-color: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.spcd-toggle-checkbox:checked + .spcd-toggle-slider {
    background-color: #4e657b;
}

.spcd-toggle-checkbox:checked + .spcd-toggle-slider::after {
    transform: translateX(18px);
}

.spcd-field--toggled {
    margin-top: 8px;
    padding-left: 50px;
}

/* Hidden utility */
.spcd-hidden {
    display: none !important;
}

/* Logo upload */
.spcd-field--logo {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e7eb;
}

.spcd-logo-upload input[type="file"] {
    font-size: 14px;
}

.spcd-help {
    font-size: 12px;
    color: #9ca3af;
    margin: 4px 0 0 0;
}

/* Style select */
.spcd-field select {
    appearance: auto;
}

/* Submit */
.spcd-submit {
    margin-top: 20px;
    text-align: center;
}

.spcd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 32px;
    background-color: #c51aa0;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    min-width: 260px;
}

.spcd-btn:hover {
    background-color: #a8158a;
}

.spcd-btn:disabled {
    background-color: #d1d5db;
    cursor: not-allowed;
}

.spcd-btn:disabled:not(.spcd-btn--secondary) {
    animation: spcd-pulse 2s ease-in-out infinite;
}

@keyframes spcd-pulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

.spcd-btn--secondary {
    background-color: #4e657b;
}

.spcd-btn--secondary:hover {
    background-color: #3d5062;
}

.spcd-remaining {
    font-size: 13px;
    color: #6b7280;
    margin-top: 10px;
}

.spcd-remaining a {
    color: #c51aa0;
    text-decoration: none;
}

.spcd-remaining a:hover {
    text-decoration: underline;
}

/* Spinner */
.spcd-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spcd-spin 0.6s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

.spcd-btn-loading {
    display: inline-flex;
    align-items: center;
}

/* Limit reached */
.spcd-limit-reached {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    color: #92400e;
}

.spcd-limit-reached a {
    color: #c51aa0;
    font-weight: 600;
}

/* Progress indicator */
.spcd-progress {
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
    display: none;
}

.spcd-progress--active {
    display: block;
}

.spcd-progress-text {
    font-size: 14px;
    color: #4e657b;
    font-weight: 600;
    margin-bottom: 8px;
    text-align: center;
}

.spcd-progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.spcd-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #c51aa0, #e02db8);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0;
}

/* Gallery inside canvas - larger cards, centered layout */
.spcd-wrapper--two-column .spcd-canvas-placeholder .spcd-gallery {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin: 0 auto;
}

.spcd-wrapper--two-column .spcd-canvas-placeholder .spcd-card {
    max-width: 800px;
    width: 100%;
}

.spcd-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 420px));
    gap: 12px;
    max-width: 1200px;
    margin: 0 auto;
    justify-content: start;
}

.spcd-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    will-change: transform;
}

.spcd-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

.spcd-card-image {
    width: 100%;
    aspect-ratio: 90 / 55;
    object-fit: cover;
    display: block;
    background: #f3f4f6;
    opacity: 0;
    animation: spcd-fade-in 0.5s ease-in 0.1s forwards;
}

@keyframes spcd-fade-in {
    to {
        opacity: 1;
    }
}

.spcd-card-placeholder {
    width: 100%;
    aspect-ratio: 90 / 55;
    background: #e5e7eb;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.spcd-card-placeholder::before {
    content: '';
    position: absolute;
    width: 40%;
    height: 30%;
    background: #d1d5db;
    border-radius: 4px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.spcd-card-shimmer {
    position: absolute;
    top: 0;
    left: -100%;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.6) 50%,
        transparent 100%
    );
    animation: spcd-shimmer 2s infinite;
}

@keyframes spcd-shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.spcd-card--loading {
    pointer-events: none;
}

.spcd-card-actions {
    padding: 10px;
    text-align: center;
}

.spcd-card-download {
    display: inline-block;
    padding: 7px 18px;
    background-color: #4e657b;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.spcd-card-download:hover {
    background-color: #3d5062;
    color: #fff;
    text-decoration: none;
}

.spcd-card-label {
    font-size: 12px;
    color: #6b7280;
    text-align: center;
    padding: 10px;
    font-weight: 500;
}

.spcd-card--error {
    border-color: #ef4444;
}

.spcd-card-error-msg {
    padding: 20px;
    text-align: center;
    color: #991b1b;
    font-size: 14px;
    line-height: 1.5;
    background: #fef2f2;
    border-radius: 4px;
    margin: 10px;
}

/* CTA Section */
.spcd-cta {
    background: linear-gradient(135deg, #faf5f9 0%, #f5f0f8 100%);
    border: 1px solid #e8d5e0;
    border-radius: 10px;
    padding: 28px 24px;
    text-align: center;
    margin-top: 20px;
}

.spcd-cta-heading {
    font-size: 20px;
    font-weight: 700;
    color: #4e657b;
    margin: 0 0 8px 0;
}

.spcd-cta-desc {
    font-size: 14px;
    color: #555;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.spcd-cta-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.spcd-cta-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s, transform 0.15s;
    min-width: 140px;
}

.spcd-cta-btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.spcd-cta-btn--email {
    background-color: #4e657b;
    color: #fff;
}

.spcd-cta-btn--email:hover {
    background-color: #3d5062;
    color: #fff;
}

.spcd-cta-btn--order {
    background-color: #c51aa0;
    color: #fff;
}

.spcd-cta-btn--order:hover {
    background-color: #a8158a;
    color: #fff;
}

/* Error */
.spcd-error {
    background: #fef2f2;
    border: 1px solid #ef4444;
    border-radius: 8px;
    padding: 16px;
    color: #991b1b;
    text-align: center;
    margin-top: 20px;
}

/* Responsive */
/* Tablets and mobile - single column layout */
@media (max-width: 1024px) {
    .spcd-wrapper--two-column {
        grid-template-columns: 1fr;
        max-width: 800px;
        height: auto;
        overflow: visible;
        padding: 16px;
    }

    .spcd-wrapper--two-column .spcd-form,
    .spcd-wrapper--two-column .spcd-limit-reached {
        position: static;
        max-height: none;
        height: auto;
        overflow: visible;
    }

    .spcd-wrapper--two-column .spcd-canvas-placeholder,
    .spcd-wrapper--two-column .spcd-error {
        grid-column: 1;
        height: auto;
        overflow: visible;
    }
}

@media (max-width: 768px) {
    .spcd-gallery {
        max-width: 100%;
    }

    .spcd-wrapper {
        padding: 10px;
    }

    .spcd-form {
        padding: 15px;
    }

    .spcd-field--toggled {
        padding-left: 0;
    }

    .spcd-btn {
        width: 100%;
    }

    /* Touch-friendly targets (minimum 44px) */
    .spcd-toggle {
        min-height: 44px;
        padding: 8px 0;
    }

    .spcd-card-download {
        min-height: 44px;
        padding: 12px 24px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .spcd-btn {
        min-height: 48px;
    }

    .spcd-cta-buttons {
        flex-direction: column;
    }

    .spcd-cta-btn {
        width: 100%;
        min-height: 48px;
    }

    /* Sticky submit button on mobile */
    .spcd-submit {
        position: sticky;
        bottom: 0;
        background: linear-gradient(to top, #f9fafb 80%, transparent);
        padding: 16px 0;
        margin: 0 -15px;
        padding-left: 15px;
        padding-right: 15px;
        z-index: 10;
    }
}
