/* ============================================
   ShareDrop - Premium Design System
   ============================================ */

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

:root {
    /* Primary Colors */
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --primary-light: #60a5fa;
    --primary-subtle: rgba(59, 130, 246, 0.1);
    --primary-glow: rgba(59, 130, 246, 0.4);

    /* Accent Colors */
    --accent: #8b5cf6;
    --accent-light: #a78bfa;
    --success: #10b981;
    --success-light: #34d399;
    --danger: #ef4444;
    --warning: #f59e0b;

    /* Neutral Colors - Light Mode */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --text-muted: #cbd5e1;

    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-elevated: #ffffff;

    --border: rgba(15, 23, 42, 0.08);
    --border-strong: rgba(15, 23, 42, 0.12);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.1), 0 8px 16px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 40px var(--primary-glow);

    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.2);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dark Mode */
body.dark-mode {
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-muted: #475569;

    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-tertiary: #1e293b;
    --bg-elevated: #1e293b;

    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.1);

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6), 0 8px 16px rgba(0, 0, 0, 0.4);

    --glass-bg: rgba(17, 24, 39, 0.8);
    --glass-border: rgba(255, 255, 255, 0.08);
}

html {
    scroll-behavior: smooth;
}

body {
    /* System Font Stack - DSGVO compliant, no external requests */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif, 
                 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   App Container & Ambient Background
   ============================================ */

.app-container {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.ambient-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.ambient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.5;
    animation: float-ambient 20s ease-in-out infinite;
}

.orb-1 {
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    top: -200px;
    right: -100px;
    opacity: 0.15;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary-light) 100%);
    bottom: -100px;
    left: -100px;
    opacity: 0.1;
    animation-delay: -7s;
}

.orb-3 {
    width: 300px;
    height: 300px;
    background: var(--primary);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.05;
    animation-delay: -14s;
}

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

body.dark-mode .orb-1 { opacity: 0.08; }
body.dark-mode .orb-2 { opacity: 0.06; }
body.dark-mode .orb-3 { opacity: 0.04; }

/* ============================================
   Main Layout
   ============================================ */

.main-wrapper {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 100vh;
    gap: 24px;
    padding: 24px;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    width: 340px;
    flex-shrink: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

body.dark-mode .sidebar {
    background: rgba(17, 24, 39, 0.6);
    border-color: var(--border-strong);
}

.sidebar-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}

/* Device Card */
.device-card {
    position: relative;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-lg);
    padding: 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 16px;
    overflow: hidden;
}

.device-card-glow {
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.2) 0%, transparent 70%);
    pointer-events: none;
}

.device-avatar {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.device-avatar i, .device-avatar svg {
    width: 28px;
    height: 28px;
    color: white;
    stroke-width: 2;
}

.device-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.device-label {
    font-size: 0.75rem;
    font-weight: 500;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.device-name {
    font-size: 1.125rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* QR Section */
.qr-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
}

body.dark-mode .qr-section {
    background: var(--bg-tertiary);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.section-icon {
    width: 20px;
    height: 20px;
    color: var(--primary);
}

.section-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.code-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--primary);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-bottom: 16px;
}

body.dark-mode .code-display {
    background: var(--bg-secondary);
}

.connection-code-text {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 6px;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
}

.connection-code-text:hover {
    background: var(--primary-subtle);
    transform: scale(1.02);
}

.connection-code-text:active {
    transform: scale(0.98);
    background: var(--primary-subtle);
}

.copy-code-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-code-btn:hover {
    color: var(--primary);
    background: var(--primary-subtle);
}

.copy-code-btn i, .copy-code-btn svg {
    width: 18px;
    height: 18px;
}

.qr-code-container {
    display: flex;
    justify-content: center;
    padding: 16px;
    background: white;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
}

body.dark-mode .qr-code-container {
    background: rgba(255, 255, 255, 0.95);
}

.qr-code-container canvas,
.qr-code-container img {
    border-radius: var(--radius-sm);
}

.qr-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-align: center;
}

/* Privacy Info */
.privacy-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

body.dark-mode .privacy-info {
    background: var(--bg-secondary);
}

.privacy-icon-wrapper {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.privacy-icon-wrapper .lock-icon {
    width: 20px;
    height: 20px;
    color: white;
}

.privacy-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.privacy-text strong {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.privacy-text span {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Footer Credit */
.footer-credit {
    margin-top: auto;
    text-align: center;
    padding-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.75rem;
}

.footer-separator {
    color: var(--text-muted);
    user-select: none;
}

.footer-credit a {
    color: var(--text-tertiary);
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

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

/* ============================================
   Main Content
   ============================================ */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

body.dark-mode .main-content {
    background: rgba(17, 24, 39, 0.6);
    border-color: var(--border-strong);
}

/* Header */
header {
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

body.dark-mode header {
    background: var(--bg-tertiary);
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-wrapper {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: var(--transition-base);
}

.logo:hover {
    transform: scale(1.05);
}

.header-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Theme Toggle */
.theme-toggle {
    width: 44px;
    height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-base);
    color: var(--text-primary);
}

.theme-toggle:hover {
    background: var(--primary-subtle);
    border-color: var(--primary);
    color: var(--primary);
    transform: scale(1.05);
}

.theme-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-icon i, .theme-icon svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   Content Container
   ============================================ */

.content-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Mobile Device Info */
.mobile-device-info {
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin: 16px 16px 0;
}

body.dark-mode .mobile-device-info {
    background: var(--bg-tertiary);
}

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

.mobile-device-emoji {
    width: 44px;
    height: 44px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-device-emoji i, .mobile-device-emoji svg {
    width: 22px;
    height: 22px;
    color: white;
}

.mobile-device-details {
    flex: 1;
    min-width: 0;
}

.mobile-device-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-code-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mobile-connection-code {
    font-family: 'SF Mono', monospace;
    font-size: 0.875rem;
    color: var(--primary);
    font-weight: 600;
    letter-spacing: 2px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(59, 130, 246, 0.2);
}

.mobile-connection-code:hover {
    background: var(--primary-subtle);
}

.mobile-connection-code:active {
    transform: scale(0.98);
    background: var(--primary-subtle);
}

.mobile-copy-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-copy-btn:hover {
    color: var(--primary);
    background: var(--primary-subtle);
}

.mobile-copy-btn:active {
    transform: scale(0.9);
}

.mobile-copy-btn i, .mobile-copy-btn svg {
    width: 16px;
    height: 16px;
}

.qr-toggle-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.qr-toggle-btn:hover {
    background: var(--primary-subtle);
    border-color: var(--primary);
    color: var(--primary);
}

.qr-toggle-btn.active {
    background: var(--primary-subtle);
    border-color: var(--primary);
    color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.qr-toggle-btn i, .qr-toggle-btn svg {
    width: 20px;
    height: 20px;
}

.mobile-qr-code {
    display: flex;
    justify-content: center;
    padding: 16px 0 0;
    margin-top: 16px;
    border-top: 1px solid var(--border);
    transition: var(--transition-slow);
}

.mobile-qr-code.hidden {
    display: none;
}

.mobile-qr-code canvas {
    border-radius: var(--radius-sm);
    background: white !important;
    padding: 8px;
}

/* ============================================
   Tabs
   ============================================ */

.tabs {
    display: flex;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

body.dark-mode .tabs {
    background: var(--bg-tertiary);
}

.tab {
    flex: 1;
    padding: 16px 20px;
    background: transparent;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
}

.tab::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 3px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    transition: var(--transition-base);
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active {
    color: var(--primary);
}

.tab.active::after {
    width: calc(100% - 40px);
}

.tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tab-icon i, .tab-icon svg {
    width: 18px;
    height: 18px;
}

/* Tab Content */
.tab-content {
    display: none;
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ============================================
   Peer List
   ============================================ */

.peer-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.no-peers {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.searching-animation {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 24px;
}

.radar-ring {
    position: absolute;
    inset: 0;
    border: 2px solid var(--primary);
    border-radius: 50%;
    opacity: 0;
    animation: radar-pulse 3s ease-out infinite;
}

.radar-ring.delay-1 { animation-delay: 1s; }
.radar-ring.delay-2 { animation-delay: 2s; }

@keyframes radar-pulse {
    0% {
        transform: scale(0.3);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.radar-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.no-peers h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.no-peers p {
    font-size: 0.875rem;
    color: var(--text-tertiary);
    max-width: 300px;
}

/* Peer Card */
.peer-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px 20px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-base);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.peer-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--primary-subtle) 0%, transparent 100%);
    opacity: 0;
    transition: var(--transition-base);
}

.peer-card:hover {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.peer-card:hover::before {
    opacity: 1;
}

.peer-card:active {
    transform: translateY(-2px);
}

body.dark-mode .peer-card {
    background: var(--bg-tertiary);
}

body.dark-mode .peer-card:hover {
    background: var(--bg-elevated);
}

.peer-icon {
    position: relative;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    transition: var(--transition-spring);
}

.peer-icon i, .peer-icon svg {
    width: 28px;
    height: 28px;
    color: white;
    stroke-width: 2;
}

.peer-card:hover .peer-icon {
    transform: scale(1.1) rotate(3deg);
}

.peer-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.peer-type {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Code Input Section
   ============================================ */

.code-input-section {
    max-width: 480px;
    margin: 0 auto;
    width: 100%;
}

.code-input-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.code-header-icon {
    width: 28px;
    height: 28px;
    color: var(--primary);
}

.code-input-section h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.code-input-section > p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 0.95rem;
}

.code-input-wrapper {
    position: relative;
    margin-bottom: 20px;
}

.code-input-field {
    width: 100%;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    text-align: center;
    padding: 20px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    color: var(--text-primary);
    letter-spacing: 12px;
    transition: var(--transition-base);
}

.code-input-field::placeholder {
    color: var(--text-muted);
    letter-spacing: 12px;
}

.code-input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-subtle);
}

body.dark-mode .code-input-field {
    background: var(--bg-tertiary);
}

.error-message {
    margin-top: 16px;
    font-size: 0.875rem;
    min-height: 24px;
    text-align: center;
    font-weight: 500;
}

/* ============================================
   Buttons
   ============================================ */

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-base);
    border: none;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md), 0 0 0 0 var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 20px var(--primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

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

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

.btn-connect {
    width: 100%;
    padding: 16px;
    font-size: 1rem;
}

/* ============================================
   Modals
   ============================================ */

.modal,
dialog.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100%;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    border: none;
    background: transparent;
    margin: 0 auto;
}

@media (max-width: 768px) {
    .modal.active,
    dialog.modal[open] {
        display: flex !important; /* Force flex when open on mobile */
        align-items: center !important;
        justify-content: center !important;
        padding: 12px;
    }
    
    .modal-content {
        width: calc(100% - 24px);
        max-width: 500px;
        margin: 0;
        max-height: 85vh;
        overflow-y: auto;
        position: relative;
    }
}

.modal.active,
dialog.modal[open] {
    display: flex;
}

body.modal-open {
    overflow: hidden;
}

dialog.modal::backdrop {
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: pointer;
    z-index: 0;
}

.modal-content {
    position: relative;
    z-index: 2;
    background: var(--bg-secondary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    width: 100%;
    max-width: 520px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.dark-mode .modal-content {
    background: var(--bg-tertiary);
    border-color: var(--border-strong);
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Upload Modal */
.upload-modal-content {
    padding: 0;
    max-width: 560px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.connected-peer-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.connected-peer-icon i, .connected-peer-icon svg {
    width: 24px;
    height: 24px;
    color: white;
}

.connected-peer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.connected-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

.connected-peer-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-close {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.modal-close i, .modal-close svg {
    width: 20px;
    height: 20px;
}

/* Upload Area */
.upload-area {
    margin: 24px;
    border: 2px dashed var(--border-strong);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition-base);
    position: relative;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary);
    background: var(--primary-subtle);
}

.upload-area.drag-over {
    border-style: solid;
    transform: scale(1.02);
}

.file-input-hidden {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.upload-area-content {
    pointer-events: none;
}

.upload-icon-wrapper {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: var(--primary-subtle);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-icon {
    width: 40px;
    height: 40px;
    color: var(--primary);
}

.upload-area h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.upload-area p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.upload-types {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
}

.upload-type {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.upload-type i, .upload-type svg {
    width: 14px;
    height: 14px;
}

body.dark-mode .upload-type {
    background: var(--bg-secondary);
}

.upload-actions {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

body.dark-mode .upload-actions {
    background: var(--bg-secondary);
}

.upload-actions .btn-primary,
.upload-actions .btn-secondary {
    flex: 1;
}

/* Transfer Modal */
.transfer-modal-content {
    padding: 32px;
    text-align: center;
}

.transfer-header {
    margin-bottom: 24px;
}

.transfer-icon-wrapper {
    width: 72px;
    height: 72px;
    margin: 0 auto 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse-glow 2s ease-in-out infinite;
}

.transfer-icon-wrapper.receiving {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
}

.transfer-icon-wrapper.complete {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
    animation: none;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 var(--primary-glow); }
    50% { box-shadow: 0 0 30px 10px var(--primary-glow); }
}

.transfer-direction-icon {
    width: 32px;
    height: 32px;
    color: white;
}

.transfer-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
}

.transfer-body {
    margin-bottom: 24px;
}

.transfer-status {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.progress-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.progress-container {
    flex: 1;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
}

body.dark-mode .progress-container {
    background: var(--bg-secondary);
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-percent {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 45px;
}

.transfer-details {
    font-size: 0.9rem;
    color: var(--text-tertiary);
}

.transfer-details strong {
    display: block;
    font-size: 1rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    word-break: break-all;
}

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

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
    min-width: 140px;
}

.btn-accept {
    background: linear-gradient(135deg, var(--success) 0%, var(--success-light) 100%);
}

.btn-accept:hover {
    box-shadow: var(--shadow-lg), 0 0 20px rgba(16, 185, 129, 0.4);
}

.btn-decline:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

/* ============================================
   Toast Notification
   ============================================ */

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-elevated);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: var(--radius-full);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    font-size: 0.9rem;
    opacity: 0;
    transition: var(--transition-spring);
    z-index: 2000;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 20px;
    height: 20px;
    color: var(--success);
}

body.dark-mode .toast {
    background: var(--bg-tertiary);
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1200px) {
    .main-wrapper {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
    }

    .sidebar {
        width: 100%;
        max-height: none;
    }

    .sidebar-content {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }

    .device-card {
        grid-column: 1 / -1;
    }

    .footer-credit {
        grid-column: 1 / -1;
        margin-top: 0;
    }
}

@media (max-width: 768px) {
    .main-wrapper {
        padding: 12px;
        gap: 12px;
    }

    .sidebar-content {
        grid-template-columns: 1fr;
    }

    header {
        padding: 16px 20px;
    }

    .header-text h1 {
        font-size: 1.25rem;
    }

    .tabs {
        padding: 0 16px;
    }

    .tab {
        padding: 14px 12px;
        font-size: 0.85rem;
        gap: 8px;
    }

    .tab span {
        display: none;
    }

    .tab-content {
        padding: 20px 16px;
    }

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

    .code-input-field {
        font-size: 2rem;
        letter-spacing: 8px;
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .main-wrapper {
        padding: 0;
        gap: 0;
    }

    .sidebar {
        display: none;
    }

    .mobile-device-info {
        display: block;
        margin: 8px 12px;
        padding: 10px 12px;
        border-radius: var(--radius-md);
        order: 0;
    }

    .tabs {
        order: 1;
    }

    .tab-content {
        order: 2;
    }

    .mobile-info-header {
        gap: 10px;
    }

    .mobile-device-emoji {
        width: 36px;
        height: 36px;
    }

    .mobile-device-emoji i,
    .mobile-device-emoji svg {
        width: 18px;
        height: 18px;
    }

    .mobile-device-name {
        font-size: 0.9rem;
    }

    .mobile-connection-code {
        font-size: 0.75rem;
        letter-spacing: 1.5px;
    }

    .qr-toggle-btn {
        width: 34px;
        height: 34px;
    }

    .mobile-qr-code {
        margin-top: 10px;
        padding: 10px 0 0;
    }

    .mobile-qr-code.hidden {
        display: none;
        margin-top: 0;
        padding: 0;
        border-top: none;
    }

    .main-content {
        border-radius: 0;
        border: none;
    }

    .ambient-bg {
        display: none;
    }

    header {
        padding: 12px 16px;
    }

    .logo-wrapper {
        width: 40px;
        height: 40px;
    }

    .header-left {
        gap: 12px;
    }

    .header-text h1 {
        font-size: 1.125rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .theme-toggle {
        width: 40px;
        height: 40px;
    }

    .tabs {
        padding: 0;
        background: var(--bg-secondary);
    }

    .tab {
        padding: 12px;
    }

    .tab span {
        display: block;
        font-size: 0.7rem;
    }

    .tab-icon i, .tab-icon svg {
        width: 20px;
        height: 20px;
    }

    .tab-content {
        padding: 16px;
    }

    .peer-list {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .peer-card {
        padding: 16px 12px;
        border-radius: var(--radius-md);
    }

    .peer-icon {
        width: 48px;
        height: 48px;
        margin-bottom: 10px;
    }

    .peer-icon i, .peer-icon svg {
        width: 22px;
        height: 22px;
    }

    .peer-name {
        font-size: 0.75rem;
    }

    .peer-type {
        font-size: 0.65rem;
    }

    .code-input-section {
        padding: 0;
    }

    .code-input-field {
        font-size: 1.75rem;
        letter-spacing: 6px;
        padding: 14px;
    }

    .btn-connect {
        padding: 14px;
    }

    .modal-content {
        margin: 16px;
        max-width: none;
        border-radius: var(--radius-lg);
    }

    .upload-area {
        margin: 16px;
        padding: 32px 16px;
    }

    .upload-icon-wrapper {
        width: 64px;
        height: 64px;
    }

    .upload-icon {
        width: 32px;
        height: 32px;
    }

    .upload-area h3 {
        font-size: 1.1rem;
    }

    .upload-types {
        gap: 8px;
    }

    .upload-type {
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    .upload-actions {
        flex-direction: column;
        padding: 16px;
    }

    .transfer-modal-content {
        padding: 24px 20px;
    }

    .transfer-icon-wrapper {
        width: 60px;
        height: 60px;
    }

    .transfer-direction-icon {
        width: 28px;
        height: 28px;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions .btn-primary,
    .modal-actions .btn-secondary {
        width: 100%;
    }

    .no-peers {
        padding: 40px 20px;
    }

    .searching-animation {
        width: 80px;
        height: 80px;
    }

    .no-peers h3 {
        font-size: 1rem;
    }

    .no-peers p {
        font-size: 0.8rem;
    }
}

/* ============================================
   Scrollbar
   ============================================ */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

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

/* ============================================
   Selection
   ============================================ */

::selection {
    background: var(--primary);
    color: white;
}

/* ============================================
   Focus Visible
   ============================================ */

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible {
    outline-offset: 2px;
}

input:focus-visible {
    outline: none;
}
