/* DP-Dash Custom Styles */

/* Mobile Heavy Range Indicator */
.mobile-heavy-range-indicator {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 8px;
    height: 8px;
    background: #ffc107;
    border-radius: 50%;
    border: 1px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
    animation: pulse-warning 2s infinite;
}

@keyframes pulse-warning {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
    }
    70% {
        box-shadow: 0 0 0 4px rgba(255, 193, 7, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    }
}

/* Comparison Badge Styles */
.comparison-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #e9ecef;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.comparison-indicator:hover {
    background: rgba(255, 255, 255, 1);
    border-color: #007bff;
    transform: scale(1.1);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 123, 255, 0.25);
}

.comparison-badge {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
    text-align: center;
}

.comparison-badge i {
    font-size: 1rem;
    margin-bottom: 0.125rem;
}

.comparison-badge small {
    font-size: 0.625rem;
    line-height: 1;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.comparison-badge.off {
    color: #6c757d;
}

.comparison-badge.off i {
    color: #6c757d;
}

.comparison-badge.previous_period {
    color: #007bff;
}

.comparison-badge.previous_period i {
    color: #007bff;
}

.comparison-badge.same_last_year {
    color: #28a745;
}

.comparison-badge.same_last_year i {
    color: #28a745;
}

.comparison-badge.year_over_year {
    color: #17a2b8;
}

.comparison-badge.year_over_year i {
    color: #17a2b8;
}

.comparison-badge.month_over_month {
    color: #ffc107;
}

.comparison-badge.month_over_month i {
    color: #ffc107;
}

.comparison-badge.same_last_month {
    color: #fd7e14;
}

.comparison-badge.same_last_month i {
    color: #fd7e14;
}

.comparison-badge.second_metric {
    color: #6f42c1;
}

.comparison-badge.second_metric i {
    color: #6f42c1;
}

/* Swap Indicator Styles */
.swap-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #198754 0%, #20c997 100%);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(25, 135, 84, 0.2);
}

.swap-indicator:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(25, 135, 84, 0.3);
    background: linear-gradient(135deg, #20c997 0%, #198754 100%);
}

.swap-indicator i {
    font-size: 14px;
    font-weight: bold;
}

/* Comparison Wizard Modal Styles */
.modal-content {
    border: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: 0.75rem;
}

.modal-header {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    color: white;
    border: none;
    padding: 1.5rem;
    border-radius: 0.75rem 0.75rem 0 0;
}

.modal-header .modal-title {
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
}

.modal-body {
    padding: 2rem;
    background: #fafbfc;
}

.modal-footer {
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 1.25rem 1.5rem;
    border-radius: 0 0 0.75rem 0.75rem;
}

/* Wizard Steps Styling */
.wizard-steps {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 2px solid #e9ecef;
}

.wizard-steps .d-flex {
    align-items: center;
    justify-content: center;
    gap: 0;
}

.wizard-steps .step {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 80px;
    position: relative;
    z-index: 1;
}

.wizard-steps .step.active {
    opacity: 1;
}

.wizard-steps .step.completed {
    opacity: 1;
}

.wizard-steps .step-number {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.wizard-steps .step.active .step-number {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    color: white;
    box-shadow: 0 0.25rem 0.5rem rgba(13, 110, 253, 0.3);
    transform: scale(1.05);
}

.wizard-steps .step.completed .step-number {
    background-color: #198754;
    color: white;
}

.wizard-steps .step-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    color: #6c757d;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.wizard-steps .step.active .step-title {
    color: #0d6efd;
    font-weight: 700;
}

.wizard-steps .step.completed .step-title {
    color: #198754;
}

.wizard-steps .step-line {
    flex: 1;
    height: 3px;
    background-color: #e9ecef;
    margin: 0 0.5rem;
    transition: all 0.3s ease;
    position: absolute;
    top: 24px;
    left: 0;
    right: 0;
    z-index: 0;
}

.wizard-step {
    display: none;
    animation: fadeIn 0.3s ease;
}

.wizard-step.active {
    display: block;
}

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

/* Comparison Type Cards */
.comparison-type-card {
    border: 2px solid #dee2e6;
    border-radius: 0.75rem;
    padding: 1.75rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.comparison-type-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s;
}

.comparison-type-card:hover {
    border-color: #0d6efd;
    box-shadow: 0 0.5rem 1.5rem rgba(13, 110, 253, 0.15);
    transform: translateY(-3px);
}

.comparison-type-card:hover::before {
    left: 100%;
}

.comparison-type-card.selected {
    border-color: #0d6efd;
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.05) 0%, rgba(11, 94, 215, 0.05) 100%);
    box-shadow: 0 0.5rem 1.5rem rgba(13, 110, 253, 0.25);
    transform: translateY(-3px) scale(1.02);
}

.comparison-type-card .card-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    color: #212529;
    transition: all 0.3s ease;
}

.comparison-type-card .card-description {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 0;
    line-height: 1.5;
}

.comparison-type-card.selected .card-title {
    color: #0d6efd;
}

/* Comparison Preview */
.comparison-preview {
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f2f5 100%);
    border-radius: 0.75rem;
    padding: 2rem;
    border: 1px solid #dee2e6;
}

.preview-metric {
    text-align: center;
    padding: 1.5rem;
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.preview-metric:hover {
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.12);
}

.preview-metric h6 {
    font-size: 0.8rem;
    font-weight: 700;
    color: #6c757d;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.preview-metric .metric-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: #0d6efd;
    margin-bottom: 0.5rem;
}

.preview-metric .metric-label {
    font-size: 0.8rem;
    color: #6c757d;
}

.trend-indicator {
    text-align: center;
    margin-top: 1.5rem;
}

.trend-indicator .badge {
    font-size: 0.9rem;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fa;
}

/* Grid Stack Customization */
.grid-stack {
    background: transparent;
}

.grid-stack-item-content {
    overflow: auto;
}

/* Grid Stack Customization */
.grid-stack {
    background: transparent;
}

.grid-stack-item-content {
    overflow: auto;
}


.grid-stack .grid-stack-item.ui-draggable-dragging,
.grid-stack .grid-stack-item.ui-resizable-resizing {
    opacity: 0.8;
    z-index: 1000;
}

/* Premium Widget Styles */
.widget-content {
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 12px;
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Premium card body styling */
.card-body {
    padding: 1.5rem;
}

/* Widget Card Header Alignment */
.card-header .d-flex {
    align-items: center;
    gap: 8px;
}

.card-header small {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-header .form-select-sm {
    min-width: 120px;
    height: 28px;
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

.card-header .btn-sm {
    height: 28px;
    width: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.card-header .comparison-indicator,
.card-header .swap-indicator {
    width: 28px;
    height: 28px;
    border-radius: 4px;
}

/* Success and danger subtle backgrounds */
.bg-success-subtle {
    background-color: rgba(34, 197, 94, 0.1);
}

.bg-danger-subtle {
    background-color: rgba(239, 68, 68, 0.1);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Widget header plugin icons */
.card-header .d-flex.align-items-center i {
    font-size: 0.875rem;
    color: #6c757d;
    margin-right: 0.25rem;
}

/* Plugin Cards */
.plugin-card {
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.plugin-card:hover {
    border-color: #0d6efd;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

/* Configured Datasource Cards */
.configured-datasource-card {
    transition: all 0.2s ease;
    border-left: 4px solid var(--success-color);
}

.configured-datasource-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.configured-datasource-card .card-header {
    background-color: #f9fafb !important;
    border-bottom: 1px solid #e5e7eb;
}

.configured-datasource-card .card-footer {
    background-color: #ffffff !important;
    border-top: 1px solid #e5e7eb;
}

/* Connection Status Badge */
#connectionStatus {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Wizard Steps */
.wizard-step {
    animation: fadeIn 0.3s ease-in;
}

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

/* Table Styles */
.table-responsive {
    max-height: 400px;
    overflow-y: auto;
}

/* Chart Container */
canvas {
    max-height: 100%;
}

/* Custom Badges */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Navbar */
.navbar-brand {
    font-size: 1.25rem;
}

/* Consistent navbar action sizing */
.navbar .btn,
.navbar .badge,
.navbar .dropdown-toggle {
    line-height: 1.25rem;
    height: 32px;
    border-radius: 8px;
}

.navbar .btn.btn-sm {
    height: 30px;
}

/* Sticky navbar separation */
.navbar {
    box-shadow: 0 1px 0 rgba(0,0,0,0.05);
}

/* Nav spacing and caret alignment */
.navbar .navbar-nav .nav-link {
    padding-right: .75rem;
    padding-left: .75rem;
    display: flex;
    align-items: center;
}
.navbar .d-flex {
    gap: 12px;
    align-items: center;
}
.navbar .dropdown-toggle::after {
    vertical-align: middle;
    margin-left: .25rem;
}
.navbar .dropdown-toggle {
    display: flex;
    align-items: center;
}

/* Focus visibility for accessibility */
.btn:focus-visible,
.comparison-indicator:focus-visible,
.swap-indicator:focus-visible {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Edit mode indicator: move to top-right and improve contrast */
.edit-mode-indicator {
    position: fixed;
    top: 16px;
    right: 16px;
    left: auto;
    background: rgba(73, 80, 87, 0.95);
    color: #fff;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    z-index: 1100;
}


/* Loading Spinner */
.spinner-border {
    width: 2rem;
    height: 2rem;
}

/* Mobile-First Responsive Design */
@media (max-width: 768px) {
    /* Dashboard Header Mobile Optimization */
    .container-fluid.py-4 {
        padding: 1rem !important;
    }
    
    .row.mb-3 {
        margin-bottom: 1rem !important;
    }
    
    .col-md-6:first-child {
        margin-bottom: 1rem;
    }
    
    .col-md-6.text-end {
        text-align: left !important;
    }
    
    .col-md-6.text-end .btn {
        margin-bottom: 0.5rem;
        margin-right: 0.5rem;
        width: 100%;
        max-width: 200px;
    }
    
    .col-md-6.text-end .btn-group {
        width: 100%;
        max-width: 200px;
    }
    
    .col-md-6.text-end .btn-group .btn {
        width: 100%;
        margin-right: 0;
    }
    
    /* Grid Stack Mobile Optimization */
    .grid-stack {
        padding: 0 !important;
    }
    
    .grid-stack-item {
        position: relative !important;
        width: 100% !important;
        left: 0 !important;
        margin-bottom: 1rem !important;
        min-height: 200px !important;
    }
    
    .grid-stack-item-content {
        height: 100% !important;
        min-height: 200px !important;
    }
    
    /* Widget Card Mobile Optimization */
    .card {
        height: 100% !important;
        min-height: 200px !important;
    }
    
    .card-body {
        padding: 1rem !important;
        height: calc(100% - 60px) !important;
        overflow-y: auto;
    }
    
    /* Widget Header Mobile Optimization */
    .card-header {
        padding: 0.75rem !important;
        min-height: 60px;
    }
    
    .card-header .d-flex {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    
    .card-header .d-flex > div:first-child {
        order: 1;
        margin-bottom: 0.5rem;
    }
    
    .card-header .d-flex > div:last-child {
        order: 2;
        display: flex;
        justify-content: space-between;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .card-header .form-select-sm {
        width: 100% !important;
        min-width: auto !important;
        margin-bottom: 0.5rem;
    }
    
    .card-header .btn-sm {
        height: 32px !important;
        width: 32px !important;
        padding: 0 !important;
        flex-shrink: 0;
    }
    
    .card-header .comparison-indicator,
    .card-header .swap-indicator {
        width: 32px !important;
        height: 32px !important;
        flex-shrink: 0;
    }
    
    /* Chart Container Mobile Optimization */
    .chart-container {
        height: 150px !important;
        min-height: 150px !important;
    }
    
    canvas {
        max-height: 150px !important;
    }
    
    /* Table Mobile Optimization */
    .table-responsive {
        max-height: 200px !important;
        font-size: 0.875rem;
    }
    
    .table th,
    .table td {
        padding: 0.5rem 0.25rem !important;
        font-size: 0.75rem;
    }
    
    /* Connection Status Mobile */
    .position-fixed.bottom-0.end-0 {
        bottom: 1rem !important;
        right: 1rem !important;
    }
    
    #connectionStatus {
        font-size: 0.75rem !important;
        padding: 0.375rem 0.75rem !important;
    }
}

/* Button hover effects */
.btn {
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Modal animations */
.modal.fade .modal-dialog {
    transition: transform 0.3s ease-out;
}

/* Alert animations */
.alert {
    animation: slideIn 0.3s ease-out;
}

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

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Utility classes */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-clamp: 2;
    overflow: hidden;
}

/* Add Widget Modal Styles */
.bg-gradient-primary {
    background: #0d6efd;
}

.modal-xl {
    max-width: 1200px;
}

/* Data Source Cards */
.datasource-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.datasource-card {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.datasource-card:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.15);
    transform: translateY(-1px);
}

.datasource-card.selected {
    border-color: #0d6efd;
    background-color: #f8f9ff;
}

.datasource-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.datasource-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #0d6efd, #0056b3);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    color: white;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
    flex-shrink: 0;
}

.datasource-info {
    flex: 1;
    min-width: 0;
}

.datasource-name {
    font-weight: 600;
    margin: 0;
    color: #2c3e50;
    font-size: 15px;
    line-height: 1.2;
}

.datasource-plugin {
    color: #6c757d;
    font-size: 13px;
    font-weight: 500;
    margin-top: 2px;
}

.datasource-status {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

.datasource-status .badge {
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 600;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.metric-card {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.metric-card:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.15);
}

.metric-card.selected {
    border-color: #0d6efd;
    background-color: #f8f9ff;
}

.metric-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.metric-icon {
    width: 36px;
    height: 36px;
    background: #0d6efd;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: white;
    font-size: 16px;
}

.metric-info h6 {
    font-weight: 600;
    margin: 0;
    color: #2c3e50;
    font-size: 14px;
}

.metric-description {
    color: #6c757d;
    font-size: 12px;
    line-height: 1.4;
    margin: 0;
}

.metric-type {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.metric-type-badge {
    background: #f8f9fa;
    color: #495057;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 500;
}

.metric-widgets {
    display: flex;
    gap: 4px;
}

.widget-type-badge {
    background: #e9ecef;
    color: #495057;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 500;
}

/* Widget Type Options */
.widget-type-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.widget-type-option {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.widget-type-option:hover {
    border-color: #0d6efd;
    box-shadow: 0 2px 8px rgba(13, 110, 253, 0.15);
}

.widget-type-option.selected {
    border-color: #0d6efd;
    background-color: #f8f9ff;
}

.widget-type-icon {
    width: 48px;
    height: 48px;
    background: #0d6efd;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: white;
    font-size: 20px;
}

.widget-type-name {
    font-weight: 600;
    color: #2c3e50;
    font-size: 13px;
    margin: 0;
}

/* Widget Preview */
.widget-preview {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.preview-placeholder {
    color: #6c757d;
}

.preview-widget-container {
    width: 100%;
    max-width: 250px;
}

.preview-widget {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid #e9ecef;
    width: 100%;
}

.preview-title {
    color: #6c757d;
    font-size: 12px;
    font-weight: 600;
    margin: 0 0 12px 0;
    text-align: center;
}

.preview-content {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.preview-type {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    display: block;
    color: #6c757d;
}

/* Card Preview Styles */
.preview-card {
    text-align: center;
    padding: 20px;
}

.preview-value {
    font-size: 28px;
    font-weight: 700;
    color: #2c3e50;
    margin: 0 0 8px 0;
}

.preview-trend {
    font-size: 12px;
    font-weight: 600;
}

.preview-trend.positive {
    color: #28a745;
}

.preview-trend.negative {
    color: #dc3545;
}

/* Table Preview Styles */
.preview-table {
    width: 100%;
}

.preview-table-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid #f1f3f4;
}

.preview-table-row:last-child {
    border-bottom: none;
}

.preview-table-name {
    font-size: 11px;
    color: #6c757d;
    font-weight: 500;
}

.preview-table-value {
    font-size: 11px;
    color: #2c3e50;
    font-weight: 600;
}

/* Step Indicator */
.step-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.step {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
}

.step.active {
    background: #0d6efd;
    color: white;
}

.step.completed {
    background: #198754;
    color: white;
}

/* Widget Steps */
.widget-step {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Settings UI Modern Styling */
.settings-card {
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.settings-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.settings-card .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid #dee2e6;
    border-radius: 12px 12px 0 0 !important;
    padding: 1rem 1.5rem;
}

.settings-card .card-header h5 {
    font-weight: 600;
    color: #495057;
    margin: 0;
}

.settings-card .card-body {
    padding: 1.5rem;
}

.settings-form-group {
    margin-bottom: 1.5rem;
}

.settings-form-group .form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
}

.settings-form-group .form-control {
    border: 2px solid #e9ecef;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    transition: all 0.3s ease;
}

.settings-form-group .form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.settings-btn {
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.settings-sidebar {
    position: sticky;
    top: 2rem;
}

.settings-sidebar .card {
    border: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border-radius: 12px;
}

.settings-sidebar .card-header {
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    color: white;
    border-radius: 12px 12px 0 0;
    padding: 1rem 1.5rem;
}

.settings-sidebar .list-group-item {
    border: none;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
}

.settings-sidebar .list-group-item:hover {
    background-color: #f8f9fa;
    transform: translateX(4px);
}

.settings-sidebar .list-group-item.active {
    background-color: #0d6efd;
    color: white;
    border-left: 4px solid #0b5ed7;
}

.settings-sidebar .list-group-item i {
    width: 20px;
    text-align: center;
}

.settings-stats {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 1rem;
    margin: 1rem 0;
}

.settings-stats .stat-item {
    text-align: center;
    padding: 0.5rem;
}

.settings-stats .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #0d6efd;
}

.settings-stats .stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: 500;
}

.settings-empty-state {
    text-align: center;
    padding: 3rem 2rem;
}

.settings-empty-state i {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.settings-empty-state h4 {
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.settings-empty-state p {
    color: #6c757d;
    margin-bottom: 2rem;
}

.settings-color-picker {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.settings-color-picker .form-control-color {
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
}

.settings-color-picker .form-control {
    flex: 1;
}

.settings-checkbox-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.settings-checkbox-group .form-check {
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.settings-checkbox-group .form-check:hover {
    border-color: #0d6efd;
    background-color: #f8f9ff;
}

.settings-checkbox-group .form-check-input:checked + .form-check-label {
    color: #0d6efd;
    font-weight: 600;
}

.settings-checkbox-group .form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.settings-preview {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1rem 0;
    border: 2px solid #dee2e6;
}

.settings-preview .navbar {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-xl {
        max-width: 95%;
        margin: 10px auto;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .widget-type-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .datasource-card-header {
        flex-direction: column;
        text-align: center;
    }
    
    .datasource-icon {
        margin-right: 0;
        margin-bottom: 8px;
    }
    
    .settings-checkbox-group {
        grid-template-columns: 1fr;
    }
    
    .settings-sidebar {
        position: static;
        margin-bottom: 2rem;
    }
}

/* Plugin Selection in Wizard Modal */
.plugin-card {
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid #e9ecef;
}

.plugin-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #0d6efd;
}

.plugin-card.selected {
    border-color: #0d6efd;
    background-color: rgba(13, 110, 253, 0.05);
}

.plugin-card.selected::after {
    content: '\2713';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background-color: #0d6efd;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.wizard-step {
    min-height: 300px;
}

.form-text a {
    color: #0d6efd;
    text-decoration: none;
}

.form-text a:hover {
    text-decoration: underline;
}

/* Info field in configuration */
.alert-info code {
    background-color: rgba(13, 110, 253, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
}

/* Edit Mode Styles */
/* Removed grey edit-mode toast indicator as dedicated toast already exists */

/* Animated border around the entire dashboard when in edit mode */
body.edit-mode::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border: 3px solid #fbbf24;
    pointer-events: none;
    z-index: 9998;
    animation: border-pulse 2s ease-in-out infinite;
}

@keyframes border-pulse {
    0%, 100% {
        opacity: 0.5;
        box-shadow: inset 0 0 30px rgba(251, 191, 36, 0.2);
    }
    50% {
        opacity: 0.8;
        box-shadow: inset 0 0 50px rgba(251, 191, 36, 0.4);
    }
}

/* Hide edit controls in view mode */
.view-mode .edit-only {
    display: none !important;
}

.edit-only {
    display: none !important;
}

body.edit-mode .edit-only {
    display: inline-block !important;
}

/* Responsive adjustments for edit mode */
@media (max-width: 768px) {
    .edit-mode-indicator {
        top: 10px;
        left: 10px;
        font-size: 0.7rem;
        padding: 6px 10px;
    }

    #editModeToggle {
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
    }

    #editModeText {
        display: none;
    }

    /* Fix navbar alignment on mobile */
    .navbar .d-flex {
        gap: 8px;
        flex-wrap: wrap;
    }

    .navbar .navbar-nav .nav-link {
        padding: 0.5rem 0.75rem;
    }

    /* Widget header responsive fixes */
    .card-header .d-flex {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .card-header .d-flex > div {
        justify-content: center;
    }

    .card-header .form-select-sm {
        width: 100%;
        min-width: auto;
    }
}

/* Notification animations */
@keyframes notification-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Connection status animations */
.connection-status-badge {
    transition: all 0.3s ease;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.875rem;
    position: relative;
}

.connection-status-badge.minimized {
    padding: 0.5rem !important;
    font-size: 1rem;
}

.connection-tooltip {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.75rem;
    line-height: 1.4;
    margin-bottom: 8px;
    z-index: 1001;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    min-width: 200px;
    max-width: 300px;
}

.connection-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.connection-status-badge:hover .connection-tooltip {
    display: block;
}

/* Ensure tooltips don't go out of viewport */
.connection-status-badge:hover .connection-tooltip {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

@media (max-width: 576px) {
    .connection-tooltip {
        left: 0;
        right: auto;
        transform: none;
        max-width: calc(100vw - 40px);
    }
    
    /* Extra small mobile optimizations */
    .container-fluid.py-4 {
        padding: 0.5rem !important;
    }
    
    .card-body {
        padding: 0.75rem !important;
    }
    
    .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
    }
    
    .btn-sm {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    
    .form-select-sm {
        font-size: 0.75rem;
        padding: 0.375rem 0.5rem;
    }
    
    .table th,
    .table td {
        padding: 0.375rem 0.25rem !important;
        font-size: 0.7rem;
    }
    
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-content {
        border-radius: 0.5rem;
    }
}

/* Mobile-specific dashboard optimizations */
.mobile-dashboard .grid-stack-item {
    touch-action: pan-y;
    will-change: transform;
}

.mobile-dashboard .card-header .btn {
    min-height: 44px; /* iOS touch target minimum */
    min-width: 44px;
}

.mobile-dashboard .comparison-indicator,
.mobile-dashboard .swap-indicator {
    min-height: 44px;
    min-width: 44px;
}

/* Mobile performance optimizations */
.mobile-dashboard * {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.mobile-dashboard .btn,
.mobile-dashboard .comparison-indicator,
.mobile-dashboard .swap-indicator {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Mobile scroll optimizations */

/* Mobile GPU acceleration */
.mobile-dashboard .grid-stack-item {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.mobile-dashboard .card {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Mobile memory optimization */
.mobile-dashboard .chart-container canvas {
    max-width: 100%;
    height: auto;
}

.mobile-dashboard .table-responsive {
    contain: layout style paint;
}

/* Mobile performance optimizations */
.mobile-dashboard .grid-stack-item {
    contain: layout style paint;
}

.mobile-dashboard .card {
    contain: layout style paint;
}

.mobile-dashboard .widget-content {
    contain: layout style paint;
}

/* Mobile touch optimizations */
.mobile-dashboard .btn,
.mobile-dashboard .comparison-indicator,
.mobile-dashboard .swap-indicator {
    touch-action: manipulation;
}

.mobile-dashboard .form-select,
.mobile-dashboard .form-control {
    touch-action: manipulation;
}

/* Mobile performance optimizations */
.mobile-dashboard .grid-stack-item {
    will-change: transform;
}

.mobile-dashboard .card {
    will-change: transform;
}

.mobile-dashboard .widget-content {
    will-change: transform;
}

/* Mobile memory optimizations */
.mobile-dashboard .chart-container {
    contain: layout style paint;
}

.mobile-dashboard .table-responsive {
    contain: layout style paint;
}

.mobile-dashboard .spinner-border {
    contain: layout style paint;
}

/* Mobile focus states */
.mobile-dashboard .mobile-focused {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

.mobile-dashboard .card:focus-within {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

/* Mobile accessibility improvements */
.mobile-dashboard .btn:focus,
.mobile-dashboard .comparison-indicator:focus,
.mobile-dashboard .swap-indicator:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

/* Mobile keyboard navigation */
.mobile-dashboard .card:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

.mobile-dashboard .form-select:focus,
.mobile-dashboard .form-control:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.25);
}

/* Mobile high contrast mode support */
@media (prefers-contrast: high) {
    .mobile-dashboard .card {
        border: 2px solid #000;
    }
    
    .mobile-dashboard .btn {
        border: 2px solid #000;
    }
    
    .mobile-dashboard .form-select,
    .mobile-dashboard .form-control {
        border: 2px solid #000;
    }
}

/* Mobile reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .mobile-dashboard * {
        animation: none !important;
        transition: none !important;
    }
    
    .mobile-dashboard .spinner-border {
        animation: none;
    }
    
    .mobile-dashboard .card {
        transition: none;
    }
    
    .mobile-dashboard .btn {
        transition: none;
    }
}

/* Mobile performance optimizations */
.mobile-dashboard .grid-stack-item {
    contain: layout style paint;
}

.mobile-dashboard .card {
    contain: layout style paint;
}

.mobile-dashboard .widget-content {
    contain: layout style paint;
}

.mobile-dashboard .chart-container {
    contain: layout style paint;
}

.mobile-dashboard .table-responsive {
    contain: layout style paint;
}

/* Mobile GPU acceleration */
.mobile-dashboard .grid-stack-item {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.mobile-dashboard .card {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Mobile memory optimization */
.mobile-dashboard .chart-container canvas {
    max-width: 100%;
    height: auto;
}

.mobile-dashboard .table-responsive {
    contain: layout style paint;
}

/* Mobile visual hierarchy improvements */
.mobile-dashboard .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

.mobile-dashboard .card-header small {
    font-weight: 600;
    color: #495057;
    line-height: 1.2;
}

.mobile-dashboard .card-body {
    background: #fff;
    padding: 1rem;
}

/* Mobile spacing improvements */
.mobile-dashboard .grid-stack-item {
    margin-bottom: 1rem;
}

.mobile-dashboard .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Mobile text improvements */
.mobile-dashboard .text-muted {
    color: #6c757d !important;
}

.mobile-dashboard .text-primary {
    color: #0d6efd !important;
}

.mobile-dashboard .text-success {
    color: #198754 !important;
}

.mobile-dashboard .text-danger {
    color: #dc3545 !important;
}

/* Mobile widget content optimization */
.mobile-widget .widget-content {
    overflow-x: auto;
}

.mobile-widget .chart-container {
    position: relative;
    height: 150px !important;
    min-height: 150px !important;
}

/* Mobile performance optimizations */
.mobile-widget .grid-stack-item {
    contain: layout style paint;
}

.mobile-widget .card {
    contain: layout style paint;
}

.mobile-widget .widget-content {
    contain: layout style paint;
}

.mobile-widget .chart-container {
    contain: layout style paint;
}

.mobile-widget .table-responsive {
    contain: layout style paint;
}

/* Mobile visual hierarchy improvements */
.mobile-widget .card-header {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
}

.mobile-widget .card-header small {
    font-weight: 600;
    color: #495057;
    line-height: 1.2;
}

.mobile-widget .card-body {
    background: #fff;
    padding: 1rem;
}

/* Mobile spacing improvements */
.mobile-widget .grid-stack-item {
    margin-bottom: 1rem;
}

.mobile-widget .container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Mobile text improvements */
.mobile-widget .text-muted {
    color: #6c757d !important;
}

/* Fix widget text visibility - ensure proper contrast */
.widget .card-title,
.widget .widget-title,
.widget h3,
.widget h4,
.widget h5,
.widget h6 {
    color: #212529 !important;
    font-weight: 600;
}

.widget .card-value,
.widget .metric-value,
.widget .value {
    color: #212529 !important;
    font-weight: 700;
    font-size: 1.5rem;
}

/* Fix table styling - reduce eye strain */
.widget table {
    background-color: #f8f9fa !important;
    border-radius: 0.375rem;
}

.widget table th {
    background-color: #e9ecef !important;
    color: #495057 !important;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6 !important;
}

.widget table td {
    background-color: #ffffff !important;
    color: #495057 !important;
    border-bottom: 1px solid #dee2e6 !important;
}

.widget table tbody tr:hover td {
    background-color: #f1f3f4 !important;
}

/* Ensure card text is visible */
.card .card-body {
    color: #495057 !important;
}

.card .card-body .text-muted {
    color: #6c757d !important;
}

.mobile-widget .text-primary {
    color: #0d6efd !important;
}

.mobile-widget .text-success {
    color: #198754 !important;
}

.mobile-widget .text-danger {
    color: #dc3545 !important;
}

/* Mobile performance optimizations */
.mobile-widget .grid-stack-item {
    will-change: transform;
}

.mobile-widget .card {
    will-change: transform;
}

.mobile-widget .widget-content {
    will-change: transform;
}

.mobile-widget .chart-container {
    will-change: transform;
}

.mobile-widget .table-responsive {
    will-change: transform;
}

/* Mobile GPU acceleration */
.mobile-widget .grid-stack-item {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.mobile-widget .card {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

/* Mobile memory optimization */
.mobile-widget .chart-container canvas {
    max-width: 100%;
    height: auto;
}

.mobile-widget .table-responsive {
    contain: layout style paint;
}

/* Mobile loading states */
.mobile-widget .spinner-border {
    width: 1.5rem;
    height: 1.5rem;
}

.mobile-widget .text-center.p-4 {
    padding: 1rem !important;
}

/* Mobile error states */
.mobile-widget .alert {
    margin: 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.5rem;
}

.mobile-widget .alert .btn-close {
    padding: 0.5rem;
    font-size: 0.75rem;
}

/* Mobile modal optimizations */
@media (max-width: 768px) {
    .modal-xl.modal-fullscreen-md-down {
        max-width: 100%;
        margin: 0;
        height: 100vh;
    }
    
    .modal-xl.modal-fullscreen-md-down .modal-content {
        height: 100vh;
        border-radius: 0;
    }
    
    .modal-xl.modal-fullscreen-md-down .modal-body {
        padding: 1rem;
        overflow-y: auto;
    }
    
    .modal-xl.modal-fullscreen-md-down .modal-header {
        padding: 1rem;
        border-bottom: 1px solid #dee2e6;
    }
    
    .modal-xl.modal-fullscreen-md-down .modal-footer {
        padding: 1rem;
        border-top: 1px solid #dee2e6;
        position: sticky;
        bottom: 0;
        background: white;
    }
}

/* Mobile navigation improvements */
@media (max-width: 768px) {
    .navbar-toggler {
        border: none;
        padding: 0.25rem 0.5rem;
    }
    
    .navbar-collapse {
        background: rgba(0, 0, 0, 0.1);
        border-radius: 0.5rem;
        margin-top: 0.5rem;
        padding: 0.5rem;
    }
    
    .navbar-nav .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 0.375rem;
        margin-bottom: 0.25rem;
    }
    
    .navbar-nav .nav-link:hover {
        background: rgba(255, 255, 255, 0.1);
    }
    
    /* Mobile dashboard header improvements */
    .container-fluid.py-4 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    .row.mb-3 {
        margin-bottom: 1rem !important;
    }
    
    .col-md-6 h2 {
        font-size: 1.5rem;
        margin-bottom: 0.5rem;
    }
    
    .col-md-6 p.text-muted {
        font-size: 0.875rem;
    }
    
    /* Mobile button improvements */
    .col-md-6.text-end .btn {
        font-size: 0.875rem;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.5rem;
        border-radius: 0.5rem;
    }
    
    .col-md-6.text-end .btn i {
        font-size: 0.875rem;
    }
    
    /* Mobile dropdown improvements */
    .dropdown-menu {
        border-radius: 0.5rem;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        border: none;
        padding: 0.5rem 0;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        border-radius: 0.375rem;
        margin: 0 0.5rem;
    }
    
    .dropdown-item:hover {
        background: #f8f9fa;
    }
}

/* Mobile edit mode improvements */
@media (max-width: 768px) {
    body.edit-mode .grid-stack-item {
        border: 2px dashed #28a745;
        border-radius: 0.5rem;
        margin-bottom: 1rem;
    }
    
    body.edit-mode .grid-stack-item:hover {
        border-color: #20c997;
        background: rgba(40, 167, 69, 0.05);
    }
    
    .edit-mode-indicator {
        position: fixed;
        top: 0.5rem;
        left: 0.5rem;
        right: auto;
        z-index: 1100;
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
        border-radius: 1rem;
        background: rgba(40, 167, 69, 0.9);
        color: white;
        --webkit-backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
    
    .mobile-edit-indicator {
        position: fixed;
        top: 0.5rem;
        left: 50%;
        transform: translateX(-50%);
        z-index: 1100;
        background: rgba(40, 167, 69, 0.95);
        color: white;
        padding: 0.5rem 1rem;
        border-radius: 1.5rem;
        font-size: 0.875rem;
        font-weight: 600;
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
        -webkit-backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.2);
        animation: slideDown 0.3s ease-out;
    }
    
    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(-20px);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }
    
    /* Mobile confirmation modal */
    .mobile-confirm-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 1rem;
    }
    
    .mobile-confirm-backdrop {
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        -webkit-backdrop-filter: blur(4px);
        backdrop-filter: blur(4px);
    }
    
    .mobile-confirm-dialog {
        position: relative;
        background: white;
        border-radius: 1rem;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
        max-width: 400px;
        width: 100%;
        animation: mobileModalSlideUp 0.3s ease-out;
    }
    
    .mobile-confirm-content {
        padding: 1.5rem;
        text-align: center;
    }
    
    .mobile-confirm-content p {
        margin-bottom: 1.5rem;
        font-size: 1rem;
        color: #333;
    }
    
    .mobile-confirm-buttons {
        display: flex;
        gap: 0.75rem;
        justify-content: center;
    }
    
    .mobile-confirm-buttons .btn {
        flex: 1;
        min-height: 44px;
        font-weight: 600;
    }
    
    @keyframes mobileModalSlideUp {
        from {
            opacity: 0;
            transform: translateY(30px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }
    
    /* Mobile empty state */
    .mobile-empty-state {
        padding: 2rem 1rem;
        text-align: center;
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-radius: 1rem;
        margin: 1rem 0;
        border: 2px dashed #dee2e6;
    }
    
    .mobile-empty-state i {
        color: #6c757d;
        margin-bottom: 1rem;
    }
    
    .mobile-empty-state h5 {
        color: #495057;
        margin-bottom: 0.5rem;
    }
    
    .mobile-empty-state p {
        color: #6c757d;
        margin-bottom: 1.5rem;
    }
    
    .mobile-empty-state .btn {
        min-height: 44px;
        padding: 0.75rem 1.5rem;
        font-weight: 600;
    }
    
    /* Mobile visual feedback improvements */
    .mobile-dashboard .btn:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    .mobile-dashboard .comparison-indicator:active,
    .mobile-dashboard .swap-indicator:active {
        transform: scale(0.95);
        transition: transform 0.1s ease;
    }
    
    /* Mobile loading states */
    .mobile-dashboard .spinner-border {
        animation: mobile-spin 1s linear infinite;
    }
    
    @keyframes mobile-spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }
    
    /* Mobile card hover effects */
    .mobile-dashboard .card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .mobile-dashboard .card:active {
        transform: scale(0.98);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    /* Mobile form improvements */
    .mobile-dashboard .form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    .mobile-dashboard .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    /* Mobile accessibility improvements */
    .mobile-dashboard .btn:focus,
    .mobile-dashboard .comparison-indicator:focus,
    .mobile-dashboard .swap-indicator:focus {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
    }
    
    .mobile-dashboard .card:focus-within {
        outline: 2px solid #0d6efd;
        outline-offset: 2px;
    }
    
    /* Mobile high contrast mode support */
    @media (prefers-contrast: high) {
        .mobile-dashboard .card {
            border: 2px solid #000;
        }
        
        .mobile-dashboard .btn {
            border: 2px solid #000;
        }
    }
    
    /* Mobile reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        .mobile-dashboard * {
            animation: none !important;
            transition: none !important;
        }
        
        .mobile-dashboard .spinner-border {
            animation: none;
        }
    }
    
    /* Mobile visual hierarchy improvements */
    .mobile-dashboard .card-header {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-bottom: 2px solid #dee2e6;
    }
    
    .mobile-dashboard .card-header small {
        font-weight: 600;
        color: #495057;
    }
    
    .mobile-dashboard .card-body {
        background: #fff;
    }
    
    /* Mobile spacing improvements */
    .mobile-dashboard .grid-stack-item {
        margin-bottom: 1rem;
    }
    
    .mobile-dashboard .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Mobile text improvements */
    .mobile-dashboard .text-muted {
        color: #6c757d !important;
    }
    
    .mobile-dashboard .text-primary {
        color: #0d6efd !important;
    }
    
    .mobile-dashboard .text-success {
        color: #198754 !important;
    }
    
    .mobile-dashboard .text-danger {
        color: #dc3545 !important;
    }
    
    /* Mobile loading states */
    .mobile-dashboard .spinner-border {
        width: 1.5rem;
        height: 1.5rem;
        border-width: 0.15em;
    }
    
    .mobile-dashboard .spinner-border-sm {
        width: 1rem;
        height: 1rem;
        border-width: 0.1em;
    }
    
    /* Mobile error states */
    .mobile-dashboard .alert {
        font-size: 0.875rem;
        padding: 0.75rem;
        margin: 0.5rem;
        border-radius: 0.5rem;
    }
    
    .mobile-dashboard .alert .btn-close {
        padding: 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Mobile success states */
    .mobile-dashboard .alert-success {
        background-color: rgba(25, 135, 84, 0.1);
        border-color: rgba(25, 135, 84, 0.2);
        color: #0f5132;
    }
    
    .mobile-dashboard .alert-warning {
        background-color: rgba(255, 193, 7, 0.1);
        border-color: rgba(255, 193, 7, 0.2);
        color: #664d03;
    }
    
    .mobile-dashboard .alert-danger {
        background-color: rgba(220, 53, 69, 0.1);
        border-color: rgba(220, 53, 69, 0.2);
        color: #842029;
    }
    
    /* Mobile visual hierarchy improvements */
    .mobile-dashboard .card-header {
        background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
        border-bottom: 2px solid #dee2e6;
        font-weight: 600;
    }
    
    .mobile-dashboard .card-header small {
        font-weight: 600;
        color: #495057;
        line-height: 1.2;
    }
    
    .mobile-dashboard .card-body {
        background: #fff;
        padding: 1rem;
    }
    
    /* Mobile spacing improvements */
    .mobile-dashboard .grid-stack-item {
        margin-bottom: 1rem;
    }
    
    .mobile-dashboard .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Mobile text improvements */
    .mobile-dashboard .text-muted {
        color: #6c757d !important;
    }
    
    .mobile-dashboard .text-primary {
        color: #0d6efd !important;
    }
    
    .mobile-dashboard .text-success {
        color: #198754 !important;
    }
    
    .mobile-dashboard .text-danger {
        color: #dc3545 !important;
    }
}

/* Enhanced Mobile UI Improvements */
@media (max-width: 768px) {
    /* Larger touch targets for all interactive elements */
    .btn, .form-control, .form-select {
        min-height: 44px;
        font-size: 16px;
    }
    
    .btn-sm {
        min-height: 38px;
        min-width: 38px;
    }
    
    /* Widget action buttons - better touch targets */
    .card-header .btn-sm {
        min-height: 40px !important;
        min-width: 40px !important;
        padding: 0.5rem !important;
        margin: 0.125rem;
    }
    
    .card-header .btn-sm i {
        font-size: 1rem;
    }
    
    /* Improved widget controls layout */
    .card-header {
        padding: 1rem !important;
    }
    
    .card-header .d-flex > div:last-child {
        gap: 0.5rem !important;
    }
    
    /* Better spacing for date range selector */
    .card-header .form-select-sm {
        font-size: 14px;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.75rem;
    }
    
    /* Improved modal handling on mobile */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-header {
        padding: 1rem;
    }
    
    .modal-body {
        padding: 1rem;
        max-height: calc(100vh - 200px);
        overflow-y: auto;
    }
    
    .modal-footer {
        padding: 1rem;
    }
    
    .modal-footer .btn {
        flex: 1;
        margin: 0.25rem;
    }
    
    /* Better dropdown menus */
    .dropdown-menu {
        min-width: 200px;
        font-size: 16px;
    }
    
    .dropdown-item {
        padding: 1rem 1.25rem;
        min-height: 44px;
    }
    
    /* Improved connection status indicator */
    #connectionStatus {
        font-size: 0.875rem !important;
        padding: 0.5rem 1rem !important;
        border-radius: 1.5rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }
    
    .position-fixed.bottom-0.end-0 {
        bottom: 1.5rem !important;
        right: 1.5rem !important;
    }
    
    /* Better scroll behavior */
    
    /* Prevent zoom on input focus */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="date"],
    textarea,
    select {
        font-size: 16px !important;
    }
    
    /* Improved widget titles */
    .card-title {
        font-size: 1rem;
        font-weight: 600;
        line-height: 1.4;
    }
    
    /* Better widget content spacing */
    .card-body {
        padding: 1.25rem !important;
    }
    
    /* Improved chart visibility on mobile */
    .chart-container {
        height: 200px !important;
        min-height: 200px !important;
        margin: 0.5rem 0;
    }
    
    canvas {
        max-height: 200px !important;
    }
    
    /* Better table on mobile */
    .table-responsive {
        max-height: 250px !important;
        font-size: 14px;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem !important;
        font-size: 14px;
        white-space: nowrap;
    }
    
    /* Improved comparison indicator */
    .comparison-indicator,
    .swap-indicator {
        min-width: 40px !important;
        min-height: 40px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Better mobile navigation */
    .navbar-nav .nav-link {
        padding: 1rem 1.25rem;
        font-size: 16px;
    }
    
    /* Improved dashboard grid spacing */
    .grid-stack-item {
        margin-bottom: 1.25rem !important;
    }
    
    /* Better widget empty states */
    .widget-empty-state {
        padding: 2rem 1rem;
        text-align: center;
    }
    
    .widget-empty-state i {
        font-size: 2.5rem;
        margin-bottom: 1rem;
    }
    
    /* Improved loading states */
    .spinner-border {
        width: 2rem;
        height: 2rem;
    }
    
    /* Better error messages */
    .alert {
        font-size: 14px;
        padding: 1rem;
        border-radius: 0.5rem;
    }
}

/* Extra small mobile devices */
@media (max-width: 576px) {
    /* Smaller buttons on very small screens but still touch-friendly */
    .btn {
        font-size: 14px;
        padding: 0.625rem 1rem;
    }
    
    /* Compact header on small screens */
    .card-header {
        padding: 0.75rem !important;
    }
    
    /* Smaller charts on very small screens */
    .chart-container {
        height: 180px !important;
        min-height: 180px !important;
    }
    
    canvas {
        max-height: 180px !important;
    }
    
    /* More compact widget spacing */
    .grid-stack-item {
        margin-bottom: 1rem !important;
    }
    
    /* Compact modal on small screens */
    .modal-dialog {
        margin: 0.25rem;
    }
    
    /* Smaller connection status */
    #connectionStatus {
        font-size: 0.75rem !important;
        padding: 0.375rem 0.75rem !important;
    }
    
    .position-fixed.bottom-0.end-0 {
        bottom: 1rem !important;
        right: 1rem !important;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    /* Optimize for landscape viewing */
    .chart-container {
        height: 180px !important;
        min-height: 180px !important;
    }
    
    canvas {
        max-height: 180px !important;
    }
    
    /* Compact header in landscape */
    .card-header {
        padding: 0.625rem !important;
    }
    
    .card-body {
        padding: 1rem !important;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    /* Better tap highlights */
    * {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
    
    /* Larger clickable areas */
    a, button, .clickable {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* Mobile: Keep GridStack but optimize for mobile */
@media (max-width: 576px) {
    /* Mobile-optimized GridStack for mobile devices */
    .grid-stack {
        padding: 0 !important;
    }
    
    .grid-stack-item {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }
    
    .grid-stack-item-content {
        height: auto !important;
        min-height: 200px !important;
    }
    
    /* Mobile Bootstrap cards styling */
    .mobile-dashboard-cards .card {
        margin-bottom: 1rem;
        border: 1px solid #dee2e6;
        border-radius: 0.375rem;
        box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    }
    
    .mobile-dashboard-cards .card-header {
        background-color: #f8f9fa;
        border-bottom: 1px solid #dee2e6;
        padding: 0.75rem 1rem;
        font-weight: 600;
        font-size: 0.875rem;
    }
    
    .mobile-dashboard-cards .card-body {
        padding: 1rem;
    }
    
    /* Mobile widget content styling */
    .mobile-dashboard-cards .widget-content {
        min-height: 200px;
    }
    
    /* Mobile chart containers */
    .mobile-dashboard-cards .chart-container {
        width: 100%;
        height: 250px;
        min-height: 250px;
    }
    
    .mobile-dashboard-cards canvas {
        width: 100% !important;
        height: 250px !important;
        max-height: 250px !important;
    }
    
    /* Mobile table styling */
    .mobile-dashboard-cards .table {
        font-size: 0.875rem;
        margin-bottom: 0;
    }
    
    .mobile-dashboard-cards .table th,
    .mobile-dashboard-cards .table td {
        padding: 0.5rem 0.25rem;
        vertical-align: middle;
    }
    
    /* Mobile card metrics */
    .mobile-dashboard-cards .metric-value {
        font-size: 1.5rem;
        font-weight: 700;
        color: #212529;
    }
    
    .mobile-dashboard-cards .metric-label {
        font-size: 0.875rem;
        color: #6c757d;
        margin-bottom: 0.25rem;
    }
}

/* Hide add widget button by default - only show in edit mode */
#addWidgetBtn {
    display: none !important;
}

/* Mobile-only: Hide edit controls on mobile */
@media (max-width: 768px) {
    #editModeToggle {
        display: none !important;
    }
    
    #addWidgetBtn {
        display: none !important;
    }
    
    .edit-only {
        display: none !important;
    }
    
    body.edit-mode .edit-only {
        display: none !important;
    }
}

/* Mobile-optimized GridStack for mobile devices */
@media (max-width: 768px) {
    .grid-stack {
        padding: 0 !important;
    }
    
    .grid-stack-item {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }
    
    .grid-stack-item-content {
        height: auto !important;
        min-height: 200px !important;
    }
}

/* Mobile widget full-width layout */
@media (max-width: 768px) {
    .card {
        width: 100% !important;
        margin-bottom: 1rem;
    }
    
    .card-header {
        padding: 0.875rem !important;
    }
    
    .card-body {
        padding: 1rem !important;
        height: auto !important;
    }
    
    /* Remove grid layout from chart containers on mobile */
    .chart-container {
        width: 100% !important;
        height: 200px !important;
        min-height: 200px !important;
    }
    
    canvas {
        width: 100% !important;
        max-height: 200px !important;
    }
}
