/**
 * Case Structuring Styles
 * 
 * Styles for drag-and-drop case structuring interface
 */

.case-structuring-wrapper,
.case-structuring-fallback {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Header */
.case-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.case-title {
    margin: 0;
    font-size: 24px;
    color: #333;
}

.case-toolbar {
    display: flex;
    gap: 8px;
}

.case-btn {
    padding: 8px 12px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.case-btn:hover {
    background: #e9e9e9;
    border-color: #999;
}

.case-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.case-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* Instructions */
.case-instructions {
    background: #f0f8ff;
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #0073aa;
}

.case-instructions p {
    margin: 0;
    color: #555;
    font-size: 15px;
}

/* Workspace */
.case-workspace {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    margin-bottom: 20px;
    min-height: 400px;
}

/* Components Panel */
.components-panel {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 15px;
}

.components-panel h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.components-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Component Card */
.case-component {
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    cursor: move;
    transition: all 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.case-component:hover:not(.placed) {
    border-color: #0073aa;
    box-shadow: 0 2px 6px rgba(0, 115, 170, 0.1);
    transform: translateY(-2px);
}

.case-component:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.case-component.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.case-component.placed {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.case-component.keyboard-dragging {
    outline: 3px dashed #0073aa;
    outline-offset: 3px;
}

/* Component Icons */
.component-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.component-revenue {
    background: #28a745;
    color: #fff;
}

.component-revenue::before {
    content: '📈';
}

.component-cost {
    background: #dc3545;
    color: #fff;
}

.component-cost::before {
    content: '📉';
}

.component-synergy {
    background: #17a2b8;
    color: #fff;
}

.component-synergy::before {
    content: '🔗';
}

.component-risk {
    background: #ffc107;
    color: #333;
}

.component-risk::before {
    content: '⚠️';
}

.component-exit {
    background: #6f42c1;
    color: #fff;
}

.component-exit::before {
    content: '🚪';
}

.component-financing {
    background: #fd7e14;
    color: #fff;
}

.component-financing::before {
    content: '💰';
}

/* Component Content */
.component-content {
    flex: 1;
}

.component-content h5 {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.component-content p {
    margin: 0;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

/* Categories Panel */
.categories-panel {
    display: flex;
    flex-direction: column;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    height: 100%;
}

/* Category Box */
.case-category {
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.case-category h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: #333;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

/* Dropzone */
.category-dropzone {
    flex: 1;
    min-height: 150px;
    background: #fff;
    border: 2px dashed #ddd;
    border-radius: 6px;
    padding: 15px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-dropzone.drag-over {
    border-color: #28a745;
    background: #f0fff4;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.category-dropzone.drag-over-invalid {
    border-color: #dc3545;
    background: #fff5f5;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.dropzone-placeholder {
    color: #999;
    text-align: center;
    font-style: italic;
    padding: 20px;
    margin: auto;
}

/* Placed Components */
.placed-component {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.placed-component:hover {
    border-color: #999;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.placed-component .component-icon {
    width: 24px;
    height: 24px;
    font-size: 14px;
}

.placed-component .component-name {
    flex: 1;
    font-size: 13px;
    color: #333;
}

.remove-component {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.remove-component:hover {
    color: #dc3545;
}

.remove-component .dashicons {
    font-size: 16px;
}

/* Progress Bar */
.case-progress {
    background: #f0f0f0;
    border-radius: 20px;
    height: 30px;
    position: relative;
    overflow: hidden;
    margin-bottom: 20px;
}

.progress-bar {
    background: linear-gradient(90deg, #28a745 0%, #20c997 100%);
    height: 100%;
    width: 0;
    transition: width 0.5s ease;
    border-radius: 20px;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 13px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

/* Feedback */
.case-feedback {
    display: none;
    padding: 15px 20px;
    border-radius: 6px;
    margin-top: 20px;
}

.case-feedback.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.case-feedback.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.case-feedback.info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

.case-feedback p {
    margin: 0 0 8px 0;
}

.case-feedback p:last-child {
    margin-bottom: 0;
}

.feedback-hint {
    font-size: 13px;
    opacity: 0.8;
    font-style: italic;
}

/* Touch Interface Adjustments */
.touch-interface .case-component {
    padding: 16px;
    min-height: 80px;
}

.touch-interface .case-btn {
    padding: 12px 16px;
    min-width: 44px;
    min-height: 44px;
}

.touch-interface .category-dropzone {
    min-height: 200px;
}

/* Dragging Clone */
.dragging-clone {
    pointer-events: none !important;
    z-index: 10000 !important;
    max-width: 280px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

/* Fallback Mode */
.case-structuring-fallback .fallback-form {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 6px;
    margin: 20px 0;
}

.component-assignment {
    margin-bottom: 20px;
    padding: 15px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.component-assignment label {
    display: block;
    margin-bottom: 8px;
}

.component-assignment strong {
    display: block;
    color: #333;
    margin-bottom: 4px;
}

.component-desc {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 10px;
}

.category-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.check-answers {
    margin-top: 20px;
}

/* Completion Modal */
.case-completion-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 100000;
}

.case-completion-modal .modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.case-completion-modal h2 {
    margin: 0 0 20px 0;
    color: #28a745;
    font-size: 28px;
}

.completion-stats {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
}

.completion-stats p {
    margin: 5px 0;
    font-size: 14px;
    color: #666;
}

/* Loading State */
.case-structuring-wrapper.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.case-structuring-wrapper.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: case-spin 1s linear infinite;
}

@keyframes case-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .case-workspace {
        grid-template-columns: 1fr;
    }
    
    .components-panel {
        max-height: 300px;
        overflow-y: auto;
    }
    
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .case-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }
    
    .case-toolbar {
        width: 100%;
        justify-content: space-between;
    }
}

/* Accessibility */
.screen-reader-text {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .case-component,
    .case-category,
    .category-dropzone {
        border-width: 3px;
    }
    
    .case-component:focus,
    .case-btn:focus {
        outline-width: 3px;
    }
}

/* Print Styles */
@media print {
    .case-toolbar,
    .remove-component {
        display: none;
    }
    
    .case-component {
        cursor: default;
        page-break-inside: avoid;
    }
}