:root {
    --background: #09090b;
    --foreground: #fafafa;
    --card: rgba(15, 15, 20, 0.6);
    --card-foreground: #fafafa;
    --popover: rgba(15, 15, 20, 0.95);
    --popover-foreground: #fafafa;
    --primary: #6366f1;
    --primary-foreground: #fafafa;
    --secondary: rgba(39, 39, 42, 0.5);
    --secondary-foreground: #fafafa;
    --muted: rgba(39, 39, 42, 0.4);
    --muted-foreground: #a1a1aa;
    --accent: rgba(99, 102, 241, 0.15);
    --accent-foreground: #fafafa;
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --destructive: #ef4444;
    --destructive-foreground: #fafafa;
    --border: rgba(63, 63, 70, 0.4);
    --input: rgba(39, 39, 42, 0.6);
    --ring: #6366f1;
    --radius: 16px;
    --glass-blur: 20px;
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-highlight: rgba(255, 255, 255, 0.05);
    --liquid-gradient: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.05) 50%, rgba(59, 130, 246, 0.1) 100%);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--background);
    color: var(--foreground);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Animated background */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.bg-animation::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    top: -50%;
    left: -50%;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 60%, rgba(59, 130, 246, 0.08) 0%, transparent 50%);
    animation: liquidMove 20s ease-in-out infinite;
}

@keyframes liquidMove {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(2%, 2%) rotate(1deg); }
    50% { transform: translate(-1%, 3%) rotate(-1deg); }
    75% { transform: translate(3%, -1%) rotate(0.5deg); }
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    animation: orbFloat 15s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: rgba(99, 102, 241, 0.2);
    top: 10%;
    left: 10%;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: rgba(139, 92, 246, 0.15);
    top: 60%;
    right: 10%;
    animation-delay: -5s;
}

.orb-3 {
    width: 250px;
    height: 250px;
    background: rgba(59, 130, 246, 0.15);
    bottom: 20%;
    left: 30%;
    animation-delay: -10s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* Language Switcher */
.lang-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 6px;
    z-index: 1000;
    background: var(--card);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 6px;
}

[dir="rtl"] .lang-switcher {
    right: auto;
    left: 20px;
}

.lang-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    color: var(--foreground);
    background: var(--secondary);
}

.lang-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 40px 20px;
    position: relative;
    z-index: 1;
}

/* Gig.ovh Badge */
.gig-badge {
    display: inline-flex;
    margin-bottom: 16px;
}

.gig-badge a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
    border: 1px solid var(--primary);
    border-radius: 20px;
    color: var(--foreground);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.gig-badge a:hover {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.3) 0%, rgba(139, 92, 246, 0.3) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
}

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

.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #a5b4fc 50%, #818cf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.header p {
    color: var(--muted-foreground);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Glass Card */
.glass-card {
    background: var(--card);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 28px;
    position: relative;
    overflow: visible;
    transition: all 0.3s ease;
}

.glass-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--glass-highlight), transparent);
}

.glass-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--liquid-gradient);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.glass-card:hover::after {
    opacity: 1;
}

/* Settings Panel */
.settings-panel {
    margin-bottom: 30px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-group {
    margin-bottom: 0;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--foreground);
}

.form-label .hint {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    font-weight: 400;
}

.tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: var(--muted);
    border-radius: 50%;
    font-size: 10px;
    color: var(--muted-foreground);
    cursor: help;
    flex-shrink: 0;
}

.tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--popover);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.75rem;
    font-weight: 400;
    white-space: normal;
    width: 250px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 9999;
    line-height: 1.5;
    pointer-events: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--foreground);
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
}

.form-input:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-input::placeholder {
    color: var(--muted-foreground);
}

select.form-input {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23a1a1aa' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    outline: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: var(--primary-foreground);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--secondary);
    color: var(--secondary-foreground);
    border: 1px solid var(--border);
    padding: 10px 20px;
    font-size: 0.85rem;
}

.btn-secondary:hover {
    background: var(--muted);
}

/* Format Toggle */
.format-toggle {
    display: flex;
    gap: 4px;
    background: var(--secondary);
    padding: 4px;
    border-radius: 8px;
    width: fit-content;
}

.format-btn {
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.format-btn:hover {
    color: var(--foreground);
}

.format-btn.active {
    background: var(--primary);
    color: white;
}

/* WireGuard .conf styling */
.output-box.wg-config {
    white-space: pre;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.6;
}

.btn-ghost {
    background: transparent;
    color: var(--muted-foreground);
    padding: 8px 12px;
    font-size: 0.8rem;
}

.btn-ghost:hover {
    background: var(--muted);
    color: var(--foreground);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.7rem;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    height: 100%;
}

.btn-xs:hover {
    background: var(--muted);
    color: var(--foreground);
    border-color: var(--primary);
}

/* MTU Presets */
.mtu-presets {
    display: flex;
    gap: 6px;
}

.mtu-btn {
    flex: 1;
    padding: 8px 4px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    text-align: center;
    background: var(--secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--muted-foreground);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.mtu-btn:hover {
    background: var(--accent);
    border-color: var(--primary);
    color: var(--foreground);
    transform: translateY(-1px);
}

.mtu-btn.active,
.mtu-btn.active:hover {
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%) !important;
    border-color: var(--primary) !important;
    color: white !important;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.4);
    transform: none;
}

.generate-btn-container {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 24px;
}

/* Main Grid */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

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

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title .icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    border-radius: 10px;
    font-size: 18px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-inbound {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.badge-outbound {
    background: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-peer {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.output-box {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
    line-height: 1.7;
    color: #e2e8f0;
    overflow-x: auto;
    white-space: pre;
    max-height: 500px;
    overflow-y: auto;
    position: relative;
}

.output-box::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.output-box::-webkit-scrollbar-track {
    background: transparent;
}

.output-box::-webkit-scrollbar-thumb {
    background: var(--muted);
    border-radius: 4px;
}

/* JSON Syntax Highlighting */
.json-key { color: #7dd3fc; }
.json-string { color: #86efac; }
.json-number { color: #fcd34d; }
.json-boolean { color: #f472b6; }
.json-null { color: #f472b6; }
.json-bracket { color: #c4b5fd; }

.info-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 16px;
}

.info-item {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
}

.info-item-label {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.info-item-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    color: var(--foreground);
    word-break: break-all;
}

.copy-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--secondary);
    border: 1px solid var(--border);
    color: var(--muted-foreground);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    z-index: 10;
}

.copy-btn:hover {
    background: var(--muted);
    color: var(--foreground);
}

.output-wrapper {
    position: relative;
}

.copied-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(var(--glass-blur));
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
}

.copied-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.copied-toast .icon {
    color: #22c55e;
    font-size: 1.2rem;
}

.connection-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
    padding: 16px;
    background: rgba(99, 102, 241, 0.05);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 12px;
}

.connection-line {
    flex: 1;
    height: 2px;
    background: linear-gradient(90deg, var(--success), var(--primary), var(--warning));
    border-radius: 2px;
}

.connection-icon {
    font-size: 1.5rem;
}

.keys-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

.keys-title {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 16px;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.key-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* Peers Section */
.peers-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.peers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.peers-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.peer-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
}

.peer-card:last-child {
    margin-bottom: 0;
}

.peer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.peer-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary);
}

.peer-info {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

.peer-info-item {
    font-size: 0.65rem;
}

.peer-info-label {
    color: var(--muted-foreground);
    margin-bottom: 1px;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.peer-info-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.65rem;
    color: var(--foreground);
    word-break: break-all;
}

.remove-peer-btn {
    background: transparent;
    border: none;
    color: var(--destructive);
    cursor: pointer;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.remove-peer-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* History Section */
.history-section {
    margin-top: 40px;
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 16px 20px;
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.history-header:hover {
    background: rgba(15, 15, 20, 0.8);
}

.history-header h3 {
    font-size: 1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.history-toggle {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.history-toggle.open {
    transform: rotate(180deg);
}

.history-content {
    display: none;
    margin-top: 12px;
}

.history-content.open {
    display: block;
}

.history-item {
    background: var(--card);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.history-item-time {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.history-item-info {
    display: flex;
    gap: 16px;
    font-size: 0.75rem;
}

.history-item-info span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.history-item-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.8rem;
    }
    
    .glass-card {
        padding: 20px;
    }

    .settings-grid {
        grid-template-columns: 1fr 1fr;
    }

    .key-row, .info-row {
        grid-template-columns: 1fr;
    }

    .peer-info {
        grid-template-columns: 1fr;
    }
}

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

/* Footer */
.footer {
    text-align: center;
    padding: 40px 20px;
    margin-top: 40px;
    border-top: 1px solid var(--border);
}

.footer-text {
    color: var(--muted-foreground);
    font-size: 0.9rem;
}

.footer-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.footer-text a:hover {
    color: #818cf8;
    text-decoration: underline;
}

/* RTL Support */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .header {
    text-align: center;
}

[dir="rtl"] .footer {
    text-align: center;
}

[dir="rtl"] .form-label {
    text-align: right;
}

[dir="rtl"] .info-item-label {
    text-align: right;
}

[dir="rtl"] .tooltip::after {
    left: auto;
    right: 50%;
    transform: translateX(50%);
}

[dir="rtl"] .copy-btn {
    right: auto;
    left: 12px;
}

[dir="rtl"] .mtu-presets {
    flex-direction: row-reverse;
}

[dir="rtl"] .generate-btn-container {
    flex-direction: row-reverse;
}