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

:root {
    --primary-color: #25D366;
    --primary-dark: #128C7E;
    --secondary-color: #075E54;
    --background: #f5f7fa;
    --card-bg: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
    padding-bottom: 100px;
}

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

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header .subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto 24px;
}

.preview-notice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--secondary-color);
}

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

/* Config Sections */
.config-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.config-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.config-section h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 2px;
}

.section-desc {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

/* Form Grid */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

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

.form-group.full-width {
    grid-column: 1 / -1;
}

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

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    padding: 12px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--card-bg);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

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

.hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* Color Input */
.color-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.color-input-wrapper input[type="color"] {
    width: 50px;
    height: 44px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 4px;
}

.color-input-wrapper .color-text {
    flex: 1;
    text-transform: uppercase;
}

/* Textarea with Emoji Button */
.textarea-wrapper {
    position: relative;
}

.textarea-wrapper textarea {
    width: 100%;
    padding-right: 50px;
}

.emoji-btn {
    position: absolute;
    right: 10px;
    top: 10px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--background);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.emoji-btn:hover {
    background: var(--border-color);
    transform: scale(1.1);
}

/* Emoji Picker */
.emoji-picker {
    position: fixed;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 12px;
    z-index: 1000;
    border: 1px solid var(--border-color);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.emoji-item:hover {
    background: var(--background);
    transform: scale(1.2);
}

/* Toggle Switch */
.toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--border-color);
    border-radius: 28px;
    transition: 0.3s;
}

.toggle-slider::before {
    position: absolute;
    content: '';
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: var(--shadow);
}

.toggle input:checked + .toggle-slider {
    background: var(--primary-color);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

.toggle-label {
    font-weight: 500;
    color: var(--text-primary);
}

/* URL Rules */
.url-rules-container {
    margin-top: 20px;
}

.url-rules-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 16px;
}

.url-rule {
    background: var(--background);
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.url-rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.url-rule-title {
    font-weight: 600;
    font-size: 0.9rem;
}

.remove-rule-btn {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.remove-rule-btn:hover {
    background: #fecaca;
}

.url-rule-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.url-rule-inputs input,
.url-rule-inputs textarea {
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--card-bg);
}

.url-rule-inputs input:focus,
.url-rule-inputs textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.url-rule-inputs textarea {
    grid-column: 1 / -1;
    resize: vertical;
    min-height: 60px;
}

.add-rule-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--background);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-rule-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.add-rule-btn span {
    font-size: 1.2rem;
    font-weight: 600;
}

/* Generate Section */
.generate-section {
    text-align: center;
    margin: 32px 0;
}

.generate-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 16px 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

.generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 211, 102, 0.5);
}

.generate-btn:active {
    transform: translateY(0);
}

/* Code Section */
.code-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.code-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.code-wrapper {
    position: relative;
    margin-top: 16px;
}

.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.copy-btn:hover {
    background: var(--primary-dark);
}

.copy-btn.copied {
    background: var(--secondary-color);
}

.code-wrapper pre {
    background: #1e293b;
    border-radius: var(--radius-sm);
    padding: 20px;
    padding-top: 50px;
    overflow-x: auto;
}

.code-wrapper code {
    color: #e2e8f0;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Instructions Section */
.instructions-section {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.instructions-section h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.instructions-section h2::before {
    content: '';
    width: 4px;
    height: 24px;
    background: var(--primary-color);
    border-radius: 2px;
}

.steps-container {
    margin-top: 24px;
}

.step {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.step:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.step-number {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.step-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.step-content p {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.step-content ul {
    margin-top: 12px;
    padding-left: 20px;
}

.step-content li {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.step-content li strong {
    color: var(--text-primary);
}

/* Footer */
.footer {
    text-align: center;
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* WhatsApp Button Preview */
.wa-button-preview {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
}

.wa-button-preview.left {
    right: auto;
    left: 20px;
    align-items: flex-start;
}

.wa-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.wa-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.wa-button svg {
    flex-shrink: 0;
}

/* Widget Popup */
.wa-widget-popup {
    display: none;
    width: 340px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.wa-widget-popup.active {
    display: block;
}

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

.wa-widget-header {
    background: var(--secondary-color);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.wa-widget-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wa-widget-brand-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: white;
    padding: 2px;
}

.wa-widget-brand-info {
    display: flex;
    flex-direction: column;
}

.wa-widget-brand-name {
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.wa-widget-brand-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.8rem;
}

.wa-widget-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wa-widget-close:hover {
    opacity: 1;
}

.wa-widget-body {
    padding: 20px;
    background: #e5ddd5;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d5cfc6' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    min-height: 100px;
}

.wa-widget-message {
    background: white;
    padding: 12px 16px;
    border-radius: 0 12px 12px 12px;
    font-size: 0.95rem;
    color: var(--text-primary);
    max-width: 85%;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    position: relative;
}

.wa-widget-message::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 8px 8px 0;
    border-color: transparent white transparent transparent;
}

.wa-widget-footer {
    padding: 16px 20px;
    background: white;
}

.wa-widget-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: var(--primary-color);
    color: white;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.wa-widget-cta:hover {
    background: var(--primary-dark);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 20px 16px;
        padding-bottom: 120px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .header .subtitle {
        font-size: 1rem;
    }

    .preview-notice {
        font-size: 0.85rem;
        padding: 10px 16px;
    }

    .config-section {
        padding: 20px;
    }

    .config-section h2 {
        font-size: 1.25rem;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .generate-btn {
        padding: 14px 32px;
        font-size: 1rem;
    }

    .wa-widget-popup {
        width: 300px;
    }

    .url-rule-inputs {
        grid-template-columns: 1fr;
    }

    .step {
        flex-direction: column;
        gap: 12px;
    }
}

/* Animation for copied state */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.copy-btn.copied {
    animation: pulse 0.3s ease;
}
