:root {
    --primary: #ec4899;
    --primary-hover: #db2777;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #311042 100%);
    --card-bg: rgba(30, 27, 75, 0.65);
    --card-border: rgba(255, 255, 255, 0.12);
    --text-main: #f8fafc;
    --text-muted: #cbd5e1;
    --accent: #f59e0b;
    --accent-blue: #38bdf8;
    --accent-green: #10b981;
    --accent-purple: #a855f7;
    --success: #10b981;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
    background-attachment: fixed;
}

.container {
    width: 100%;
    max-width: 1200px;
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    border-radius: 28px;
    padding: 2.5rem;
    box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 40px rgba(236, 72, 153, 0.1);
    animation: fadeIn 0.6s ease-out;
}

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

header {
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: linear-gradient(135deg, rgba(236, 72, 153, 0.2), rgba(168, 85, 247, 0.2));
    border: 1px solid rgba(236, 72, 153, 0.4);
    color: #f472b6;
    padding: 0.35rem 1rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 0.75rem;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.15);
}

header h1 {
    font-family: 'Fredoka', 'Outfit', sans-serif;
    font-size: 2.7rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    background: linear-gradient(to right, #f43f5e, #fb923c, #facc15, #a855f7, #38bdf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 680px;
    margin: 0 auto;
    line-height: 1.5;
}

/* Tabs Styling */
/* Stepper Layout */
.stepper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    margin-bottom: 3.5rem;
    padding: 0 1rem;
}

.stepper::before {
    content: '';
    position: absolute;
    top: 25px;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    z-index: 1;
}

.stepper-progress {
    position: absolute;
    top: 25px;
    left: 0;
    height: 3px;
    background: linear-gradient(to right, var(--primary), #a855f7);
    z-index: 2;
    transition: width 0.4s ease;
    width: 0%; /* Dynamic width 0% for Step 1, 50% for Step 2, 100% for Step 3 */
}

.step-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 3;
    cursor: pointer;
    flex: 1;
}

.step-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #111827;
    border: 3px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-muted);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
}

.step-label {
    margin-top: 0.75rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.4s;
    text-align: center;
}

/* Stepper Active/Completed/Disabled States */
.step-item.active .step-circle {
    border-color: var(--primary);
    color: #fff;
    background: var(--primary);
    box-shadow: 0 0 15px rgba(37, 99, 235, 0.4);
}

.step-item.active .step-label {
    color: #fff;
}

.step-item.completed .step-circle {
    border-color: var(--success);
    color: #fff;
    background: var(--success);
}

.step-item.completed .step-label {
    color: var(--success);
}

.step-item.disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.step-content {
    display: none;
    animation: slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.step-content.active {
    display: block;
}

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

/* Stepper actions (back/next buttons) */
.step-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Main Form / Generator Tab */
.generator-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2.5rem;
}

.card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 2rem;
}

.drop-zone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    padding: 3.5rem 2rem;
    text-align: center;
    transition: all 0.3s ease;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.04);
}

.drop-zone.loaded {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.04);
    box-shadow: inset 0 0 15px rgba(16, 185, 129, 0.05);
}

.drop-zone.loaded i {
    color: var(--success);
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.drop-zone i {
    font-size: 3.5rem;
    color: var(--primary);
    text-shadow: 0 0 20px rgba(37, 99, 235, 0.2);
}

.drop-zone span {
    font-size: 1.1rem;
    font-weight: 500;
}

/* Template Selector Grid Enhanced */
.template-grid-enhanced {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.template-card {
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.template-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 12px 25px -5px rgba(0, 0, 0, 0.5);
}

.template-card.active {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.03);
    box-shadow: 0 0 20px rgba(37, 99, 235, 0.15);
}

.template-card-preview {
    position: relative;
    aspect-ratio: 1.6 / 1;
    background: #090d16;
    overflow: hidden;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.template-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.template-card:hover .template-card-preview img {
    transform: scale(1.04);
}

.template-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary);
    color: white;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.template-card-info {
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    flex-grow: 1;
}

.template-card-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.template-card-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-card-select {
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0.45rem;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.btn-card-select:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.template-card.active .btn-card-select {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-card-edit {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0.45rem;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-card-edit:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-main);
}

.template-card.active .btn-card-edit {
    border-color: rgba(37, 99, 235, 0.3);
    color: var(--primary);
}

/* Add Template Card Special Style */
.add-template-card {
    border: 2px dashed rgba(255, 255, 255, 0.12);
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    aspect-ratio: 1.6 / 1;
    min-height: 160px;
}

.add-template-card:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.02);
}

.add-template-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    transition: color 0.3s;
    padding: 1rem;
}

.add-template-card:hover .add-template-inner {
    color: var(--primary);
}

.add-template-inner i {
    font-size: 2rem;
    margin-bottom: 0.2rem;
}

.add-template-inner span {
    font-weight: 600;
    font-size: 0.85rem;
}

.add-template-inner .subtext {
    font-size: 0.7rem;
    opacity: 0.6;
    font-weight: 400;
}

/* Collapsible Designer Section */
.designer-section {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, opacity 0.3s ease-out, margin 0.3s ease-out;
    opacity: 0;
    margin-top: 0;
}

.designer-section.open {
    max-height: 1500px;
    opacity: 1;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

/* Visual Designer Layout */
.designer-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2rem;
}

@media (max-width: 1024px) {
    .designer-layout {
        grid-template-columns: 1fr;
    }
}

.canvas-container {
    background: #090d16;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-height: 450px;
}

.designer-workspace {
    position: relative;
    display: inline-block;
    max-width: 100%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    border-radius: 8px;
    overflow: hidden;
}

.designer-workspace img {
    display: block;
    max-width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

/* Interactive Overlay Placeholders */
.designer-box {
    position: absolute;
    border: 2px solid;
    cursor: move;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
    box-sizing: border-box;
    user-select: none;
}

.designer-box.qr-placeholder {
    border-color: #f97316;
    background: rgba(249, 115, 22, 0.15);
    color: #ffedd5;
}

.designer-box.text-placeholder {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.15);
    color: #dbeafe;
    height: auto;
    min-height: 30px;
}

.designer-box .box-label {
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
    margin-bottom: 2px;
    pointer-events: none;
}

.designer-box .resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #fff;
    border: 2px solid #000;
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
    border-radius: 50%;
}

/* Sidebar Inputs */
.designer-sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

input[type="text"], input[type="number"], select {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
    padding: 0.75rem;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    width: 100%;
}

input[type="color"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.2rem;
    border-radius: 8px;
    width: 100%;
    height: 42px;
    cursor: pointer;
    transition: all 0.2s;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

.color-preset-pill {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.color-preset-pill:hover {
    transform: scale(1.18);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

.color-input-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 2px 6px;
}

.color-input-badge input[type="color"] {
    width: 24px;
    height: 22px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.color-hex-label {
    font-size: 0.72rem;
    font-family: monospace;
    color: var(--text-muted);
}

input:focus, select:focus, input[type="color"]:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.08);
}

.btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-success {
    background: var(--success);
}
.btn-success:hover {
    background: #059669;
}

.btn-generate {
    grid-column: 1 / -1;
    background: linear-gradient(to right, var(--primary), #4f46e5);
    color: white;
    border: none;
    padding: 1.2rem;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.8rem;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.25);
}

.btn-generate:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 25px rgba(37, 99, 235, 0.4);
}

/* Status Area & Progress */
.status-area {
    margin-top: 2.5rem;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 1.5rem;
    display: none;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.08);
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), #a855f7);
    width: 0%;
    transition: width 0.3s;
}

input[type="file"] {
    display: none;
}
