/* Design System & Visual Aesthetics */
:root {
    --bg-app: #060913;
    --bg-card: rgba(13, 20, 38, 0.6);
    --bg-card-hover: rgba(22, 33, 62, 0.85);
    --border-card: rgba(255, 255, 255, 0.06);
    --border-card-hover: rgba(99, 102, 241, 0.4);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-primary-glow: rgba(99, 102, 241, 0.15);
    
    --color-success: #10b981;
    --color-success-glow: rgba(16, 185, 129, 0.25);
    
    --color-warning: #f59e0b;
    --color-warning-glow: rgba(245, 158, 11, 0.25);
    
    --color-danger: #f43f5e;
    --color-danger-glow: rgba(244, 63, 94, 0.25);
    
    --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --shadow-md: 0 4px 20px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px 2px rgba(99, 102, 241, 0.2);
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
}

/* Reset & Scrollbar */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-app);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    line-height: 1.5;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #090e1a;
}
::-webkit-scrollbar-thumb {
    background: #1e293b;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-heading);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn i {
    width: 1rem;
    height: 1rem;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Login Screen Styles */
.login-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--bg-app);
    background-image: 
        radial-gradient(circle at 50% 30%, rgba(99, 102, 241, 0.1) 0%, transparent 60%);
    z-index: 200;
}

.login-card {
    background: rgba(13, 20, 38, 0.7);
    border: 1px solid var(--border-card);
    padding: 2.5rem;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(16px);
    animation: fadeIn 0.4s ease-out;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-brand-icon {
    width: 3.5rem;
    height: 3.5rem;
    color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(99, 102, 241, 0.2);
    margin-bottom: 1rem;
    display: inline-block;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.15);
}

.login-header h2 {
    font-family: var(--font-heading);
    font-size: 1.75rem;
    font-weight: 750;
    margin-bottom: 0.25rem;
    letter-spacing: -0.03em;
}

.login-header span {
    font-size: 0.825rem;
    color: var(--text-secondary);
}

/* App Container & Header */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 2rem;
}

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

.brand-icon {
    width: 2.75rem;
    height: 2.75rem;
    color: var(--color-primary);
    background: rgba(99, 102, 241, 0.1);
    padding: 0.5rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text span {
    font-size: 0.775rem;
    color: var(--text-secondary);
    display: block;
    margin-top: -2px;
}

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

.header-stats {
    display: flex;
    gap: 0.75rem;
}

.stat-pill {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    padding: 0.5rem 0.85rem;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-weight: 700;
    font-family: var(--font-heading);
}

.stat-label {
    color: var(--text-secondary);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.green {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
}

.dot.red {
    background-color: var(--color-danger);
    box-shadow: 0 0 8px var(--color-danger);
}

.pulsing {
    animation: pulse 1.8s infinite alternate;
}

@keyframes pulse {
    0% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    100% {
        transform: scale(1.1);
        box-shadow: 0 0 10px 4px rgba(16, 185, 129, 0);
    }
}

.system-time {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.825rem;
    font-family: monospace;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.5rem 0.85rem;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.03);
}

/* Content & Section Headers */
.dashboard-content {
    animation: fadeIn 0.5s ease-out;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.section-header h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 600;
}

.refresh-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.3s;
}

.refresh-indicator i {
    width: 0.9rem;
    height: 0.9rem;
}

.spin {
    animation: spin 2s linear infinite;
}

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

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

/* Grid & Cards */
.hosts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.host-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(12px);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.host-card:hover {
    transform: translateY(-4px);
    background: var(--bg-card-hover);
    border-color: var(--border-card-hover);
    box-shadow: var(--shadow-lg), 0 4px 20px rgba(99, 102, 241, 0.1);
}

.host-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--color-danger);
    opacity: 0.7;
    transition: background 0.3s;
}

.host-card.is-up::before {
    background: var(--color-success);
}

/* Card Actions / Edit & Delete Buttons */
.card-delete-btn,
.card-edit-btn {
    position: absolute;
    top: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    transform: scale(0.9);
}

.card-delete-btn {
    right: 1rem;
    color: var(--color-danger);
    background: rgba(244, 63, 94, 0.08);
    border-color: rgba(244, 63, 94, 0.15);
}

.card-edit-btn {
    right: 3.25rem;
    color: var(--color-warning);
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.15);
}

.card-copy-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    color: var(--color-primary);
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.15);
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0;
    transform: scale(0.9);
}

.host-card:hover .card-delete-btn,
.host-card:hover .card-edit-btn,
.host-card:hover .card-copy-btn {
    opacity: 1;
    transform: scale(1);
}

.card-delete-btn:hover {
    background: var(--color-danger);
    color: #fff;
    box-shadow: 0 0 10px rgba(244, 63, 94, 0.3);
}

.card-edit-btn:hover {
    background: var(--color-warning);
    color: #fff;
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.card-copy-btn:hover {
    background: var(--color-primary);
    color: #fff;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.25rem;
    padding-right: 4.25rem; /* Space for both action buttons */
}

.host-info h3 {
    font-family: var(--font-heading);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.host-address {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: monospace;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

.status-badge {
    padding: 0.25rem 0.6rem;
    border-radius: 30px;
    font-size: 0.725rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.status-badge.up {
    background: var(--color-success-glow);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-badge.down {
    background: var(--color-danger-glow);
    color: var(--color-danger);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Host Metrics */
.card-metrics {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.metric-label {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.metric-label i {
    width: 0.95rem;
    height: 0.95rem;
    color: var(--text-muted);
}

.metric-value {
    font-weight: 600;
    font-family: monospace;
}

/* SSH Resource bars */
.ssh-resources {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.resource-bar-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.resource-bar-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
}

.resource-bar-label {
    color: var(--text-secondary);
}

.resource-bar-value {
    font-weight: 600;
}

.progress-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 10px;
    transition: width 0.4s ease-out;
}

.progress-fill.success { background: var(--color-success); }
.progress-fill.warning { background: var(--color-warning); }
.progress-fill.danger { background: var(--color-danger); }

/* Error banner */
.error-banner {
    background: var(--color-danger-glow);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: #fda4af;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.775rem;
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.error-banner i {
    flex-shrink: 0;
    width: 0.95rem;
    height: 0.95rem;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(4, 6, 12, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #0d1222;
    border: 1px solid rgba(255, 255, 255, 0.08);
    width: 90%;
    max-width: 850px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    overflow: hidden;
}

.modal-content.fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    transform: none !important;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title-wrapper h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.modal-title-wrapper span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.modal-host-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-host-meta span {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.badge {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-family: monospace;
    text-transform: uppercase;
    font-size: 0.7rem;
    color: var(--color-primary) !important;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.close-btn {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    width: 2rem;
    height: 2rem;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .modal-grid {
        grid-template-columns: 1fr;
    }
}

.modal-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.modal-card h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 0.5rem;
}

.system-info-card .metrics-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chart-container {
    position: relative;
    width: 100%;
    height: 220px;
}

/* Forms styling inside modals */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-bottom: 1.15rem;
}

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.875rem;
    transition: all 0.2s ease;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    background: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-footer {
    padding: 1.25rem 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: flex-end;
    gap: 0.85rem;
    background: rgba(0, 0, 0, 0.15);
}

/* User tables inside Users list modal */
#users-table {
    color: var(--text-primary);
}

#users-table th,
#users-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

#users-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

#mfa-status-banner {
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.15);
    color: #fda4af;
}

#mfa-status-banner.enabled {
    background: var(--color-success-glow);
    border-color: rgba(16, 185, 129, 0.2);
    color: var(--color-success);
}

.filter-tab {
    background: none;
    border: none;
    padding: 0.45rem 0.9rem;
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-tab.active {
    background: var(--color-primary) !important;
    color: var(--text-primary) !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
}

.filter-tab:hover:not(.active) {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.badge-ssh {
    color: #60a5fa !important;
    border-color: rgba(96, 165, 250, 0.2) !important;
    background: rgba(96, 165, 250, 0.05) !important;
}

.badge-ping {
    color: #34d399 !important;
    border-color: rgba(52, 211, 153, 0.2) !important;
    background: rgba(52, 211, 153, 0.05) !important;
}

.badge-hls {
    color: #f59e0b !important;
    border-color: rgba(245, 158, 11, 0.2) !important;
    background: rgba(245, 158, 11, 0.05) !important;
}

.badge-rtmp {
    color: #ec4899 !important;
    border-color: rgba(236, 72, 153, 0.2) !important;
    background: rgba(236, 72, 153, 0.05) !important;
}
