/* ============================================================
   shared/css/module.css
   Styles communs a tous les modules interactifs
   (welcome, chat, document, dropdown, share modal)
   ============================================================ */

/* ===== WELCOME INPUT SCREEN ===== */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
}

.welcome-screen.hidden {
    display: none;
}

.welcome-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-primary);
}

.welcome-header-logo {
    width: 34px;
    height: 34px;
}

.welcome-header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-header-info {
    flex: 1;
}

.welcome-header-title {
    font-weight: 600;
}

.welcome-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 40px 20px;
}

.welcome-logo {
    width: 80px;
    height: 80px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    overflow: hidden;
}

.welcome-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.welcome-title {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 8px;
}

.welcome-subtitle {
    color: var(--text-secondary);
    margin-bottom: 40px;
    text-align: center;
}

.welcome-input-container {
    width: 100%;
    max-width: 600px;
    display: none;
}

.welcome-input-container.visible {
    display: block;
}

.welcome-textarea {
    width: 100%;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 18px;
    resize: none;
    outline: none;
    min-height: 60px;
    line-height: 1.5;
    overflow: hidden;
    transition: background 0.3s, border-color 0.3s, color 0.3s;
}

.welcome-textarea:focus {
    border-color: var(--text-secondary);
}

.welcome-send {
    margin-top: 16px;
    width: 100%;
    padding: 14px;
    background: var(--btn-primary);
    border: none;
    border-radius: 10px;
    color: var(--btn-primary-text);
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s;
}

.welcome-send:hover {
    background: var(--btn-primary-hover);
}

.welcome-send svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* ===== CHAT SCREEN ===== */
.chat-screen {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-screen.visible {
    display: flex;
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    background: var(--bg-primary);
}

.chat-header-logo {
    width: 34px;
    height: 34px;
}

.chat-header-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-header-info {
    flex: 1;
}

.chat-header-title {
    font-weight: 600;
}

.chat-header-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.new-chat-btn-mobile {
    width: 36px;
    height: 36px;
    background: var(--btn-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 25px;
    font-weight: bold;
    color: var(--btn-primary-text);
    transition: all 0.2s;
}

.new-chat-btn-mobile:hover {
    background: var(--btn-primary-hover);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 0;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    margin-bottom: 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.message {
    max-width: 80%;
    margin-bottom: 16px;
    animation: msgFadeIn 0.3s ease;
}

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

.message.user {
    margin-left: auto;
}

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
}

.message.user .message-content {
    background: var(--user-msg-bg);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
    border-left: 3px solid var(--text-secondary);
}

.message.ai .message-content {
    background: var(--bg-secondary);
    border-bottom-left-radius: 4px;
    transition: background 0.3s;
}

.chat-input-container {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 18px;
    resize: none;
    outline: none;
    min-height: 44px;
    line-height: 1.4;
    overflow: hidden;
}

.chat-input:focus {
    border-color: var(--text-secondary);
}

.chat-send {
    width: 44px;
    height: 44px;
    background: var(--btn-primary);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-send:hover {
    background: var(--btn-primary-hover);
}

.chat-send svg {
    width: 20px;
    height: 20px;
    stroke: var(--btn-primary-text);
    stroke-width: 2;
    fill: none;
}

/* ===== DOCUMENT SCREEN ===== */
.document-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: none;
    flex-direction: column;
    z-index: 50;
}

.document-screen.visible {
    display: flex;
}

.document-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.document-back {
    width: 36px;
    height: 36px;
    background: var(--bg-secondary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.document-back svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.document-title {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.document-actions {
    display: flex;
    gap: 8px;
    position: relative;
}

.document-actions button {
    padding: 8px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.document-actions button:hover {
    background: var(--bg-tertiary);
}

.document-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;
}

.document-body {
    max-width: 800px;
    margin: 0 auto;
    background: none;
    border-radius: 0;
    padding: 0;
    line-height: 1.7;
}

.document-body h1 { font-size: 28px; margin-bottom: 8px; color: var(--text-primary); }
.document-body h2 { font-size: 23px; margin-top: 32px; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.document-body h3 { font-size: 18px; margin-top: 24px; margin-bottom: 12px; color: var(--text-secondary); }
.document-body p { margin-bottom: 12px; }
.document-body ul, .document-body ol { margin-bottom: 16px; padding-left: 24px; }
.document-body li { margin-bottom: 8px; }
.document-body table { width: 100%; border-collapse: collapse; margin: 16px 0; }
.document-body th, .document-body td { padding: 12px; border: 1px solid var(--border); text-align: left; }
.document-body th { background: var(--bg-tertiary); font-weight: 600; }

/* ===== MENU DROPDOWN DOCUMENT ===== */
.doc-menu-btn {
    font-size: 28px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    border-radius: 8px;
    transition: background 0.2s;
}

.doc-menu-btn:hover {
    background: var(--bg-tertiary);
}

.doc-dropdown-menu {
    display: none;
    position: absolute;
    right: 20px;
    top: 60px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    min-width: 180px;
}

[data-theme="dark"] .doc-dropdown-menu {
    background: #1a1a1a;
}

.doc-dropdown-menu.visible {
    display: block;
}

.doc-dropdown-menu button {
    display: block;
    width: 100%;
    padding: 12px 20px;
    text-align: left;
    border: none;
    background: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.doc-dropdown-menu button:hover {
    background: var(--bg-tertiary);
}

.doc-dropdown-menu .delete-btn {
    color: #dc2626;
    border-top: 1px solid var(--border);
}

.doc-dropdown-menu .delete-btn:hover {
    background: #fee;
}

/* ===== SHARE MODAL ===== */
.share-modal {
    display: none;
    position: absolute;
    z-index: 80;
    top: 100%;
    right: 0;
    margin-top: 8px;
}

.share-modal.visible {
    display: block;
}

.share-modal-content {
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 16px;
    width: 320px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.share-modal-title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 12px;
    text-align: left;
}

.share-link-container {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.share-link-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    min-width: 0;
}

.copy-link-btn {
    padding: 8px 14px;
    background: var(--btn-primary);
    border: none;
    border-radius: 6px;
    color: var(--btn-primary-text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

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

.share-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.share-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.share-action-btn svg { flex-shrink: 0; }
.share-action-btn.whatsapp { background: #25D366; color: #fff; }
.share-action-btn.whatsapp:hover { background: #1da851; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(37, 211, 102, 0.3); }
.share-action-btn.email { background: #4285F4; color: #fff; }
.share-action-btn.email:hover { background: #3367D6; transform: translateY(-2px); box-shadow: 0 4px 12px rgba(66, 133, 244, 0.3); }


/* ============================================================
   RESPONSIVE - MODULE
   ============================================================ */

/* ===== MOBILE (max-width: 768px) ===== */
@media (max-width: 768px) {
    /* Welcome */
    .welcome-content {
        padding: 20px 16px;
        justify-content: flex-start;
    }

    .welcome-logo {
        width: 56px;
        height: 56px;
        margin-bottom: 12px;
    }

    .welcome-title {
        font-size: 23px;
        margin-bottom: 6px;
    }

    .welcome-subtitle {
        margin-bottom: 16px;
        font-size: 15px;
    }

    .welcome-textarea {
        min-height: 50px;
        font-size: 17px;
    }

    .welcome-send {
        padding: 12px;
        font-size: 17px;
    }

    /* Chat */
    .chat-header {
        padding: 12px 16px;
    }

    .message {
        max-width: 90%;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-container {
        padding: 12px 16px;
    }

    .chat-input {
        font-size: 17px;
        min-height: 40px;
    }

    .new-chat-btn-mobile {
        display: flex;
    }

    /* Document */
    .document-header {
        padding: 12px 16px;
        gap: 8px;
    }

    .document-title {
        font-size: 16px;
    }

    .document-content {
        padding: 16px;
    }

    .document-body {
        padding: 0;
    }

    .document-body h1 { font-size: 23px; }
    .document-body h2 { font-size: 20px; margin-top: 24px; }
    .document-body h3 { font-size: 16px; }
    .document-body th, .document-body td { padding: 8px; font-size: 15px; }
    .document-body table { font-size: 15px; }

    .document-actions button {
        padding: 6px 10px;
        font-size: 15px;
    }

    /* Dropdown */
    .doc-dropdown-menu {
        right: 10px;
        top: 50px;
        min-width: 170px;
        max-width: 220px;
    }

    .doc-dropdown-menu button {
        padding: 16px 18px !important;
        font-size: 18px !important;
        white-space: nowrap;
        line-height: 1.2;
        display: block !important;
    }

    /* Share modal - bottom sheet mobile */
    .share-modal {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        margin-top: 0;
        background: rgba(0,0,0,0.4);
    }

    .share-modal.visible {
        display: flex;
        align-items: flex-end;
    }

    .share-modal-content {
        width: 100%;
        border-radius: 12px 12px 0 0;
        padding: 20px 16px;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
    }

    .share-link-container {
        flex-direction: column;
    }

    .copy-link-btn {
        width: 100%;
        text-align: center;
    }

    .share-actions {
        flex-direction: column;
        gap: 8px;
    }

    .share-action-btn {
        width: 100%;
    }
}

/* ===== TABLETTE (769px - 1024px) ===== */
@media (min-width: 769px) and (max-width: 1024px) {
    .welcome-content {
        padding: 24px 20px;
    }

    .welcome-logo {
        width: 64px;
        height: 64px;
    }

    .welcome-title {
        font-size: 28px;
    }

    .document-content {
        padding: 20px;
    }

    .document-body {
        max-width: 700px;
    }

    .share-modal-content {
        width: 300px;
    }
}

/* ===== BARRE DE PROGRESSION QUESTIONNAIRE ===== */
.progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    margin-top: 12px;
    margin-bottom: 4px;
}
.undo-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 4px 2px;
    cursor: pointer;
    transition: color 0.2s;
}
.undo-btn:hover { color: var(--text-primary); }
.undo-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.progress-bar-container {
    width: 100%;
    background: var(--bg-tertiary);
    border-radius: 4px;
    height: 8px;
    margin: 8px 0 12px 0;
    border: 1px solid var(--border);
}
.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--btn-primary);
    transition: width 0.4s ease;
    width: 0%;
    min-width: 4px;
}
.progress-label {
    font-size: 14px;
    color: var(--text-primary);
    text-align: right;
    margin-bottom: 4px;
    font-weight: 600;
}

/* Tablette */
@media (min-width: 769px) and (max-width: 1024px) {
    .progress-header { padding: 0 14px; margin-top: 10px; }
    .progress-bar-container {
        height: 7px;
        margin: 7px 0 11px 0;
    }
    .progress-label { font-size: 13px; }
    .undo-btn { font-size: 13px; padding: 4px 2px; }
}

/* Mobile standard */
@media (max-width: 768px) {
    .progress-header { padding: 0 12px; margin-top: 8px; }
    .progress-bar-container {
        height: 6px;
        margin: 6px 0 10px 0;
    }
    .progress-label { font-size: 13px; margin-bottom: 3px; }
    .undo-btn {
        font-size: 14px;
        padding: 6px 2px;
        min-height: 32px;
        display: inline-flex;
        align-items: center;
    }
}

/* Mobile petit — iPhone SE */
@media (max-width: 375px) {
    .progress-header { padding: 0 10px; margin-top: 6px; }
    .progress-bar-container {
        height: 5px;
        margin: 4px 0 8px 0;
    }
    .progress-label { font-size: 12px; margin-bottom: 2px; }
    .undo-btn {
        font-size: 13px;
        padding: 6px 2px;
        min-height: 32px;
    }
}
