/* ==========================================================================
   Text Editor Component
   Stili per views/partials/text-editor.ejs e text-editor-init.js
   Condiviso tra Homepage (/) e Tool (/tools/ai-watermark-remover-texts)
   ========================================================================== */

.homepage-editor-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1000;
}

main .editor-card {
    display: flex;
    flex-direction: column;
    border-radius: 20px;
    border: 1px solid var(--text-200);
    background-color: var(--background-50);
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

main .editor-card.is-dragover {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 2px var(--primary-500);
}

/* Toolbar */

main .editor-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background-color: var(--navbar-bg);
    border-bottom: 1px solid var(--text-200);
    flex-wrap: wrap;
}

main .toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

main .toolbar-divider {
    width: 1px;
    height: 22px;
    background-color: var(--text-200);
    margin: 0 4px;
}

main .toolbar-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 9px;
    border: 0 solid transparent;
    background-color: transparent;
    color: var(--text-700);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

main .toolbar-btn:hover {
    background-color: var(--background-100);
    color: var(--text-950);
}

main .toolbar-btn.active {
    background-color: var(--primary-50);
    color: var(--primary-600);
}

main .toolbar-btn-attach {
    width: auto;
    padding: 0 12px 0 10px;
    gap: 7px;
}

main .toolbar-attach-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

main .editor-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

main .editor-attach-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 22px;
    background-color: var(--primary-50);
    color: var(--primary-700);
    font-size: 13px;
    border-bottom: 1px solid var(--text-200);
}

main .editor-attach-progress[hidden] {
    display: none;
}

main .editor-attach-progress-spinner {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid var(--primary-200);
    border-top-color: var(--primary-600);
    animation: attachSpin 0.7s linear infinite;
    flex-shrink: 0;
}

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

main .editor-attach-error {
    padding: 10px 22px;
    background-color: var(--accent-50);
    color: var(--accent-700);
    font-size: 13px;
    border-bottom: 1px solid var(--text-200);
}

main .toolbar-status {
    margin-left: auto;
    font-size: 12.5px;
    color: var(--text-400);
    white-space: nowrap;
    padding-left: 8px;
}

/* Area di scrittura */

main .editor-area {
    min-height: 340px;
    max-height: calc(100vh - 200px);
    overflow: auto;
    padding: 28px 30px;
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.7;
    color: var(--text-950);
    outline: none;
    background-color: var(--background-50);
    text-align: left;
}

main .editor-area.is-empty::before {
    content: attr(data-placeholder);
    color: var(--text-400);
    pointer-events: none;
}

main .editor-area b,
main .editor-area strong {
    font-weight: 700;
    color: var(--text-950);
}

main .editor-area i,
main .editor-area em {
    font-style: italic;
}

main .editor-area ul,
main .editor-area ol {
    margin: 12px 0;
    padding-left: 26px;
}

main .editor-area ul {
    list-style-type: disc;
}

main .editor-area ol {
    list-style-type: decimal;
}

main .editor-area li {
    margin: 4px 0;
}

main .editor-area p {
    margin: 0 0 14px 0;
}

main .editor-area p:last-child {
    margin-bottom: 0;
}

/* Footer della card */

main .editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 22px;
    background-color: var(--navbar-bg);
    border-top: 1px solid var(--text-200);
    text-align: left;
}

main .editor-footer-hint {
    margin: 0;
    font-size: 13px;
    color: var(--text-500);
    flex: 1 1 auto;
    min-width: 0;
}

/* Bottone di submit specifico per l'editor */

main .editor-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 9999px;
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    box-sizing: border-box;
    background-color: var(--text-950);
    color: var(--background-50);
    flex: 0 0 auto;
    white-space: nowrap;
}

main .editor-submit-btn:hover:not(:disabled) {
    background-color: var(--text-800);
}

main .editor-submit-btn:active:not(:disabled) {
    transform: scale(0.98);
}

main .editor-submit-btn:disabled,
main .editor-submit-btn.is-loading {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

main .editor-submit-btn.is-loading span::after {
    content: '…';
}

/* Messaggio di stato invio */

.editor-status-message,
main .editor-status-message {
    text-align: center;
    font-size: 14px;
    padding: 12px 16px;
    visibility: hidden;
    overflow: hidden;
    transition: all 0.25s ease;
    max-height: 60px;
    bottom: -50px;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    max-width: 400px;
    width: calc(100% - 32px);
    border-radius: 12px;
    z-index: 99995;
}

.editor-status-message.visible,
main .editor-status-message.visible {
    visibility: visible;
    bottom: 48px;
}

.editor-status-message.is-error,
main .editor-status-message.is-error {
    color: var(--text-700);
    background-color: var(--background-200);
    border: 1px solid var(--text-300);
}

/* Modal Styled Checkbox (usato dai modali di text-editor-init.js) */

.modal-body .styled-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-family: var(--font-body);
}

.modal-body .styled-checkbox-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

.modal-body .styled-checkbox-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border-radius: 7px;
    border: 1.5px solid var(--text-400);
    background-color: var(--navbar-bg);
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.modal-body .styled-checkbox:hover .styled-checkbox-box {
    border-color: var(--primary-500);
}

.modal-body .styled-checkbox-input:active ~ .styled-checkbox-box {
    transform: scale(0.88);
}

.modal-body .styled-checkbox-icon {
    color: #ffffff;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.15s ease;
}

.modal-body .styled-checkbox-input:checked ~ .styled-checkbox-box {
    background-color: var(--primary-500);
    border-color: var(--primary-500);
    animation: checkboxPop 0.3s ease;
}

.modal-body .styled-checkbox-input:checked ~ .styled-checkbox-box .styled-checkbox-icon {
    transform: scale(1);
    opacity: 1;
}

.modal-body .styled-checkbox-input:focus-visible ~ .styled-checkbox-box {
    outline: 2px solid var(--primary-300);
    outline-offset: 2px;
}

.modal-body .styled-checkbox-label {
    font-size: 14px;
    color: var(--text-950);
    line-height: 1.4;
}

@keyframes checkboxPop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Responsive Editor */

@media (max-width: 640px) {
    main .editor-card {
        border-radius: 16px;
    }

    main .editor-toolbar {
        padding: 8px 10px;
    }

    main .toolbar-status {
        display: none;
    }

    main .toolbar-attach-label {
        display: none;
    }

    main .toolbar-btn-attach {
        width: 34px;
        padding: 0;
    }

    main .editor-area {
        min-height: 260px;
        padding: 20px 18px;
        font-size: 15px;
    }

    main .editor-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 14px 18px;
    }

    main .editor-footer-hint {
        text-align: center;
    }

    main .editor-submit-btn {
        width: 100%;
    }
}
