/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #1a56db;
    --primary-hover: #1347b8;
    --primary-light: #e8eefb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --success: #16a34a;
    --warning: #d97706;
    --info: #2563eb;
    --dark: #111827;
    --text: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --bg: #f3f4f6;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

/* ===== APP LAYOUT ===== */
.app-container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== HEADER ===== */
.app-header {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 12px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 16px;
    z-index: 100;
    border: 1px solid var(--border);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.logo-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ===== NAVIGATION ===== */
.main-nav {
    display: flex;
    gap: 4px;
    background: var(--bg);
    padding: 4px;
    border-radius: var(--radius);
}

.nav-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.nav-btn:hover:not(:disabled) {
    background: var(--white);
    color: var(--text);
}

.nav-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.nav-btn svg {
    flex-shrink: 0;
}

/* ===== MAIN ===== */
.app-main {
    flex: 1;
}

/* ===== SECTIONS ===== */
.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

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

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 24px;
    color: var(--dark);
}

/* ===== UPLOAD AREA ===== */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 80px 40px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--white);
}

.upload-area:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: scale(1.005);
}

.upload-icon-wrapper {
    width: 96px;
    height: 96px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.upload-svg-icon {
    color: var(--primary);
}

.upload-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
}

.upload-hint {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 15px;
}

.upload-info {
    color: var(--text-secondary);
    font-size: 13px;
    margin-top: 16px;
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 10px 24px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--white);
    color: var(--text);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg);
    border-color: #d1d5db;
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ===== EDITOR ===== */
.editor-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Toolbar */
.editor-toolbar {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.tool-group {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.tool-group + .tool-group {
    padding-left: 12px;
    border-left: 1px solid var(--border);
}

.tool-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.tool-btn {
    padding: 7px 12px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
    color: var(--text);
    white-space: nowrap;
}

.tool-btn:hover {
    background: var(--bg);
    border-color: #d1d5db;
}

.tool-btn.danger {
    color: var(--danger);
    border-color: #fecaca;
}

.tool-btn.danger:hover {
    background: var(--danger-light);
    border-color: var(--danger);
}

.tool-btn.tool-mini {
    padding: 6px 10px;
    font-size: 14px;
    min-width: 34px;
    justify-content: center;
}

.tool-btn.tool-mini.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

select {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
    color: var(--text);
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

input[type="color"] {
    width: 34px;
    height: 34px;
    padding: 2px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    background: var(--white);
}

/* Editor main area */
.editor-main {
    display: flex;
    gap: 12px;
    min-height: 650px;
}

.pages-sidebar {
    width: 110px;
    flex-shrink: 0;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 10px;
    overflow-y: auto;
    max-height: 700px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.page-thumb {
    width: 90px;
    height: 120px;
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition);
    background-size: cover;
    background-position: center top;
    position: relative;
}

.page-thumb:hover {
    border-color: var(--primary);
}

.page-thumb.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.page-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.6);
    color: white;
    text-align: center;
    font-size: 10px;
    padding: 2px 0;
    border-radius: 0 0 4px 4px;
}

.canvas-wrapper {
    flex: 1;
    background: #e5e7eb;
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow: auto;
    min-height: 600px;
}

.canvas-wrapper .canvas-container {
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    border-radius: 2px;
}

/* Editor footer */
.editor-footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.page-info {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    min-width: 100px;
    text-align: center;
}

/* ===== EXPORT OPTIONS ===== */
#export-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 24px;
}

.option-card {
    background: var(--bg);
    border: 2px solid transparent;
    border-radius: var(--radius-lg);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.option-card:hover {
    border-color: var(--primary);
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.option-icon {
    color: var(--primary);
    margin-bottom: 16px;
}

.option-card h3 {
    margin-bottom: 8px;
    color: var(--dark);
    font-size: 16px;
    font-weight: 600;
}

.option-card p {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== EMAIL FORM ===== */
#email-section {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

#emailForm {
    max-width: 520px;
    margin: 24px auto 0;
}

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

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

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: all var(--transition);
}

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

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

/* ===== POPUPS ===== */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.15s ease;
}

.popup-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 440px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    overflow: hidden;
}

.popup-box.signature-modal {
    max-width: 560px;
}

.popup-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

.popup-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0 4px;
    line-height: 1;
    transition: color var(--transition);
}

.popup-close:hover {
    color: var(--danger);
}

.popup-body {
    padding: 20px;
}

.popup-body input[type="text"],
.popup-body textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    transition: border-color var(--transition);
}

.popup-body input[type="text"]:focus,
.popup-body textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.popup-footer {
    padding: 12px 20px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* Signature canvas */
#signatureCanvas {
    width: 100%;
    height: 200px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--white);
    cursor: crosshair;
}

/* ===== LOADER ===== */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 11000;
}

.loader-content {
    text-align: center;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

.loader-content p {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
}

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

/* ===== NOTIFICATIONS ===== */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 12000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification {
    padding: 12px 20px;
    border-radius: var(--radius);
    color: var(--white);
    font-weight: 500;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideInRight 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 360px;
}

.notification.success { background: var(--success); }
.notification.error { background: var(--danger); }
.notification.info { background: var(--info); }
.notification.warning { background: var(--warning); }

.notification.fade-out {
    animation: slideOutRight 0.3s ease forwards;
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

/* ===== BANNER BAR (fixe en haut) ===== */
.banner-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    max-height: 90px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.banner-bar .banner-img {
    max-height: 90px;
    width: 100%;
    object-fit: contain;
    display: block;
}

.banner-bar .banner-video {
    max-height: 90px;
    width: 100%;
    object-fit: contain;
    display: block;
}

.banner-bar .banner-link {
    display: block;
    width: 100%;
    text-align: center;
}

.banner-close {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.banner-close:hover {
    background: rgba(0,0,0,0.8);
}

body.has-banner .app-container {
    margin-top: 90px;
}

body.has-banner .app-header {
    top: 90px;
}

/* ===== PRÉSENTATION ===== */
.info-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
}

.info-hero {
    text-align: center;
    padding: 40px 0 32px;
}

.info-hero-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 16px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.info-hero h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 8px;
}

.info-hero-sub {
    font-size: 16px;
    color: var(--text-secondary);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.info-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.info-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.info-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.info-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
}

.info-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-cta {
    text-align: center;
    padding: 24px 0;
}

.btn-lg {
    padding: 14px 36px;
    font-size: 16px;
    border-radius: 10px;
}

/* ===== COMMENT ÇA MARCHE ===== */
.howto-steps {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 24px 0;
}

.howto-step {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: var(--white);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.howto-step:hover {
    transform: translateX(6px);
}

.howto-num {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    background: var(--primary);
    color: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
}

.howto-step h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 4px;
}

.howto-step p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.howto-video {
    margin-top: 32px;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow);
}

.howto-video h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--dark);
}

.video-wrapper {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* ===== EDIT MODE (Modifier texte) ===== */
.tool-highlight {
    background: var(--primary-light) !important;
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    font-weight: 600;
}

.tool-highlight.active {
    background: var(--primary) !important;
    color: var(--white) !important;
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.25);
}

.canvas-wrapper.edit-mode {
    cursor: crosshair;
}

.canvas-wrapper.edit-mode .canvas-container {
    cursor: crosshair;
}

.edit-mode-banner {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: var(--radius);
    padding: 8px 16px;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: #92400e;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    animation: fadeIn 0.2s ease;
}

.edit-mode-banner svg {
    flex-shrink: 0;
}

.edit-replace-input {
    position: absolute;
    z-index: 500;
    background: var(--white);
    border: 2px solid var(--primary);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    outline: none;
    min-width: 60px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.edit-replace-input:focus {
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.2), 0 2px 8px rgba(0,0,0,0.15);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
    .app-header {
        flex-direction: column;
        gap: 12px;
        position: static;
    }
    
    .main-nav {
        width: 100%;
        overflow-x: auto;
    }

    .editor-main {
        flex-direction: column;
    }
    
    .pages-sidebar {
        width: 100%;
        max-height: 130px;
        display: flex;
        gap: 8px;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .page-thumb {
        flex-shrink: 0;
        width: 80px;
        height: 105px;
        margin-bottom: 0;
    }
    
    .editor-toolbar {
        gap: 8px;
    }

    .tool-group + .tool-group {
        padding-left: 0;
        border-left: none;
        padding-top: 8px;
        border-top: 1px solid var(--border);
        width: 100%;
    }

    .tool-group {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 600px) {
    .app-container {
        padding: 8px;
    }

    .upload-area {
        padding: 40px 20px;
    }

    .upload-content h3 {
        font-size: 16px;
    }

    .logo-text h1 {
        font-size: 16px;
    }

    .nav-btn span,
    .nav-btn svg {
        display: none;
    }

    #export-section {
        padding: 24px 16px;
    }

    .canvas-wrapper {
        padding: 10px;
    }
}

/* ===== FOOTER ===== */
.app-footer {
    text-align: center;
    padding: 24px 16px;
    margin-top: 24px;
    color: var(--text-secondary);
    font-size: 13px;
    border-top: 1px solid var(--border);
}

.app-footer a {
    color: var(--primary);
    text-decoration: none;
}

.app-footer a:hover {
    text-decoration: underline;
}

.footer-contact {
    margin-top: 4px;
    font-size: 12px;
}

.admin-link {
    display: inline-block;
    margin-top: 8px;
    font-size: 11px;
    color: var(--text-secondary) !important;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.admin-link:hover {
    opacity: 1;
}
