:root {
    --primary-color: #2196F3;
    --hover-color: #1976D2;
    --error-color: #f44336;
    --success-color: #4CAF50;
    --warning-color: #ff9800;
    --text-color: #333;
    --background-color: #f5f5f5;
    --card-background: #ffffff;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Header styles */
header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-container {
    margin: 1.5rem 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo {
    height: 80px;
    width: auto;
    max-width: 90%;
    transition: transform 0.2s ease;
}

@media (max-width: 768px) {
    .logo {
        height: 60px;
    }
}

@media (max-width: 480px) {
    .logo {
        height: 50px;
    }
}

h1 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

h3 {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
}

/* Connection section styles */
#connection-section {
    background: var(--card-background);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px var(--shadow-color);
    margin-bottom: 2rem;
}

.peer-info {
    margin-bottom: 2rem;
}

.peer-id-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
    background: var(--background-color);
    padding: 10px;
    border-radius: 4px;
}

#peer-id {
    flex: 1;
    word-break: break-all;
    font-family: monospace;
}

.peer-actions {
    display: flex;
    gap: 8px;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

.icon-button:hover {
    background-color: var(--border-color);
}

.icon-button .material-icons {
    font-size: 20px;
    color: var(--text-color);
}

/* QR Code styles */
#qrcode-container {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

#qrcode {
    padding: 10px;
    background: white;
    border-radius: 4px;
}

/* Connect peer styles */
.connect-peer {
    margin-bottom: 2rem;
}

.input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 1rem;
}

.peer-input-container {
    flex: 1;
    position: relative;
}

input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
}

.button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.button.primary:hover {
    background-color: var(--hover-color);
}

/* Status indicator styles */
.status {
    margin-top: 1rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: var(--error-color);
    transition: background-color 0.3s;
}

.status-dot.connecting {
    background-color: var(--warning-color);
    animation: pulse 1.5s infinite;
}

.status-dot.connected {
    background-color: var(--success-color);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* File transfer section styles */
#file-transfer-section {
    background: var(--card-background);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px var(--shadow-color);
}

.drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    margin-bottom: 2rem;
}

.drop-zone:hover {
    border-color: var(--primary-color);
}

.drop-zone-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: #666;
}

.drop-zone-text .material-icons {
    font-size: 48px;
    color: var(--primary-color);
}

input[type="file"] {
    display: none;
}

/* Progress bar styles */
.progress-container {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1rem;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background-color: var(--background-color);
    border-radius: 5px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background-color: var(--primary-color);
    width: 0;
    transition: width 0.3s;
}

/* Files history styles */
.files-history {
    margin-top: 2rem;
}

.files-section {
    margin-bottom: 2rem;
}

.files-list {
    list-style: none;
}

.files-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--background-color);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: background-color 0.2s, background 0.3s ease;
}

.files-list li:hover {
    background-color: #f0f0f0;
}

.files-list .material-icons {
    color: var(--primary-color);
    font-size: 24px;
}

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

.file-name {
    font-weight: 500;
    font-size: 1rem;
    color: var(--text-color);
    word-break: break-all;
    margin-bottom: 2px;
}

.file-size {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 2px;
}

.shared-by {
    font-size: 0.85rem;
    color: #666;
    font-style: italic;
}

.download-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    color: var(--primary-color);
    transition: background-color 0.2s;
}

.download-button:hover {
    background-color: rgba(33, 150, 243, 0.1);
}

.download-button .material-icons {
    font-size: 20px;
}

.download-progress-text {
    color: var(--primary-color);
    font-weight: bold;
    font-family: monospace;
    font-size: 1rem;
}

/* Files sections */
.files-section {
    background: var(--card-background);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.files-section h3 {
    margin: 0 0 16px 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 500;
}

/* Recent peers dropdown */
.recent-peers {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 2px 4px var(--shadow-color);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
}

.recent-peers-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 500;
}

.clear-peers {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.clear-peers:hover {
    background-color: var(--border-color);
}

#recent-peers-list {
    list-style: none;
}

#recent-peers-list li {
    padding: 10px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#recent-peers-list li:hover {
    background-color: var(--background-color);
}

/* Utility classes */
.hidden {
    display: none !important;
}

.warning {
    color: var(--warning-color);
    margin-bottom: 1rem;
}

/* Notifications */
.notifications {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.notification {
    background: var(--card-background);
    border-radius: 4px;
    padding: 10px 20px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px var(--shadow-color);
    animation: slideIn 0.3s ease-out;
    max-width: 300px;
}

.notification.error {
    border-left: 4px solid var(--error-color);
}

.notification.success {
    border-left: 4px solid var(--success-color);
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    .input-group {
        flex-direction: column;
    }

    .button {
        width: 100%;
        justify-content: center;
    }

    .peer-id-container {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }

    .peer-actions {
        justify-content: center;
    }

    #qrcode {
        max-width: 100%;
        height: auto;
    }

    .drop-zone {
        padding: 20px;
    }

    .files-list li {
        flex-direction: column;
        text-align: center;
    }

    .download-button {
        margin-top: 10px;
    }
}

/* Download completed styles */
.files-list li.download-completed {
    background: rgba(76, 175, 80, 0.15);  /* More prominent green background */
    border-left: 4px solid #4CAF50;  /* Green left border */
    transition: all 0.3s ease;
}

.icon-button.download-completed {
    color: #4CAF50;  /* Green color for completed icon */
    background-color: rgba(76, 175, 80, 0.1);  /* Light green background for button */
}

/* Error state styles for failed downloads */
.files-list li.download-failed {
    background-color: #ffebee;
    border-left: 4px solid var(--error-color);
    animation: errorShake 0.5s ease-in-out;
}

.icon-button.download-failed {
    color: var(--error-color);
}

.file-error {
    color: var(--error-color);
    font-size: 12px;
    margin-top: 4px;
    font-weight: 500;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Peer ID editing styles */
.peer-id-display {
    display: flex;
    align-items: center;
    flex: 1;
}

.peer-id-edit {
    font-size: 1rem;
    padding: 4px 8px;
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    background: var(--background-color);
    color: var(--text-color);
    width: 100%;
    max-width: 100%;
    min-width: 200px;
    font-family: monospace;
    box-sizing: border-box;
    overflow-x: auto;
}

.peer-id-edit.hidden {
    display: none;
}

#peer-id.hidden {
    display: none;
}

.icon-button.hidden {
    display: none;
}

/* Disabled edit button state */
.icon-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-button:disabled:hover {
    background-color: transparent;
}

/* ===== PWA INSTALLATION STYLES ===== */

/* PWA Indicator Icon */
.pwa-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.3);
    transition: all 0.3s ease;
    z-index: 1001;
    /* Ensure visibility with proper spacing */
    margin: 0;
    padding: 0;
    /* Add safe distance from viewport edges */
    top: calc(20px + env(safe-area-inset-top, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
}

.pwa-indicator:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.4);
}

.pwa-indicator .material-icons {
    font-size: 20px;
    font-weight: bold;
}

.pwa-indicator.hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.pwa-indicator.update-available {
    background: #FF9800;
}

.pwa-indicator.update-available .material-icons {
    content: "system_update";
}



.pwa-install-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.pwa-install-container.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(-100%);
}

.pwa-install-banner {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(33, 150, 243, 0.3);
}

.pwa-install-content {
    display: flex;
    align-items: center;
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.pwa-install-icon {
    flex-shrink: 0;
}

.pwa-install-icon img {
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.pwa-install-text {
    flex: 1;
}

.pwa-install-text h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
}

.pwa-install-text p {
    margin: 0;
    font-size: 14px;
    opacity: 0.9;
    line-height: 1.4;
}

.pwa-install-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.pwa-install-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.pwa-install-btn.primary {
    background: white;
    color: #2196F3;
}

.pwa-install-btn.primary:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
}

.pwa-install-btn.secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.pwa-install-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* PWA Update Notification */
.pwa-update-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    background: #4CAF50;
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
    animation: slideInUp 0.3s ease;
}

.pwa-update-banner {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-update-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.pwa-update-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pwa-update-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== MOBILE OPTIMIZATIONS ===== */

/* Mobile device specific styles */
.mobile-device {
    --safe-area-inset-top: env(safe-area-inset-top);
    --safe-area-inset-bottom: env(safe-area-inset-bottom);
    --safe-area-inset-left: env(safe-area-inset-left);
    --safe-area-inset-right: env(safe-area-inset-right);
}

.mobile-device .container {
    padding-top: var(--safe-area-inset-top);
    padding-bottom: var(--safe-area-inset-bottom);
    padding-left: var(--safe-area-inset-left);
    padding-right: var(--safe-area-inset-right);
}

/* Touch optimizations */
.mobile-device button,
.mobile-device .icon-button {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.mobile-device button:active,
.mobile-device .icon-button:active {
    transform: scale(0.95);
}

/* Mobile file input optimization */
.mobile-device #file-input {
    font-size: 16px; /* Prevents zoom on iOS */
}

/* Mobile layout adjustments */
@media (max-width: 768px) {
    .pwa-install-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }
    
    .pwa-install-actions {
        width: 100%;
        justify-content: center;
    }
    
    .pwa-install-btn {
        flex: 1;
        max-width: 120px;
    }
    
    /* Adjust main layout for mobile */
    .container {
        padding: 16px;
        max-width: 100%;
    }
    
    /* Optimize file list for mobile */
    .file-list {
        margin: 16px 0;
    }
    
    .file-list li {
        padding: 12px;
        margin-bottom: 8px;
        border-radius: 8px;
    }
    
    /* Optimize buttons for mobile */
    .icon-button {
        padding: 12px;
        font-size: 18px;
    }
    
    /* Optimize input fields for mobile */
    input[type="text"],
    input[type="file"] {
        font-size: 16px;
        padding: 12px;
        border-radius: 8px;
    }
    
    /* Optimize notifications for mobile */
    .notification {
        margin: 8px;
        padding: 12px;
        border-radius: 8px;
        font-size: 14px;
    }
}

/* Portrait mode optimizations */
.mobile-device.portrait .container {
    padding-top: calc(16px + var(--safe-area-inset-top));
}

.mobile-device.portrait .file-transfer-section {
    margin-top: 8px;
}

/* Landscape mode optimizations */
.mobile-device.landscape .container {
    padding-top: calc(8px + var(--safe-area-inset-top));
}

.mobile-device.landscape .file-transfer-section {
    margin-top: 4px;
}

/* Pull-to-refresh indicator */
.pull-to-refresh-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(135deg, #2196F3, #1976D2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: 500;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 9998;
}

.pull-to-refresh-indicator.visible {
    transform: translateY(0);
}

/* Mobile-specific animations */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile gesture feedback */
.mobile-device .gesture-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 10001;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-device .gesture-feedback.visible {
    opacity: 1;
}

/* Mobile file transfer progress */
.mobile-device .transfer-progress {
    position: fixed;
    bottom: calc(20px + var(--safe-area-inset-bottom));
    left: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 9999;
}

.mobile-device .transfer-progress .progress-bar {
    height: 6px;
    border-radius: 3px;
    background: #e0e0e0;
    overflow: hidden;
    margin: 8px 0;
}

.mobile-device .transfer-progress .progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2196F3, #1976D2);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Mobile notification badges */
.mobile-device .notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #f44336;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Mobile keyboard adjustments */
@media (max-height: 500px) {
    .mobile-device .container {
        padding-top: 8px;
        padding-bottom: 8px;
    }
    
    .mobile-device .file-transfer-section {
        margin-top: 4px;
    }
    
    .mobile-device .pwa-install-container {
        position: absolute;
        top: 8px;
        left: 8px;
        right: 8px;
    }
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .pwa-install-icon img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Dark mode support for mobile */
@media (prefers-color-scheme: dark) {
    .mobile-device .transfer-progress {
        background: #1e1e1e;
        color: white;
    }
    
    .mobile-device .gesture-feedback {
        background: rgba(255, 255, 255, 0.9);
        color: #1e1e1e;
    }
}

/* Accessibility improvements for mobile */
.mobile-device button:focus,
.mobile-device .icon-button:focus {
    outline: 2px solid #2196F3;
    outline-offset: 2px;
}

.mobile-device .pwa-install-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .pwa-install-container,
    .pwa-update-container,
    .pull-to-refresh-indicator,
    .gesture-feedback {
        transition: none;
    }
    
    .mobile-device button:active,
    .mobile-device .icon-button:active {
        transform: none;
    }
}

/* Mobile PWA indicator adjustments */
@media (max-width: 768px) {
    .pwa-indicator {
        width: 36px;
        height: 36px;
        top: 16px;
        right: 16px;
    }
    
    .pwa-indicator .material-icons {
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .pwa-indicator {
        width: 32px;
        height: 32px;
        top: 12px;
        right: 12px;
    }
    
    .pwa-indicator .material-icons {
        font-size: 16px;
    }
}
