/* Game Server Instances Page Styles */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem 0;
    border-bottom: 2px solid #e0e0e0;
}

.header-content h1 {
    margin: 0;
    color: #2c3e50;
    font-size: 2rem;
    font-weight: 700;
}

.header-content p {
    margin: 0.5rem 0 0 0;
    color: #666;
    font-size: 1.1rem;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.auto-refresh-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #e8f5e8;
    border: 1px solid #4caf50;
    border-radius: 6px;
    color: #2e7d32;
    font-size: 0.9rem;
    font-weight: 500;
    animation: pulse 2s infinite;
}

.refresh-icon {
    animation: spin 2s linear infinite;
}

.btn-icon-small {
    background: none;
    border: none;
    font-size: 1rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 3px;
    transition: background-color 0.2s;
}

.btn-icon-small:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

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

.stat-icon {
    font-size: 2.5rem;
    opacity: 0.8;
}

.stat-content {
    flex: 1;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #2c3e50;
    line-height: 1;
}

.stat-label {
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Instances Section */
.instances-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e0e0e0;
}

.section-header h2 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
}

.section-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.filter-select {
    padding: 0.5rem 1rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.filter-select:focus {
    outline: none;
    border-color: #3498db;
}

/* Instances Grid */
.instances-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.instance-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid #e0e0e0;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

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

.instance-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.instance-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.instance-status {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.instance-status.running {
    background: #d4edda;
    color: #155724;
}

.instance-status.stopped {
    background: #f8d7da;
    color: #721c24;
}

.instance-status.error {
    background: #f5c6cb;
    color: #721c24;
}

.instance-status.starting {
    background: #fff3cd;
    color: #856404;
}

.instance-status.stopping {
    background: #d1ecf1;
    color: #0c5460;
}

.instance-info {
    margin-bottom: 1rem;
}

.instance-info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.instance-info-label {
    color: #666;
    font-weight: 500;
}

.instance-info-value {
    color: #2c3e50;
    font-weight: 600;
}

.instance-description {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.instance-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.instance-action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.instance-action-btn.primary {
    background: #3498db;
    color: white;
}

.instance-action-btn.primary:hover {
    background: #2980b9;
}

.instance-action-btn.secondary {
    background: #95a5a6;
    color: white;
}

.instance-action-btn.secondary:hover {
    background: #7f8c8d;
}

.instance-action-btn.danger {
    background: #e74c3c;
    color: white;
}

.instance-action-btn.danger:hover {
    background: #c0392b;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: #666;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.5rem;
}

.empty-state p {
    margin: 0 0 2rem 0;
    font-size: 1.1rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
    font-size: 1.5rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.modal-close:hover {
    background-color: #f0f0f0;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    border-top: 1px solid #e0e0e0;
    background-color: #f8f9fa;
    border-radius: 0 0 12px 12px;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2c3e50;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: #666;
}

.port-input-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.port-input-group input {
    flex: 1;
}

.port-input-group button {
    white-space: nowrap;
}

.port-status {
    margin-top: 0.25rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.port-status.available {
    color: #27ae60;
}

.port-status.unavailable {
    color: #e74c3c;
}

/* Action Buttons */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}

.action-btn {
    padding: 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    text-decoration: none;
}

.action-btn.primary {
    background: #3498db;
    color: white;
}

.action-btn.primary:hover {
    background: #2980b9;
}

.action-btn.secondary {
    background: #95a5a6;
    color: white;
}

.action-btn.secondary:hover {
    background: #7f8c8d;
}

.action-btn.danger {
    background: #e74c3c;
    color: white;
}

.action-btn.danger:hover {
    background: #c0392b;
}

.action-icon {
    font-size: 1.1rem;
}

/* Instance Info in Modal */
.instance-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.instance-info h4 {
    margin: 0 0 0.5rem 0;
    color: #2c3e50;
    font-size: 1.1rem;
}

.instance-info p {
    margin: 0.25rem 0;
    color: #666;
    font-size: 0.9rem;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    color: white;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Fix modal overlay issue - use visibility instead of opacity to prevent z-index stacking issues */
/* Modal without fade class to avoid Bootstrap's .fade:not(.show) opacity: 0 rule */
html body #shareInstanceModal.modal:not(.show),
body #shareInstanceModal.modal:not(.show),
div#shareInstanceModal.modal:not(.show) {
    opacity: 1 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: none !important;
    -webkit-transition: none !important;
    -moz-transition: none !important;
    -o-transition: none !important;
}

html body #shareInstanceModal.modal.show,
body #shareInstanceModal.modal.show,
div#shareInstanceModal.modal.show {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 1055 !important;
}

/* Ensure modal content is above backdrop */
html body #shareInstanceModal.modal.show .modal-dialog,
body #shareInstanceModal.modal.show .modal-dialog,
div#shareInstanceModal.modal.show .modal-dialog {
    z-index: 1056 !important;
    position: relative;
}

/* Modal backdrop fix - also use visibility and ensure it's below modal content */
.modal-backdrop:not(.show) {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.modal-backdrop.show {
    opacity: 0.5 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: 1040 !important;
}

/* Instance name mobile styling */
.instance-name-mobile {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.instance-name-mobile .small {
    font-size: 0.75rem;
    line-height: 1.4;
}

.instance-name-mobile .small i {
    font-size: 0.7rem;
    margin-right: 0.25rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }
    
    .instances-grid {
        grid-template-columns: 1fr;
    }
    
    .section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
    
    .port-input-group {
        flex-direction: column;
    }
    
    .port-input-group input {
        margin-bottom: 0.5rem;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    /* Compact table on mobile */
    #instancesTable {
        font-size: 0.9rem;
    }
    
    #instancesTable th,
    #instancesTable td {
        padding: 0.5rem 0.25rem;
        vertical-align: middle;
    }
    
    #instancesTable .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    #instancesTable .badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}
