/* Dashboard Personalization UI Styles */

/* Grid Container */
#dashboard-grid {
    position: relative;
    width: 100%;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    min-height: 600px;
    transition: all 0.3s ease;
}

/* Dashboard Widgets */
.dashboard-widget {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 0;
    position: relative;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    cursor: move;
}

.dashboard-widget:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

.dashboard-widget.dragging {
    opacity: 0.3;
    cursor: grabbing;
}

.dashboard-widget.resizing {
    cursor: se-resize;
}

/* Widget Header */
.widget-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    min-height: 48px;
}

.widget-icon {
    font-size: 20px;
    color: #6c757d;
    margin-right: 12px;
}

.widget-title {
    flex: 1;
    font-weight: 500;
    font-size: 16px;
    color: #343a40;
}

.widget-controls {
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dashboard-widget:hover .widget-controls {
    opacity: 1;
}

.widget-btn {
    background: none;
    border: none;
    color: #6c757d;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.widget-btn:hover {
    background: #e9ecef;
    color: #343a40;
}

.widget-btn i {
    font-size: 14px;
}

/* Widget Body */
.widget-body {
    flex: 1;
    padding: 16px;
    overflow: auto;
}

.widget-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
}

.widget-loading i {
    font-size: 32px;
    margin-bottom: 12px;
}

/* Resize Handle */
.widget-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: se-resize;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.dashboard-widget:hover .widget-resize-handle {
    opacity: 1;
}

.widget-resize-handle::before {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-right: 2px solid #6c757d;
    border-bottom: 2px solid #6c757d;
}

/* Drag Preview */
.widget-drag-preview {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    opacity: 0.8;
    transform: rotate(2deg);
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

/* Drop Indicator */
.drop-indicator {
    background: rgba(13, 110, 253, 0.1);
    border: 2px dashed #0d6efd;
    border-radius: 8px;
    pointer-events: none;
    display: none;
}

/* Grid Overlay (Debug) */
.grid-overlay {
    display: grid;
    grid-template-columns: inherit;
    grid-template-rows: inherit;
    gap: inherit;
}

/* Widget Library Modal */
.widget-library-modal .modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.widget-categories {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid #e9ecef;
    overflow-x: auto;
}

.category-btn {
    padding: 8px 16px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-btn:hover {
    background: #f8f9fa;
}

.category-btn.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.widget-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

.widget-library-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    transition: all 0.2s ease;
    cursor: pointer;
}

.widget-library-item:hover {
    border-color: #0d6efd;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.widget-preview-icon {
    font-size: 40px;
    color: #0d6efd;
    margin-bottom: 12px;
    display: block;
}

.widget-library-item h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    color: #343a40;
}

.widget-library-item p {
    margin: 0 0 12px 0;
    font-size: 12px;
    color: #6c757d;
    text-transform: capitalize;
}

.add-widget-btn {
    background: #0d6efd;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-widget-btn:hover {
    background: #0b5ed7;
}

/* AI Recommendations */
#ai-recommendations {
    background: white;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.recommendations-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
    color: #343a40;
    font-weight: 500;
}

.recommendations-header i {
    font-size: 20px;
    color: #6f42c1;
    margin-right: 12px;
}

.recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recommendation-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.recommendation-item:hover {
    background: #e9ecef;
}

.recommendation-item i {
    font-size: 24px;
    color: #6f42c1;
    margin-right: 16px;
}

.recommendation-content {
    flex: 1;
}

.recommendation-content h5 {
    margin: 0 0 4px 0;
    font-size: 14px;
    color: #343a40;
}

.recommendation-content p {
    margin: 0;
    font-size: 12px;
    color: #6c757d;
}

.apply-recommendation {
    background: #6f42c1;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apply-recommendation:hover {
    background: #59359a;
}

/* Dashboard Controls */
.dashboard-controls {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.dashboard-controls button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: #495057;
}

.dashboard-controls button:hover {
    background: #f8f9fa;
    border-color: #0d6efd;
    color: #0d6efd;
}

.dashboard-controls button i {
    font-size: 16px;
}

/* Notifications */
.dashboard-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 10000;
}

.dashboard-notification.show {
    transform: translateX(0);
}

.dashboard-notification.success {
    border-left: 4px solid #28a745;
}

.dashboard-notification.error {
    border-left: 4px solid #dc3545;
}

.dashboard-notification.info {
    border-left: 4px solid #17a2b8;
}

/* Settings Modal */
.widget-settings-modal .modal-content {
    width: 90%;
    max-width: 500px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 500;
    color: #495057;
    font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Modal Base Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: modalSlideIn 0.3s ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
}

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    color: #343a40;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: #f8f9fa;
    color: #343a40;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid #e9ecef;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    #dashboard-grid {
        padding: 12px;
        gap: 12px;
    }
    
    .widget-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-controls {
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .widget-header {
        padding: 10px 12px;
    }
    
    .widget-title {
        font-size: 14px;
    }
    
    .widget-controls {
        opacity: 1; /* Always show on mobile */
    }
}