:root {
    /* SaaS Premium Palette */
    --bg-color: #0f172a; /* Slate 900 */
    --card-bg: #1e293b; /* Slate 800 */
    --primary: #38bdf8; /* Sky 400 */
    --primary-hover: #0ea5e9; /* Sky 500 */
    --secondary: #64748b; /* Slate 500 */
    --accent: #8b5cf6; /* Violet 500 */
    --text-main: #f8fafc; /* Slate 50 */
    --text-muted: #94a3b8; /* Slate 400 */
    --success: #10b981; /* Emerald 500 */
    --danger: #ef4444; /* Red 500 */
    --border: rgba(255, 255, 255, 0.08);
    
    /* Typography & Spacing */
    --font-main: 'Inter', -apple-system, sans-serif;
    --font-tech: 'Orbitron', sans-serif;
    --radius: 16px;
    --shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
}

body {
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text-main);
    font-family: var(--font-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

/* --- Navigation --- */
nav {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: var(--font-tech);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- Main Layout --- */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
}

.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 2.5rem;
    width: 100%;
    max-width: 1200px;
    justify-items: center;
}

/* --- Server Card (Premium SaaS Style) --- */
.server-card {
    background: var(--card-bg);
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, border-color 0.3s ease;
    position: relative;
    overflow: hidden;
}

.server-card:hover {
    transform: translateY(-8px);
    border-color: rgba(56, 189, 248, 0.3);
}

.flag-container {
    width: 72px;
    height: 72px;
    margin: 0 auto 1.5rem;
    border-radius: 20px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.server-flag {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 16px;
}

.server-name {
    font-size: 1.75rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 0.5rem;
    color: #fff;
}

/* Status Badge */
.status-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 12px var(--success);
}

.dot.offline {
    background: var(--danger);
    box-shadow: 0 0 12px var(--danger);
}

.server-status-text {
    color: var(--success);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.server-status-text.offline {
    color: var(--danger);
}

/* Chips/Badges for Ports & Protocols */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.info-item h4 {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 0.75rem;
}

.badge {
    display: inline-block;
    background: rgba(56, 189, 248, 0.08);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid rgba(56, 189, 248, 0.15);
    margin: 2px;
}

/* --- Buttons --- */
.btn-primary {
    width: 100%;
    padding: 1.125rem;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(56, 189, 248, 0.3);
}

.btn-primary:disabled {
    background: #1e293b;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    filter: grayscale(1);
    opacity: 0.6;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(56, 189, 248, 0.4);
    filter: brightness(1.1);
}

.btn-secondary {
    width: 100%;
    margin-top: 1rem;
    padding: 1rem;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.03);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

/* --- Footer --- */
footer {
    padding: 3rem 2rem;
    text-align: center;
    border-top: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.5);
}

footer p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--primary);
}

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

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
    background: rgba(56, 189, 248, 0.2);
    border-radius: 10px;
    transition: all 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* --- Form Inputs (Dark Theme) --- */
.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    letter-spacing: 1px;
}

.form-input {
    width: 100%;
    background: #1e1e1e !important;
    color: #ffffff !important;
    border: 1px solid #333 !important;
    border-radius: 12px;
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
}

.form-input::placeholder {
    color: #888;
}

.form-input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.1);
}

textarea.form-input {
    min-height: 100px;
}

/* --- Modals & Toasts --- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-height: 90vh;
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalScale 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.modal-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

@keyframes modalScale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.credential-modal {
    background: var(--card-bg);
    width: 100%;
    max-width: 440px;
    border-radius: 24px;
    padding: 2.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
}

.copy-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 0.875rem 1.25rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 1.25rem;
}

.copy-box span {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    color: var(--primary);
}

.copy-box button {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.copy-box button:hover {
    color: #fff;
}

/* --- Toast Notifications (Fixed) --- */
#toast-container {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    min-width: 300px;
    max-width: 450px;
    background: var(--card-bg);
    color: #fff;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
    animation: toastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: currentColor;
    width: 100%;
    opacity: 0.3;
    animation: toastProgress 5s linear forwards;
}

.toast.success { border-left: 4px solid var(--success); color: var(--success); }
.toast.error { border-left: 4px solid var(--danger); color: var(--danger); }
.toast.info { border-left: 4px solid var(--primary); color: var(--primary); }

.toast-message {
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 500;
}

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

@keyframes toastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

.toast.fade-out {
    opacity: 0;
    transform: scale(0.9);
}

@media (max-width: 480px) {
    #toast-container {
        top: 1rem;
        right: 1rem;
        left: 1rem;
    }
    .toast {
        min-width: auto;
        width: 100%;
    }
}
