/**
 * QForms Admin Styles
 * Version: 1.0.0
 * Wird in Phase 2 erweitert
 */

/* === Basis-Styles === */
.qforms-widget {
    margin-bottom: 20px;
}

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

.qforms-widget .card-header h5 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* === Builder-Styles (Platzhalter für Phase 2) === */
.qforms-builder {
    /* Wird in Phase 2 implementiert */
}

/* === Duplicate-Check-Feedback === */
.duplicate-feedback {
    margin-top: 0.5rem;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

.duplicate-feedback i {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 0.5rem;
}

/* ============================================
   SUBMISSIONS TABLE STYLES (Phase 4)
   ============================================ */

/* Spam Score Bar */
.qforms-submissions-table .spam-score-bar {
    width: 100%;
    height: 20px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.qforms-submissions-table .spam-score-bar .progress {
    height: 100%;
    transition: width 0.3s;
}

.qforms-submissions-table .spam-score-low {
    background: #28a745;
}

.qforms-submissions-table .spam-score-medium {
    background: #ffc107;
}

.qforms-submissions-table .spam-score-high {
    background: #dc3545;
}

/* Status Badges */
.qforms-status-draft {
    background-color: #6c757d;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.qforms-status-pending {
    background-color: #ffc107;
    color: #000;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.qforms-status-processed {
    background-color: #28a745;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.qforms-status-spam {
    background-color: #dc3545;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.qforms-status-archived {
    background-color: #6c757d;
    color: #fff;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

/* Duplicate Badge */
.qforms-duplicate-badge {
    background: #ff9800;
    color: #fff;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
}

/* ============================================
   TIMELINE STYLES (Phase 4)
   ============================================ */

.qforms-timeline {
    position: relative;
    padding-left: 30px;
}

.qforms-timeline-item {
    position: relative;
    padding-bottom: 20px;
    border-left: 2px solid #e0e0e0;
    padding-left: 20px;
}

.qforms-timeline-item:last-child {
    border-left: none;
}

.qforms-timeline-icon {
    position: absolute;
    left: -11px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #5d78ff;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

.qforms-timeline-icon svg {
    width: 12px;
    height: 12px;
}

.qforms-timeline-content {
    margin-bottom: 10px;
}

.qforms-timeline-content strong {
    color: #333;
    font-size: 14px;
}

.qforms-timeline-content p {
    color: #666;
    font-size: 13px;
    margin-top: 5px;
}

.qforms-timeline-time {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

/* Timeline icon colors based on event type */
.qforms-timeline-item.timeline-submission_created .qforms-timeline-icon {
    background: #28a745;
}

.qforms-timeline-item.timeline-status_changed .qforms-timeline-icon {
    background: #ffc107;
}

.qforms-timeline-item.timeline-email_sent .qforms-timeline-icon {
    background: #17a2b8;
}

.qforms-timeline-item.timeline-entity_created .qforms-timeline-icon {
    background: #6f42c1;
}

.qforms-timeline-item.timeline-note_added .qforms-timeline-icon {
    background: #fd7e14;
}

.qforms-timeline-item.timeline-pdf_exported .qforms-timeline-icon {
    background: #20c997;
}

/* ============================================
   DETAIL VIEW LAYOUT (Phase 4)
   ============================================ */

.qforms-submission-detail {
    display: grid;
    grid-template-columns: 70% 30%;
    gap: 20px;
}

.qforms-submission-data {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.qforms-submission-meta {
    background: transparent;
}

.qforms-submission-meta .card {
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.qforms-data-row {
    display: grid;
    grid-template-columns: 30% 70%;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.qforms-data-row:last-child {
    border-bottom: none;
}

.qforms-data-label {
    font-weight: 600;
    color: #333;
}

.qforms-data-value {
    color: #666;
    word-wrap: break-word;
}

.qforms-data-value a {
    color: #007bff;
    text-decoration: none;
}

.qforms-data-value a:hover {
    text-decoration: underline;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 992px) {
    .qforms-submission-detail {
        grid-template-columns: 100%;
    }

    .qforms-data-row {
        grid-template-columns: 100%;
        gap: 5px;
    }
}

/* ============================================
   STATISTICS WIDGETS
   ============================================ */

.qforms-stat-widget {
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.qforms-stat-widget h2 {
    font-size: 32px;
    margin: 0 0 5px 0;
    font-weight: 700;
}

.qforms-stat-widget p {
    font-size: 14px;
    color: #666;
    margin: 0;
}

.qforms-stat-widget.stat-total h2 {
    color: #007bff;
}

.qforms-stat-widget.stat-today h2 {
    color: #28a745;
}

.qforms-stat-widget.stat-week h2 {
    color: #17a2b8;
}

.qforms-stat-widget.stat-pending h2 {
    color: #ffc107;
}

/* ============================================
   CONDITIONAL LOGIC BUILDER (Phase 5)
   ============================================ */

.qforms-conditional-logic-builder {
    padding: 20px;
    max-height: 600px;
    overflow-y: auto;
}

.qforms-rule-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    background: #f9f9f9;
    transition: all 0.2s ease;
}

.qforms-rule-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.qforms-rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
}

.qforms-rule-header strong {
    color: #333;
    font-size: 14px;
}

.qforms-rule-body {
    padding-left: 0;
}

.qforms-condition-item {
    display: grid;
    grid-template-columns: 30% 25% 35% 10%;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ddd;
    align-items: center;
}

.qforms-condition-item select,
.qforms-condition-item input {
    height: 36px;
}

.qforms-condition-item .btn {
    height: 36px;
    width: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qforms-logic-toggle {
    display: inline-flex;
    background: #5d78ff;
    color: #fff;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin: 10px 0;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.qforms-logic-toggle:hover {
    background: #4a61cc;
}

.qforms-add-condition-btn {
    margin-top: 10px;
    font-size: 13px;
}

.qforms-delete-rule-btn,
.qforms-delete-condition-btn {
    transition: all 0.2s;
}

.qforms-delete-rule-btn:hover,
.qforms-delete-condition-btn:hover {
    transform: scale(1.1);
}

.qforms-conditions-container {
    margin-bottom: 15px;
}

/* Public Form Conditional */
.qforms-field-wrapper[data-conditional-target="true"] {
    transition: opacity 0.3s, max-height 0.3s, margin 0.3s;
    overflow: hidden;
}

.qforms-field-wrapper.qforms-hidden {
    opacity: 0;
    max-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Responsive Conditional Logic */
@media (max-width: 768px) {
    .qforms-condition-item {
        grid-template-columns: 100%;
        gap: 8px;
    }
    
    .qforms-condition-item .btn {
        width: 100%;
    }
}

/* ============================================
   OPTIONS EDITOR (Field Enhancements)
   ============================================ */

.qforms-options-editor {
    padding: 15px 0;
}

.qforms-options-list {
    margin-bottom: 15px;
    max-height: 400px;
    overflow-y: auto;
}

.qforms-option-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 8px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.qforms-option-item:hover {
    background: #f0f0f0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.qforms-option-item.disabled {
    opacity: 0.6;
    background: #fafafa;
}

.qforms-option-handle {
    cursor: move;
    color: #999;
    font-size: 18px;
    padding: 0 5px;
    user-select: none;
}

.qforms-option-handle:hover {
    color: #666;
}

.qforms-option-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.qforms-option-content input {
    height: 36px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.qforms-option-content input:focus {
    outline: none;
    border-color: #5d78ff;
    box-shadow: 0 0 0 2px rgba(93, 120, 255, 0.1);
}

.qforms-option-actions {
    display: flex;
    gap: 5px;
}

.qforms-option-toggle {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.qforms-option-toggle:hover {
    background: #f0f0f0;
}

.qforms-option-toggle.enabled {
    background: #28a745;
    border-color: #28a745;
    color: #fff;
}

.qforms-option-toggle.disabled {
    background: #dc3545;
    border-color: #dc3545;
    color: #fff;
}

.qforms-option-delete {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dc3545;
    background: #fff;
    color: #dc3545;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.qforms-option-delete:hover {
    background: #dc3545;
    color: #fff;
}

.qforms-add-option-btn {
    width: 100%;
    padding: 10px;
    border: 2px dashed #5d78ff;
    background: transparent;
    color: #5d78ff;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.qforms-add-option-btn:hover {
    background: rgba(93, 120, 255, 0.05);
    border-color: #4a61cc;
}

/* Sortable.js Drag State */
.qforms-option-item.sortable-ghost {
    opacity: 0.4;
    background: #e3f2fd;
}

.qforms-option-item.sortable-drag {
    opacity: 1;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* ============================================
   STYLE SETTINGS (Field Enhancements)
   ============================================ */

.qforms-style-settings {
    padding: 15px 0;
}

.qforms-style-group {
    margin-bottom: 20px;
}

.qforms-style-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 13px;
}

.qforms-style-group select,
.qforms-style-group input[type="text"],
.qforms-style-group input[type="color"] {
    width: 100%;
    height: 38px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.qforms-style-group input[type="color"] {
    padding: 2px;
    cursor: pointer;
}

.qforms-style-group select:focus,
.qforms-style-group input:focus {
    outline: none;
    border-color: #5d78ff;
    box-shadow: 0 0 0 2px rgba(93, 120, 255, 0.1);
}

.qforms-color-preview {
    display: flex;
    align-items: center;
    gap: 10px;
}

.qforms-color-preview input[type="color"] {
    width: 60px;
    height: 38px;
}

.qforms-color-preview input[type="text"] {
    flex: 1;
}

/* ============================================
   DIVIDER SETTINGS (Field Enhancements)
   ============================================ */

.qforms-divider-settings {
    padding: 15px 0;
}

.qforms-divider-group {
    margin-bottom: 20px;
}

.qforms-divider-group label {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 13px;
}

.qforms-divider-group select,
.qforms-divider-group input {
    width: 100%;
    height: 38px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.qforms-divider-group input[type="color"] {
    padding: 2px;
    cursor: pointer;
}

.qforms-divider-group input[type="number"] {
    width: 100%;
}

.qforms-divider-preview {
    margin-top: 15px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.qforms-divider-preview hr {
    margin: 0;
}

/* ============================================
   INLINE OPTIONS EDITOR (Kompakte Darstellung wie Conditional Logic)
   ============================================ */

.qforms-options-container {
    margin-top: 10px;
}

.qforms-options-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 4px;
}

.qforms-option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin-bottom: 8px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
    animation: slideInOption 0.3s ease;
}

.qforms-option-item:hover {
    background: #f9f9f9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.qforms-option-drag-handle {
    cursor: move;
    color: #999;
    display: flex;
    align-items: center;
    font-size: 16px;
    user-select: none;
}

.qforms-option-drag-handle:hover {
    color: #666;
}

.qforms-option-label,
.qforms-option-value {
    flex: 1;
    height: 34px;
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.qforms-option-label:focus,
.qforms-option-value:focus {
    outline: none;
    border-color: #5d78ff;
    box-shadow: 0 0 0 2px rgba(93, 120, 255, 0.1);
}

.qforms-option-toggle {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.qforms-option-toggle svg {
    width: 14px;
    height: 14px;
}

.qforms-option-toggle.btn-success {
    background: #28a745 !important;
    border-color: #28a745 !important;
    color: #fff !important;
}

.qforms-option-toggle.btn-secondary {
    background: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff !important;
}

.qforms-option-delete {
    width: 34px !important;
    height: 34px !important;
    min-width: 34px;
    padding: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.qforms-option-delete svg {
    width: 14px;
    height: 14px;
}

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

/* Database Options Info Banner */
.qforms-db-options-preview {
    margin-top: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.qforms-db-options-preview ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 0;
}

.qforms-db-options-preview ul li {
    padding: 4px 0;
    color: #666;
}











/* Sortable Drag State für Inline-Items */


/* ============================================
   RESPONSIVE DESIGN (Field Enhancements)
   ============================================ */

@media (max-width: 768px) {
    .qforms-option-content {
        grid-template-columns: 100%;
    }
    
    .qforms-option-item {
        flex-wrap: wrap;
    }
    
    .qforms-option-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    /* Inline Options auf Mobile */
    .qforms-option-item {
        flex-direction: column;
        gap: 10px;
    }
    
    .qforms-option-label,
    .qforms-option-value {
        width: 100%;
    }
}
