@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Primary Colors */
    --primary: #14B8A6;
    --primary-hover: #0D9488;
    --secondary: #3B82F6;

    /* Dark Theme (Default) */
    --bg-color: #030712;
    --surface-color: #111827;
    --text-primary: #FFFFFF;
    --text-secondary: #9CA3AF;
    --border-color: #1F2937;
    --grid-opacity: rgba(128, 128, 128, 0.07);
    --glow-opacity: rgba(20, 184, 166, 0.15);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.7);
}

/* Light Theme (Selectable) */
[data-theme="light"] {
    --bg-color: #ffffff;
    --surface-color: #F9FAFB;
    --text-primary: #111827;
    --text-secondary: #4B5563;
    --border-color: #E5E7EB;
    --grid-opacity: rgba(0, 0, 0, 0.05);
    --glow-opacity: rgba(20, 184, 166, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Background Grid & Glow */
.background-grid {
    position: fixed;
    inset: 0;
    z-index: -10;
    height: 100%;
    width: 100%;
    background-image:
        linear-gradient(to right, var(--grid-opacity) 1px, transparent 1px),
        linear-gradient(to bottom, var(--grid-opacity) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, #000 70%, transparent 110%);
    -webkit-mask-image: radial-gradient(ellipse 80% 50% at 50% 0%, #000 70%, transparent 110%);
}

.glow {
    position: fixed;
    top: -20%;
    left: 50%;
    transform: translateX(-50%);
    width: 1200px;
    height: 800px;
    border-radius: 100%;
    background: radial-gradient(circle, var(--glow-opacity), rgba(59, 130, 246, 0.05), transparent 70%);
    filter: blur(100px);
    z-index: -11;
}

/* Container */
.app-container {
    width: 100%;
    max-width: 800px;
    padding: 40px 24px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-logo {
    color: var(--primary);
    width: 32px;
    height: 32px;
}

header h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-primary), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Language & Theme Controls */
.controls {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    justify-content: flex-end;
}

.status-badge {
    display: inline-block;
    width: fit-content;
    margin: 0 auto 20px auto;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 9999px;
    background: var(--surface-color);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.toggle-group {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-color);
    padding: 10px 20px;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Switch Styling */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: var(--border-color);
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

.status-badge.online {
    background: rgba(20, 184, 166, 0.1);
    color: var(--primary);
    border-color: rgba(20, 184, 166, 0.2);
}

.btn-icon {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.btn-icon:hover {
    background: var(--surface-color);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Hero Content */
.hero {
    text-align: center;
    margin-bottom: 48px;
}

.hero h2 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.hero p {
    color: var(--text-secondary);
    font-size: 18px;
    max-width: 500px;
    margin: 0 auto;
}

/* Peer Discovery Grid */
.peer-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: rgba(17, 24, 39, 0.2);
    border: 2px dashed var(--border-color);
    border-radius: 24px;
    text-align: center;
}

[data-theme="light"] .empty-state {
    background: rgba(249, 250, 251, 0.5);
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.empty-state p {
    font-weight: 600;
    margin-top: 20px;
    margin-bottom: 8px;
}

.empty-state small {
    color: var(--text-secondary);
}

/* Peer Card */
.peer-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
    aspect-ratio: 1 / 1;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.peer-card:hover {
    transform: translateY(-6px);
    border-color: var(--primary);
    box-shadow: var(--shadow-lg);
    background: var(--surface-color);
}

.peer-icon-wrapper {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 8px 16px -4px rgba(20, 184, 166, 0.3);
}

.peer-name {
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    color: var(--text-primary);
}

/* Footer */
footer {
    padding: 32px 0;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.local-peer {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-color);
    padding: 10px 20px;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.local-peer i {
    color: var(--primary);
}

/* Modals */
.modal-overlay,
.progress-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.8);
    backdrop-filter: blur(8px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.glass-modal {
    background: var(--surface-color);
    border-radius: 24px;
    padding: 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    text-align: center;
}

.glass-modal h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.glass-modal p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 15px;
}

.progress-filename {
    font-weight: 600;
    color: var(--text-primary) !important;
    margin-top: -8px;
    margin-bottom: 20px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.progress-eta {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 8px;
}

.modal-actions {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 14px;
    border-radius: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 15px;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-color);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--surface-color);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
}

/* Progress */
.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: var(--bg-color);
    border-radius: 999px;
    margin-bottom: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.3s ease;
}

.hidden {
    display: none !important;
}

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

/* Language Switcher Button */
.lang-btn {
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--surface-color);
    color: var(--text-secondary);
    cursor: pointer;
}

.lang-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Responsive */
@media (max-width: 640px) {
    .hero h2 {
        font-size: 32px;
    }

    .hero p {
        font-size: 16px;
    }

    .peer-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}