/* Dashboard Specific Styles */

/* ===================================================
   DASHBOARD WIDGET ORGANIZATION SYSTEM
   =================================================== */

/* Remove forced heights and create flexible grid system - ONLY for dashboard */
.dashboard-container {
    padding: 1rem 0;
}

/* Fix for vertically stretched cards - override h-100 behavior - DASHBOARD ONLY */
.dashboard .card.h-100,
.dashboard-container .card.h-100 {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    display: flex;
    flex-direction: column;
}

/* Better card grid layout without forced height - DASHBOARD ONLY */
.dashboard .card,
.dashboard-container .card {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

/* Ensure card content fills appropriately without stretching - DASHBOARD ONLY */
.dashboard .card-body,
.dashboard-container .card-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1.25rem;
}

/* Fix for Bootstrap's equal height cards in rows - DASHBOARD ONLY */
.dashboard .row [class*="col-"] .card,
.dashboard-container .row [class*="col-"] .card {
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    width: 100%;
}

/* Dashboard specific row improvements */
.dashboard .row,
.dashboard-container .row {
    margin-bottom: 0;
    align-items: stretch;
}

.dashboard .row [class*="col-"],
.dashboard-container .row [class*="col-"] {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

/* Make all dashboard cards consistent */
.dashboard .card,
.dashboard-container .card {
    flex: 1;
    justify-self: stretch;
    align-self: stretch;
}

/* ===================================================
   IMPROVED DASHBOARD GRID LAYOUT
   =================================================== */

/* Summary cards row - ensure consistent heights */
.dashboard-container .summary-cards-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.dashboard-container .summary-cards-row .col-xl-4,
.dashboard-container .summary-cards-row .col-lg-6,
.dashboard-container .summary-cards-row .col-md-6 {
    flex: 1;
    min-width: 280px;
    margin-bottom: 0;
}

/* Widget rows with better organization */
.dashboard-container .widget-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: start;
}

.dashboard-container .widget-row.two-column {
    grid-template-columns: 1fr 1fr;
}

.dashboard-container .widget-row.three-column {
    grid-template-columns: repeat(3, 1fr);
}

.dashboard-container .widget-row .card {
    width: 100%;
    height: auto;
    margin-bottom: 0;
}

/* Chart containers with consistent sizing */
.dashboard-container .chart-widget {
    min-height: 350px;
}

.dashboard-container .chart-widget .card-body {
    padding: 1rem;
}

.dashboard-container .chart-widget canvas {
    max-height: 300px;
    width: 100% !important;
    height: auto !important;
}

/* Stats widgets for consistent height */
.dashboard-container .stats-widget {
    min-height: 120px;
}

.dashboard-container .stats-widget .card-body {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem 1rem;
}

/* List widgets with controlled height */
.dashboard-container .list-widget {
    min-height: 300px;
    max-height: 500px;
}

.dashboard-container .list-widget .card-body {
    padding: 0.75rem;
    overflow-y: auto;
}

/* ===================================================
   RESPONSIVE DASHBOARD IMPROVEMENTS
   =================================================== */

/* Large screens - 4 column layout for summary cards */
@media (min-width: 1400px) {
    .dashboard-container .summary-cards-row {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .dashboard-container .widget-row {
        grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    }
    
    .dashboard-container .widget-row.three-column {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Extra large screens */
@media (min-width: 1200px) {
    .dashboard-container .summary-cards-row .col-xl-4 {
        flex: 0 0 calc(33.333333% - 1rem);
        max-width: calc(33.333333% - 1rem);
    }
}

/* Large screens */
@media (min-width: 992px) and (max-width: 1199px) {
    .dashboard-container .summary-cards-row .col-lg-6 {
        flex: 0 0 calc(50% - 0.75rem);
        max-width: calc(50% - 0.75rem);
    }
    
    .dashboard-container .widget-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-container .widget-row.three-column {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium screens */
@media (min-width: 768px) and (max-width: 991px) {
    .dashboard-container .summary-cards-row {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-container .widget-row {
        grid-template-columns: 1fr;
    }
    
    .dashboard-container .widget-row.two-column,
    .dashboard-container .widget-row.three-column {
        grid-template-columns: 1fr;
    }
}

/* Small screens and below */
@media (max-width: 767px) {
    .dashboard-container .container-fluid {
        padding: 0.5rem;
    }
    
    .dashboard-container .summary-cards-row {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .dashboard-container .widget-row {
        grid-template-columns: 1fr;
        gap: 1rem;
        margin-bottom: 1.5rem;
    }
    
    .dashboard-container .chart-widget {
        min-height: 250px;
    }
    
    .dashboard-container .chart-widget canvas {
        max-height: 200px;
    }
    
    .dashboard-container .list-widget {
        min-height: 200px;
        max-height: 300px;
    }
    
    .dashboard-container .stats-widget {
        min-height: 100px;
    }
    
    .dashboard-container .card-body {
        padding: 1rem;
    }
}

/* ===================================================
   DASHBOARD CARD BORDER COLORS
   =================================================== */

.border-left-primary {
    border-left: 0.25rem solid #4e73df !important;
}

.border-left-success {
    border-left: 0.25rem solid #1cc88a !important;
}

.border-left-info {
    border-left: 0.25rem solid #36b9cc !important;
}

.border-left-warning {
    border-left: 0.25rem solid #f6c23e !important;
}

.border-left-danger {
    border-left: 0.25rem solid #e74a3b !important;
}

/* ===================================================
   DASHBOARD MODAL IMPROVEMENTS
   =================================================== */

/* Dashboard Modal Centering */
.modal-dialog.modal-dialog-centered {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: calc(100% - 3.5rem) !important;
    margin: 1.75rem auto !important;
}

/* Additional horizontal centering for Recent Activity modal */
.modal-dialog.modal-lg.modal-dialog-centered {
    max-width: 90% !important;
    width: 800px !important;
    margin-left: auto !important;
    margin-right: auto !important;
}

/* ===================================================
   DASHBOARD STYLING IMPROVEMENTS
   =================================================== */

/* Dashboard card spacing and shadows */
.dashboard .card,
.dashboard-container .card {
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
    border: 1px solid #e3e6f0;
    border-radius: 0.35rem;
    height: auto !important; /* Override any height forcing */
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.dashboard .card:hover,
.dashboard-container .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.25rem 2rem 0 rgba(58, 59, 69, 0.2) !important;
}

/* Text color overrides for readability */
.text-gray-800 {
    color: #5a5c69 !important;
}

.text-gray-300 {
    color: #dddfeb !important;
}

/* Dashboard specific sizing */
.h5 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    font-weight: 400;
    line-height: 1.2;
}

.text-xs {
    font-size: 0.75rem;
}

.font-weight-bold {
    font-weight: 700 !important;
}

/* ===================================================
   CHART IMPROVEMENTS
   =================================================== */

/* Chart containers */
.dashboard canvas,
.dashboard-container canvas {
    max-height: 400px;
    width: 100% !important;
    height: auto !important;
}

.dashboard .chart-container,
.dashboard-container .chart-container {
    position: relative;
    height: 300px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===================================================
   DASHBOARD HEADER STYLES
   =================================================== */

/* Dashboard header styles */
.dashboard-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 0;
    margin-bottom: 2rem;
}

.dashboard-header h1 {
    font-weight: 300;
    margin-bottom: 0.5rem;
}

.dashboard-header .subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* ===================================================
   ADDITIONAL WIDGET TYPES
   =================================================== */

/* Period selector buttons */
.period-selector .btn {
    min-width: 80px;
}

.period-selector .btn.active {
    background-color: #4e73df;
    border-color: #4e73df;
    color: white;
}

/* Dashboard widgets */
.widget-container {
    background: #f8f9fc;
    border-radius: 0.35rem;
    padding: 1.5rem;
}

.widget-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #5a5c69;
    margin-bottom: 1rem;
}

/* Recent activity list */
.recent-activity .list-group-item {
    border: none;
    padding: 0.75rem 0;
}

.recent-activity .list-group-item:not(:last-child) {
    border-bottom: 1px solid #e3e6f0;
}

.recent-activity .activity-icon {
    width: 40px;
    height: 40px;
    background: #f8f9fc;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #858796;
}

.recent-activity .activity-content {
    flex: 1;
}

.recent-activity .activity-time {
    font-size: 0.8rem;
    color: #858796;
}

/* Workflow statistics table */
.workflow-stats-table {
    font-size: 0.875rem;
}

.workflow-stats-table th {
    background-color: #f8f9fc;
    border-bottom: 1px solid #e3e6f0;
    color: #5a5c69;
    font-weight: 600;
    padding: 0.75rem;
}

.workflow-stats-table td {
    padding: 0.75rem;
    vertical-align: middle;
}

/* Badge customizations */
.badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* ===================================================
   LOADING AND EMPTY STATES
   =================================================== */

/* Loading state */
.dashboard-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.dashboard-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Chart legends */
.chart-legend {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    margin: 0 1rem;
}

.chart-legend-color {
    width: 12px;
    height: 12px;
    margin-right: 0.5rem;
    border-radius: 2px;
}

/* ===================================================
   UTILITY IMPROVEMENTS
   =================================================== */

/* Alert positioning for dashboard */
.dashboard .alert {
    position: relative;
    margin-bottom: 1rem;
}

/* Dropdown menu improvements */
.dashboard .dropdown-menu {
    border: 1px solid #e3e6f0;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.dashboard .dropdown-item {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.dashboard .dropdown-item:hover {
    background-color: #f8f9fc;
}

/* Date range picker styling */
.date-range-picker {
    background: white;
    border: 1px solid #d1d3e2;
    border-radius: 0.35rem;
    padding: 0.375rem;
}

.date-range-picker input[type="date"] {
    border: none;
    outline: none;
    background: transparent;
}

/* Export button styling */
.export-btn {
    background: #6c757d;
    border-color: #6c757d;
    color: white;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.export-btn:hover {
    background: #5a6268;
    border-color: #5a6268;
}

/* ===================================================
   MOBILE OPTIMIZATIONS
   =================================================== */

/* Mobile optimizations for dashboard */
@media (max-width: 576px) {
    .dashboard-header {
        padding: 1rem 0;
        margin-bottom: 1rem;
    }
    
    .dashboard-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .period-selector {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .date-range-picker {
        width: 100%;
    }
    
    .dashboard-container .chart-container {
        height: 200px;
    }
    
    .workflow-stats-table {
        font-size: 0.75rem;
    }
    
    .workflow-stats-table th,
    .workflow-stats-table td {
        padding: 0.5rem 0.25rem;
    }
    
    .dashboard .card-body,
    .dashboard-container .card-body {
        padding: 1rem;
    }
    
    .dashboard-container .stats-widget .card-body {
        padding: 1rem 0.75rem;
    }
}

/* ===================================================
   PRINT STYLES
   =================================================== */

/* Print styles for dashboard */
@media print {
    .dashboard .btn,
    .dashboard .dropdown,
    .period-selector {
        display: none !important;
    }
    
    .dashboard .card {
        break-inside: avoid;
        box-shadow: none !important;
        border: 1px solid #000 !important;
        margin-bottom: 1rem !important;
    }
    
    .dashboard .chart-container {
        height: auto !important;
    }
    
    .dashboard-container .widget-row {
        display: block !important;
    }
    
    .dashboard-container .widget-row .card {
        width: 100% !important;
        margin-bottom: 1rem !important;
    }
}
