/* ===== Variables ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --white: #ffffff;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px 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);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.6;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    width: 100%;
}

/* ===== Header ===== */
.header {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--gray-600);
    font-size: 16px;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.2s;
}

.btn-back:hover {
    color: var(--primary);
}

.page-title {
    font-size: 24px;
    font-weight: 600;
}

/* ===== Buttons ===== */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

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

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

/* ===== Main ===== */
.main {
    flex: 1;
    padding: 32px 0;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    font-size: 48px;
}

.stat-info {
    flex: 1;
}

.stat-label {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--gray-900);
}

/* ===== Section ===== */
.section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.search-box input {
    padding: 10px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    width: 250px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

/* ===== Campaigns List ===== */
.campaigns-list {
    display: grid;
    gap: 16px;
}

.campaign-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.campaign-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.campaign-info h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.campaign-meta {
    display: flex;
    gap: 16px;
    color: var(--gray-500);
    font-size: 14px;
}

.campaign-actions {
    display: flex;
    gap: 8px;
}

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: var(--success);
}

.badge-info {
    background: #dbeafe;
    color: #3b82f6;
}

/* ===== Form ===== */
.form-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
}

.form-card h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--gray-200);
}

/* ===== Progress Steps ===== */
.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    position: relative;
}

.progress-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gray-200);
    z-index: 0;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--gray-500);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    transition: all 0.3s;
}

.step.active .step-number {
    background: var(--primary);
    color: var(--white);
}

.step.completed .step-number {
    background: var(--success);
    color: var(--white);
}

.step-label {
    font-size: 14px;
    color: var(--gray-500);
    font-weight: 500;
}

.step.active .step-label {
    color: var(--primary);
    font-weight: 600;
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

/* ===== Dropzone ===== */
.dropzone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.dropzone-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.dropzone-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 8px;
}

.dropzone-subtext {
    font-size: 14px;
    color: var(--gray-500);
}

.dropzone-small {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
}

.dropzone-small:hover {
    border-color: var(--primary);
}

/* ===== Contacts Preview ===== */
.contacts-preview {
    margin-top: 24px;
}

.contacts-stats {
    margin: 16px 0;
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.contacts-table {
    width: 100%;
    border-collapse: collapse;
}

.contacts-table th,
.contacts-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.contacts-table th {
    background: var(--gray-50);
    font-weight: 600;
    font-size: 14px;
}

.contacts-table tbody tr:hover {
    background: var(--gray-50);
}

/* ===== Tabs ===== */
.design-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--gray-200);
}

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

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

/* ===== Email Preview ===== */
.preview-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--gray-200);
}

.email-preview {
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 24px;
    min-height: 300px;
    background: var(--gray-50);
    overflow: auto;
}

.empty-state {
    text-align: center;
    color: var(--gray-400);
    padding: 48px 24px;
}

/* ===== Review Summary ===== */
.review-summary {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.review-item {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-200);
}

.review-item:last-child {
    border-bottom: none;
}

.test-section {
    background: var(--gray-50);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 24px;
}

.test-section h4 {
    margin-bottom: 16px;
}

/* ===== Loading ===== */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 16px;
}

.loading-overlay.show {
    display: flex;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: var(--white);
    font-size: 16px;
    font-weight: 600;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--white);
    padding: 16px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    animation: slideIn 0.3s;
}

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

.toast-success {
    border-left: 4px solid var(--success);
}

.toast-error {
    border-left: 4px solid var(--danger);
}

.toast-info {
    border-left: 4px solid var(--primary);
}

/* ===== Templates Grid ===== */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.template-card {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.template-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
}

.template-preview {
    font-size: 48px;
    margin-bottom: 12px;
}

/* ===== Images Preview ===== */
.images-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.image-preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    border: 2px solid var(--gray-200);
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .progress-steps {
        flex-direction: column;
        align-items: stretch;
    }

    .progress-steps::before {
        display: none;
    }

    .step {
        flex-direction: row;
        justify-content: flex-start;
    }

    .header-content {
        flex-direction: column;
        gap: 16px;
        align-items: stretch;
    }

    .toast-container {
        left: 24px;
        right: 24px;
    }

    .toast {
        min-width: auto;
    }
}

/* ===== Add Single Contact Form ===== */
.divider-text {
    text-align: center;
    margin: 32px 0;
    position: relative;
}

.divider-text::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gray-200);
    z-index: 0;
}

.divider-text span {
    background: white;
    padding: 0 16px;
    position: relative;
    z-index: 1;
    color: var(--gray-500);
    font-size: 14px;
}

.add-contact-form {
    background: var(--gray-50);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
}

.add-contact-form h4 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--gray-800);
}

.add-contact-form .form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.add-contact-form .form-group {
    margin: 0;
}

.btn-success {
    background: var(--success);
    white-space: nowrap;
    padding: 0 24px;
}

.btn-success:hover {
    opacity: 0.9;
}

@media (max-width: 768px) {
    .add-contact-form .form-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn-success {
        width: 100%;
    }
}

/* ===== Canva Folder Dropzone ===== */
.canva-dropzone {
    border: 3px dashed var(--primary);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-light) 0%, white 100%);
    cursor: pointer;
    transition: all 0.3s ease;
}

.canva-dropzone:hover {
    border-color: var(--primary-dark);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--gray-50) 100%);
}

.canva-dropzone.dragover {
    border-color: var(--success);
    background: var(--success-light);
}

.canva-dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.canva-icon {
    font-size: 64px;
}

.canva-text {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.canva-subtext {
    font-size: 14px;
    color: var(--gray-600);
    margin: 0;
}

.image-preview-item {
    position: relative;
}

.image-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
