/**
 * Sender Form Styles.
 * Update v3.0.0: Erfolgsmeldung fixiert oben, Adressbuch-Autocomplete
 * Update v4.0.0: Audio-Dropdown Styles
 * Update v5.1.0: Kompaktere Formular-Abstände
 * Update v5.5.0: Kompakteres Layout, Textvorlagen-Styles
 * Update v5.5.8: Slim Scrollbar
 * Update v5.6.18: Berechtigungs-Einschränkungen
 * @package FourSystem_ECards
 */

/* Update v5.6.18: Berechtigungs-Einschränkungen */
.fsec-permission-restricted {
    position: relative;
    opacity: 0.7;
}

.fsec-permission-restricted::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    cursor: not-allowed;
    z-index: 5;
}

.fsec-permission-restricted select:disabled,
.fsec-permission-restricted input:disabled {
    background: #f0f0f1;
    color: #646970;
    cursor: not-allowed;
}

.fsec-permission-badge {
    display: inline-block;
    margin-left: 8px;
    font-size: 14px;
    vertical-align: middle;
}

.fsec-permission-hint {
    margin: 8px 0 0;
    padding: 8px 12px;
    background: linear-gradient(135deg, #fff3cd, #ffeeba);
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-size: 13px;
    color: #856404;
}

.fsec-permission-hint::before {
    content: '💡 ';
}

/* Permission Alert Popup */
.fsec-permission-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 15px;
    background: linear-gradient(135deg, #fff3cd, #ffeeba);
    border: 1px solid #ffc107;
    border-left: 4px solid #ffc107;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    animation: fsec-slide-in 0.3s ease-out;
}

@keyframes fsec-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fsec-permission-alert.fsec-alert-hiding {
    opacity: 0;
    transform: translateY(-10px);
    transition: opacity 0.3s, transform 0.3s;
}

.fsec-alert-icon {
    font-size: 20px;
}

.fsec-alert-message {
    flex: 1;
    color: #856404;
    font-size: 14px;
    font-weight: 500;
}

.fsec-alert-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #856404;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.fsec-alert-close:hover {
    opacity: 1;
}

/* Klick-Overlay für gesperrte Bereiche */
.fsec-permission-restricted .fsec-form-field {
    position: relative;
}

.fsec-send-form {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    z-index: 10;
    overflow-y: auto;
}

/* Update v5.5.8: Slim Scrollbar */
.fsec-send-form::-webkit-scrollbar {
    width: 6px;
}

.fsec-send-form::-webkit-scrollbar-track {
    background: transparent;
}

.fsec-send-form::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.fsec-send-form::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Firefox */
.fsec-send-form {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.fsec-send-form-content {
    display: flex;
    min-height: 100%;
    min-width: 900px;
}

.fsec-send-form-left {
    flex: 2;
    min-width: 550px;
    padding: 20px 25px;
    overflow-y: auto;
}

.fsec-send-form-right {
    flex: 1;
    padding: 15px;
    background: #f5f5f5;
    border-left: 1px solid #ddd;
    display: flex;
    flex-direction: column;
}

.fsec-send-form-title {
    margin: 0 0 15px 0;
    font-size: 20px;
    font-weight: 600;
    color: #1d2327;
}

.fsec-form-section {
    margin-bottom: 12px;
}

.fsec-form-section h4 {
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 600;
    color: #50575e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fsec-form-row {
    display: flex;
    gap: 12px;
}

.fsec-form-field {
    flex: 1;
    margin-bottom: 8px;
    position: relative;
}

.fsec-form-field-full {
    flex: none;
    width: 100%;
}

.fsec-form-field label {
    display: block;
    margin-bottom: 3px;
    font-weight: 500;
    color: #1d2327;
    font-size: 13px;
}

.fsec-form-field label .required {
    color: #d63638;
}

.fsec-form-field input[type="text"],
.fsec-form-field input[type="email"],
.fsec-form-field input[type="datetime-local"],
.fsec-form-field select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.4;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.fsec-form-field input:focus,
.fsec-form-field select:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}

.fsec-form-field input.foursys-error {
    border-color: #d63638;
}

.fsec-field-error {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #d63638;
}

.fsec-field-hint {
    margin-top: 5px;
    font-size: 12px;
    color: #646970;
}

/* Update v3.0.0: Adressbuch-Autocomplete */
.fsec-autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #8c8f94;
    border-top: none;
    border-radius: 0 0 4px 4px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.fsec-autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

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

.fsec-autocomplete-item:hover,
.fsec-autocomplete-item.foursys-selected {
    background: #f0f6fc;
}

.fsec-autocomplete-name {
    font-weight: 500;
}

.fsec-autocomplete-email {
    font-size: 12px;
    color: #646970;
}

/* WYSIWYG Editor */
.fsec-message-editor {
    border: 1px solid #8c8f94;
    border-radius: 4px;
    overflow: hidden;
}

.fsec-editor-toolbar {
    display: flex;
    align-items: center;
    padding: 8px;
    background: #f6f7f7;
    border-bottom: 1px solid #dcdcde;
    gap: 4px;
}

.fsec-toolbar-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
}

.fsec-toolbar-btn:hover {
    background: #dcdcde;
}

.fsec-toolbar-divider {
    width: 1px;
    height: 20px;
    background: #dcdcde;
    margin: 0 8px;
}

.fsec-editor-content {
    min-height: 80px;
    padding: 10px;
    font-size: 13px;
    line-height: 1.5;
    outline: none;
}

/* Emoji Picker - Update v5.5.1: Erweitert mit Kategorien */
.fsec-emoji-picker-extended {
    position: absolute;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    width: 320px;
    max-height: 400px;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.fsec-emoji-tabs {
    display: flex;
    border-bottom: 1px solid #dcdcde;
    padding: 4px;
    gap: 2px;
    background: #f9f9f9;
    border-radius: 8px 8px 0 0;
}

.fsec-emoji-tab {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 16px;
    border-radius: 4px;
    transition: background 0.2s;
}

.fsec-emoji-tab:hover {
    background: #e9ecef;
}

.fsec-emoji-tab.foursys-active {
    background: #2271b1;
    color: #fff;
}

.fsec-emoji-search {
    padding: 8px;
    border-bottom: 1px solid #eee;
}

.fsec-emoji-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    font-size: 13px;
}

.fsec-emoji-search input:focus {
    border-color: #2271b1;
    outline: none;
}

.fsec-emoji-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    max-height: 250px;
}

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

.fsec-emoji-picker-extended .fsec-emoji-grid span {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 4px;
    font-size: 20px;
    transition: background 0.15s, transform 0.15s;
}

.fsec-emoji-picker-extended .fsec-emoji-grid span:hover {
    background: #f0f6fc;
    transform: scale(1.2);
}

/* Update v5.5.10: Keine Ergebnisse Meldung */
.fsec-emoji-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 15px;
    color: #646970;
    font-size: 12px;
}

/* Update v5.5.3: [empfänger] Variable Button - alle Pseudo-Elemente entfernen */
.fsec-insert-var-btn {
    font-family: monospace !important;
    font-size: 10px !important;
    color: #2271b1 !important;
    padding: 4px 8px !important;
    min-width: auto !important;
    width: auto !important;
    background: #f0f6fc !important;
    border: 1px solid #c3c4c7 !important;
    border-radius: 3px !important;
    cursor: pointer !important;
    line-height: 1.2 !important;
    height: auto !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    position: relative !important;
    overflow: visible !important;
}

.fsec-insert-var-btn::before,
.fsec-insert-var-btn::after {
    display: none !important;
    content: none !important;
}

.fsec-insert-var-btn:hover {
    background: #e5f2ff !important;
    border-color: #2271b1 !important;
}

.fsec-insert-var-btn:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* Checkboxen - Update v5.1.0: Kompakter */
.fsec-form-options {
    background: #f6f7f7;
    padding: 8px 10px;
    border-radius: 4px;
}

.fsec-form-checkbox {
    margin-bottom: 4px;
}

.fsec-form-checkbox:last-child {
    margin-bottom: 0;
}

.fsec-form-checkbox label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-weight: normal;
    font-size: 12px;
}

.fsec-form-checkbox label.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.fsec-form-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
}

.fsec-option-hint {
    font-size: 10px;
    color: #646970;
    margin-left: 5px;
}

/* Buttons - Update v5.5.8: Weniger Abstand oben */
.fsec-form-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    padding-top: 12px;
    border-top: 1px solid #dcdcde;
}

.fsec-btn {
    padding: 7px 14px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.fsec-btn-primary {
    background: #2271b1;
    color: #fff;
}

.fsec-btn-primary:hover {
    background: #135e96;
}

.fsec-btn-secondary {
    background: #f6f7f7;
    color: #2271b1;
    border: 1px solid #2271b1;
}

.fsec-btn-secondary:hover {
    background: #f0f0f1;
}

.fsec-btn-link {
    background: transparent;
    color: #646970;
    padding: 10px;
}

.fsec-btn-link:hover {
    color: #2271b1;
}

.fsec-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Preview Card */
.fsec-preview-card {
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.fsec-preview-image {
    width: 100%;
    background: #f0f0f1;
}

.fsec-preview-image img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
}

.fsec-preview-message {
    padding: 15px;
    background: #fff;
    border-top: 1px solid #eee;
    min-height: 60px;
}

.fsec-preview-message-label {
    font-size: 11px;
    font-weight: 600;
    color: #646970;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.fsec-preview-message-content {
    font-size: 13px;
    line-height: 1.5;
    color: #1d2327;
    word-wrap: break-word;
}

.fsec-preview-message-content:empty::before {
    content: 'Deine Nachricht erscheint hier...';
    color: #a7aaad;
    font-style: italic;
}

/* Update v5.5.11: Erfolgsmeldung FIXIERT oben - höchster z-index */
.fsec-form-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 20px 40px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 2147483647; /* Höchster möglicher z-index */
    min-width: 300px;
}

.fsec-form-message.foursys-success {
    border-top: 4px solid #00a32a;
}

.fsec-form-message.foursys-error {
    border-top: 4px solid #d63638;
}

/* Mobile */
@media (max-width: 768px) {
    .fsec-send-form-content {
        flex-direction: column-reverse;
        min-width: auto;
    }
    
    .fsec-send-form-left {
        min-width: auto;
        padding: 20px;
    }
    
    .fsec-send-form-right {
        border-left: none;
        border-bottom: 1px solid #ddd;
        padding: 15px;
    }
    
    .fsec-preview-card {
        display: flex;
        flex-direction: row;
    }
    
    .fsec-preview-image {
        width: 120px;
        flex-shrink: 0;
    }
    
    .fsec-preview-message {
        flex: 1;
        border-top: none;
        border-left: 1px solid #eee;
    }
    
    .fsec-form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .fsec-form-buttons {
        flex-direction: column;
    }
    
    .fsec-btn {
        width: 100%;
    }
    
    .fsec-form-message {
        left: 10px;
        right: 10px;
        transform: none;
        min-width: auto;
    }
}

/* === Update v4.0.0: Audio-Dropdown === */
.fsec-audio-section {
    background: #f0f6fc;
    border-radius: 4px;
    padding: 15px;
    border: 1px solid #c3c4c7;
}

.fsec-audio-section h4 {
    margin-top: 0;
}

.fsec-audio-select {
    flex: 1;
}

.fsec-audio-section .fsec-form-field {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 0;
}

.fsec-btn-audio-preview {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 4px;
    background: #2271b1;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s ease;
}

.fsec-btn-audio-preview:hover {
    background: #135e96;
}

/* === Update v5.5.0: Kompakteres Layout === */
.fsec-form-row-sections {
    display: flex;
    gap: 20px;
}

.fsec-form-section-half {
    flex: 1;
    min-width: 0;
}

.fsec-form-row-options {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.fsec-form-row-options .fsec-form-section-half {
    flex: 1;
}

.fsec-form-row-options .fsec-form-field {
    margin-bottom: 0;
}

/* === Update v5.5.0: Textvorlagen Styles === */
.fsec-template-save-checkbox {
    margin-top: 8px;
}

.fsec-template-form {
    margin-top: 10px;
    padding: 12px;
    background: #f0f6fc;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
}

.fsec-template-form .fsec-form-field {
    margin-bottom: 8px;
}

.fsec-template-hint {
    font-size: 11px;
    color: #646970;
    margin-top: 5px;
}

.fsec-template-hint code {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 11px;
}

.fsec-template-select-wrapper {
    margin-bottom: 12px;
}

.fsec-template-select-wrapper h4 {
    margin-bottom: 5px;
}

/* Update v5.5.2: Dropdown ohne Suchfeld */
.fsec-template-select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 12px;
    background: #fff;
}

.fsec-template-select:focus {
    border-color: #2271b1;
    outline: none;
}

/* Guest Hint für Textvorlagen */
.fsec-template-guest-hint {
    font-size: 11px;
    color: #d63638;
    margin-top: 5px;
    display: none;
}

.fsec-template-guest-hint.foursys-visible {
    display: block;
}

/* === Update v5.5.7: Mobile Formular Styles === */

/* Mobile Close Button - auf Desktop verstecken */
.fsec-mobile-close-btn {
    display: none;
}

@media (max-width: 768px) {
    /* Mobile Close Button anzeigen */
    .fsec-mobile-close-btn {
        display: flex;
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 100;
        width: 36px;
        height: 36px;
        background: transparent;
        border: none;
        color: #50575e;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        padding: 0;
    }
    
    .fsec-mobile-close-btn:hover {
        color: #1d2327;
    }
    
    .fsec-mobile-close-btn svg {
        width: 24px;
        height: 24px;
    }
    
    /* Formular-Content: Vorschau oben, Formular unten */
    .fsec-send-form-content {
        min-width: auto;
        flex-direction: column-reverse; /* Rechts (Vorschau) wird oben */
    }
    
    /* Vorschau-Bereich (rechte Spalte) wird oben angezeigt */
    .fsec-send-form-right {
        display: block !important;
        width: 100%;
        padding: 15px;
        padding-top: 50px; /* Platz für X-Button */
        background: #f6f7f7;
        border-bottom: 1px solid #ddd;
    }
    
    .fsec-send-form-right .fsec-preview-card {
        max-width: 100%;
    }
    
    .fsec-send-form-right .fsec-preview-image img {
        max-width: 100%;
        height: auto;
    }
    
    /* Linker Bereich (Formular) */
    .fsec-send-form-left {
        min-width: auto;
        padding: 15px;
    }
    
    .fsec-form-row-sections,
    .fsec-form-row-options {
        flex-direction: column;
        gap: 0;
    }
    
    .fsec-form-section-half {
        width: 100%;
    }
    
    .fsec-form-buttons {
        flex-direction: column;
    }
    
    .fsec-form-buttons .fsec-btn {
        width: 100%;
    }
}
