/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

.mobile-container {
    max-width: 480px;
    padding: 10px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Screen management */
.screen {
    display: none;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
}

.screen.active {
    display: block;
}

/* Mobile screen layout optimization */
.mobile .screen.active {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 120px);
}

/* Start screen */
.start-content {
    padding: 60px 40px;
    text-align: center;
}

.start-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #333;
}

.start-content p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 40px;
    line-height: 1.8;
}

/* Main screen */
.main-content {
    padding: 40px;
}

.mobile-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* QR Section */
.qr-section {
    text-align: center;
    margin-bottom: 40px;
    padding-bottom: 40px;
    border-bottom: 1px solid #eee;
}

.qr-section h3 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #333;
}

#qrContainer {
    margin-bottom: 20px;
}

#qrPlaceholder {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    padding: 40px;
    color: #666;
    font-size: 1.1rem;
}

#qrCode {
    max-width: 200px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Status indicator */
.status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1rem;
}

.mobile-status {
    margin-bottom: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background: #28a745;
    box-shadow: 0 0 8px rgba(40, 167, 69, 0.5);
}

.status-indicator.offline {
    background: #dc3545;
    box-shadow: 0 0 8px rgba(220, 53, 69, 0.5);
}

/* Upload section */
.upload-section, .mobile-upload-section {
    margin-bottom: 40px;
}

/* Mobile upload section should not grow */
.mobile-upload-section {
    flex-shrink: 0;
    margin-bottom: 20px;
}

.upload-section h3, .mobile-upload-section h3 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #333;
}

.upload-area, .mobile-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9fa;
}

.mobile-upload-area {
    padding: 30px 20px;
}

.upload-area:hover, .mobile-upload-area:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

.upload-area.drag-over {
    border-color: #667eea;
    background: #e8f0fe;
    transform: scale(1.02);
}

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

.upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.upload-area p, .mobile-upload-area p {
    color: #666;
    font-size: 1.1rem;
}

.upload-link {
    color: #667eea;
    text-decoration: underline;
    cursor: pointer;
}

/* Progress bar */
.progress-container {
    margin-top: 20px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    text-align: center;
    margin-top: 10px;
    color: #666;
    font-size: 0.9rem;
}

/* Files section */
.files-section, .mobile-files-section {
    margin-bottom: 20px;
}

/* Mobile files section should grow to fill space */
.mobile-files-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for flex scrolling */
    margin-bottom: 0;
}

.files-section h3, .mobile-files-section h3 {
    font-size: 1.4rem;
    margin-bottom: 20px;
    color: #333;
}

/* Files header with download all button */
.files-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.files-header h3 {
    margin-bottom: 0;
}

.btn-download-all {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    white-space: nowrap;
}

.btn-download-all:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

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

.files-list {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.mobile-files-list {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth iOS scrolling */
    background: #f8f9fa;
    border-radius: 10px;
}

.no-files {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 20px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px;
    background: white;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    transition: transform 0.2s ease;
}

.file-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.mobile-file-item {
    padding: 12px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    word-break: break-word;
    display: flex;
    align-items: center;
    gap: 8px;
}

.rename-indicator {
    font-size: 0.8rem;
    opacity: 0.7;
    cursor: help;
    background: #fff3cd;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.file-details {
    font-size: 0.85rem;
    color: #666;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-download {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn-download {
    background: #28a745;
    color: white;
    padding: 8px 16px;
    font-size: 0.9rem;
    flex-shrink: 0;
    margin-left: 15px;
}

.btn-download:hover {
    background: #218838;
    transform: translateY(-1px);
}

.mobile-btn {
    padding: 8px 12px;
    font-size: 1.2rem;
    margin-left: 10px;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    z-index: 1000;
    max-width: 350px;
}

.notification.show {
    transform: translateX(0);
}

.notification.success {
    background: #28a745;
}

.notification.error {
    background: #dc3545;
}

.notification.warning {
    background: #ffc107;
    color: #333;
}

.notification.info {
    background: #17a2b8;
}

/* QR Scanner */
.scanner-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-top: 20px;
    text-align: center;
}

.scanner-section h3 {
    margin-bottom: 20px;
    color: #333;
}

#scannerContainer {
    position: relative;
    margin-bottom: 20px;
}

#scannerVideo {
    width: 100%;
    max-width: 300px;
    height: auto;
    border-radius: 10px;
}

/* Mobile optimizations */
.mobile {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.mobile header h1 {
    font-size: 2rem;
}

.mobile .screen {
    margin-bottom: 20px;
}

/* Responsive design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .main-content {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .start-content {
        padding: 40px 20px;
    }
    
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .file-item {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .btn-download {
        margin: 10px 0 0 0;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .upload-area, .mobile-upload-area {
        padding: 30px 15px;
    }
    
    .upload-icon {
        font-size: 2.5rem;
    }
    
    .files-list, .mobile-files-list {
        padding: 15px;
    }
}

/* Footer styles */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid #e0e0e0;
    padding: 12px 20px;
    z-index: 100;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-links {
    margin-bottom: 5px;
}

.footer-link {
    color: #666;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.3s;
}

.footer-link:hover {
    color: #4CAF50;
}

.icp-link {
    color: #888;
}

.icp-link:hover {
    color: #4CAF50;
}

.footer-separator {
    margin: 0 10px;
    color: #ccc;
}

.footer-note {
    color: #888;
    font-size: 12px;
    margin-top: 3px;
}

/* Mobile footer adjustments */
.mobile-footer {
    position: relative;
    margin-top: 30px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    border-radius: 8px 8px 0 0;
    width: 100%;
}

.mobile-footer .footer-links {
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.mobile-footer .footer-link {
    font-size: 12px;
}

.mobile-footer .footer-note {
    font-size: 11px;
    text-align: center;
}

.mobile-footer .footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Adjust body padding to account for fixed footer */
body {
    padding-bottom: 80px;
}

body.mobile {
    padding-bottom: 20px;
}

/* Language Switcher */
.language-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.mobile-lang {
    top: 15px;
    right: 15px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.lang-btn:hover {
    background: white;
    border-color: #4CAF50;
    color: #4CAF50;
}

.lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 120px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    margin-top: 5px;
}

.lang-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-dropdown a {
    display: block;
    padding: 10px 15px;
    color: #666;
    text-decoration: none;
    transition: background 0.2s;
    font-size: 14px;
}

.lang-dropdown a:hover {
    background: #f5f5f5;
    color: #4CAF50;
}

.lang-dropdown a:first-child {
    border-radius: 6px 6px 0 0;
}

.lang-dropdown a:last-child {
    border-radius: 0 0 6px 6px;
}

/* Responsive footer */
@media (max-width: 768px) {
    .footer {
        padding: 10px 15px;
    }
    
    .footer-link {
        font-size: 12px;
    }
    
    .footer-note {
        font-size: 11px;
    }
    
    .footer-separator {
        margin: 0 8px;
    }
    
    .language-switcher {
        top: 15px;
        right: 15px;
    }
    
    .lang-btn {
        padding: 6px 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .footer-links {
        display: flex;
        flex-direction: column;
        gap: 5px;
        align-items: center;
    }
    
    .footer-separator {
        display: none;
    }
    
    .footer-link {
        font-size: 11px;
    }
    
    .footer-note {
        font-size: 10px;
        margin-top: 5px;
    }
}