/* EC2 Instances Styles */

/* Card styles */
.instance-card {
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.instance-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Instance Status indicator */
.status-running {
    color: #28a745;
}

.status-pending {
    color: #ffc107;
}

.status-stopped, .status-stopping, .status-terminated, .status-shutting-down {
    color: #6c757d;
}

/* Utilization badges on instance cards */
.instance-stats-banner {
    background-color: #f8f9fa;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
}

.util-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
    color: #495057;
    flex: 1;
    margin: 0 3px;
}

.util-badge i {
    margin-bottom: 3px;
    font-size: 0.85rem;
}

.util-badge.low {
    background-color: rgba(25, 135, 84, 0.08);
    color: #198754;
}

.util-badge.medium {
    background-color: rgba(255, 193, 7, 0.08);
    color: #fd7e14;
}

.util-badge.high {
    background-color: rgba(220, 53, 69, 0.08);
    color: #dc3545;
}

.util-badge .util-value {
    font-family: monospace;
    font-weight: bold;
    font-size: 0.8rem;
}

.util-progress {
    height: 3px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 1.5px;
    position: relative;
    width: 100%;
    margin: 2px 0;
}

.util-progress-bar {
    height: 100%;
    border-radius: 1.5px;
    position: absolute;
    top: 0;
    left: 0;
}

.util-progress-bar.low {
    background-color: #198754;
}

.util-progress-bar.medium {
    background-color: #fd7e14;
}

.util-progress-bar.high {
    background-color: #dc3545;
}

.cpu-util i {
    color: #3b7ddd;
}

.ram-util i {
    color: #6f42c1;
}

.disk-util i {
    color: #fd7e14;
}

/* Instance details panel */
.instance-details-card {
    margin-top: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-top: 0;
}

.metrics-container {
    min-height: 250px;
}

.metrics-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 5;
}

.metrics-unavailable-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
    color: #6c757d;
    text-align: center;
}

/* Responsive styles */
@media (max-width: 992px) {
    .instance-stats-banner {
        padding: 3px 8px;
    }
    
    .util-badge {
        padding: 1px 4px;
        font-size: 0.7rem;
    }
}

@media (max-width: 576px) {
    .instance-stats-banner {
        padding: 2px 6px;
    }
    
    .util-badge {
        padding: 1px 3px;
        font-size: 0.65rem;
    }
}

/* Search styling */
#ec2-search-results {
    font-size: 0.875rem;
    padding: 0.25rem 0.5rem;
    color: #6c757d;
}

/* Instance ID styles */
.instance-card code {
    word-break: break-all;
    background-color: #f8f9fa;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.85em;
    color: #e83e8c;
}

/* Display a checkmark on unique instances */
.instance-card.unique::after {
    content: "✓";
    position: absolute;
    top: 5px;
    right: 5px;
    color: green;
    font-size: 12px;
}

/* Status text styling */
.status-running {
    color: #10b981;
    font-weight: 500;
}

.status-stopped {
    color: #f59e0b;
    font-weight: 500;
}

.status-pending {
    color: #f59e0b;
    font-weight: 500;
}

.status-terminated {
    color: #ef4444;
    font-weight: 500;
}

/* Instance Card Styling */
.instance-card {
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.instance-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.instance-card .card-header {
    padding: 0.75rem 1rem;
}

.instance-card .card-body {
    flex: 1; /* Make card body expand to fill available space */
    display: flex;
    flex-direction: column;
}

.instance-card .card-footer {
    background-color: transparent;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    padding: 0.75rem 1rem;
    margin-top: auto; /* Push footer to bottom of card */
}

.instance-card code {
    font-size: 0.85rem;
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
}

.border-success {
    border-left: 4px solid #10b981 !important;
}

.border-warning {
    border-left: 4px solid #f59e0b !important;
}

.border-danger {
    border-left: 4px solid #ef4444 !important;
}

/* Details Panel Styling */
.instance-details-card {
    border: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    animation: slideDown 0.3s ease-out;
}

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

.close-details-btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* Improved metrics container with static display */
.metrics-section {
    background-color: #f8f9fa;
    border-radius: 4px;
    padding: 10px;
    margin-top: 15px;
    border: 1px solid #e9ecef;
}

/* Compact resource usage bars */
.resource-usage-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.resource-label {
    min-width: 60px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #6c757d;
}

.resource-value {
    min-width: 45px;
    text-align: right;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: monospace;
}

.progress {
    flex-grow: 1;
    margin: 0;
    border-radius: 2px;
}

/* Health status badges */
.instance-health-badge {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 500;
}

.health-good {
    background-color: rgba(25, 135, 84, 0.1);
    color: #198754;
}

.health-warning {
    background-color: rgba(255, 193, 7, 0.1);
    color: #ffc107;
}

.health-critical {
    background-color: rgba(220, 53, 69, 0.1);
    color: #dc3545;
}

.health-unknown {
    background-color: rgba(108, 117, 125, 0.1);
    color: #6c757d;
}

/* Last updated timestamp */
.metrics-last-updated {
    font-size: 0.75rem;
    color: #6c757d;
    text-align: right;
    margin-top: 8px;
}

/* Modal resource summary */
.modal-resource-summary {
    padding: 5px 0;
}

.modal-resource-item {
    margin-bottom: 15px;
}

.modal-resource-value {
    font-weight: 600;
    font-family: monospace;
    font-size: 1rem;
}

/* Performance stats */
.performance-stat {
    background-color: #f8f9fa;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.performance-stat:hover {
    background-color: #eaecef;
}

.performance-stat .h5 {
    font-weight: 600;
    color: #333;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .resource-usage-bar {
        gap: 4px;
    }
    
    .resource-label {
        min-width: 40px;
        font-size: 0.7rem;
    }
    
    .resource-value {
        min-width: 35px;
        font-size: 0.7rem;
    }
    
    .metrics-section {
        padding: 8px;
    }
}

/* Responsive sizing for metrics containers */
@media (max-width: 1400px) {
    .metrics-container {
        min-height: 160px;
    }
}

@media (max-width: 992px) {
    .metrics-container {
        min-height: 140px;
    }
}

@media (max-width: 768px) {
    .metrics-container {
        min-height: 120px;
    }
}

/* Responsive chart sizing */
@media (max-width: 768px) {
    .chart-container {
        padding-bottom: 66.67%; /* 3:2 aspect ratio for smaller screens */
    }
}

/* Improved tooltip for chart to prevent UI expansion */
.chartjs-tooltip {
    max-width: 200px;
    white-space: normal;
    word-wrap: break-word;
}

/* Improved tab navigation for instances */
#instances-tabs {
    border-bottom: 1px solid #dee2e6;
}

#instances-tabs .nav-link {
    margin-right: 4px;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6c757d;
}

#instances-tabs .nav-link.active {
    color: #3b7ddd;
    border-bottom-color: #3b7ddd;
    background-color: transparent;
}

#instances-tabs .nav-link:hover:not(.active) {
    border-bottom-color: #dee2e6;
}

/* Responsive layout for instance cards */
@media (max-width: 767.98px) {
    .col-md-6.col-lg-4.mb-3 {
        padding-left: 8px;
        padding-right: 8px;
    }
    
    .instance-card .card-body {
        padding: 1rem;
    }
    
    .metrics-preview {
        padding: 0.5rem !important;
    }
    
    #ec2-search-input {
        font-size: 0.9rem;
    }
}

/* Better search experience */
#ec2-search-results {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
    background-color: #f8f9fa;
    border-radius: 4px;
}
