* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    min-height: 100vh;
    padding: 12px;
    margin: 0;
}

/* Arabic font */
html[dir="rtl"] body,
html[lang="ar"] body, button {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Language Switcher */
.lang-switcher {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 2000;
    display: flex;
    gap: 8px;
}

.lang-btn {
    background: #fff;
    color: #666;
    border: 1px solid #e0e0e0;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    min-width: 40px;
    text-align: center;
}

.lang-btn:hover:not(.active) {
    border-color: #000;
    background: #fafafa;
}

.lang-btn.active {
    background: #000 !important;
    color: #fff !important;
    border-color: #000 !important;
    cursor: default;
}

/* Room Join Screen */
.room-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f5f5f5;
    z-index: 1000;
}

.room-screen.hidden {
    display: none;
}

.room-container {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 32px 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.room-container h2 {
    font-size: 20px;
    font-weight: 600;
    color: #000;
    margin-bottom: 6px;
}

.room-container p {
    font-size: 12px;
    color: #666;
    margin-bottom: 24px;
}

.room-input {
    width: 100%;
    padding: 16px 12px;
    font-size: 28px;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    margin-bottom: 12px;
    text-align: center;
    letter-spacing: 6px;
    font-weight: 600;
    -webkit-appearance: none;
}

.room-input:focus {
    outline: none;
    border-color: #000;
}

.room-btn {
    width: 100%;
    background: #000;
    color: #fff;
    border: none;
    padding: 14px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    margin-bottom: 8px;
    text-transform: none;
}

.room-btn:hover {
    background: #333;
}

.room-btn:active {
    transform: scale(0.98);
}

.room-btn.outline {
    background: #fff;
    color: #000;
    border: 1px solid #e0e0e0;
}

.room-btn.outline:hover {
    border-color: #000;
    background: #fafafa;
}

.divider {
    margin: 24px 0;
    color: #999;
    font-size: 12px;
    position: relative;
}

.divider::before,
.divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #e0e0e0;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.generated-code {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    padding: 12px;
    margin: 16px 0;
    font-size: 36px;
    font-weight: 600;
    letter-spacing: 6px;
    color: #000;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding-top: 48px;
}

h1 {
    font-size: 18px;
    font-weight: 600;
    color: #000;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.room-info {
    font-size: 11px;
    color: #666;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.room-code-display {
    background: #000;
    color: #fff;
    padding: 4px 10px;
    border-radius: 3px;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 2px;
}

.btn-leave {
    background: #fff;
    color: #000;
    border: 1px solid #e0e0e0;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}

.btn-leave:hover {
    border-color: #000;
}

.status {
    font-size: 12px;
    color: #666;
    margin-bottom: 24px;
}

.status.connected {
    color: #000;
}

.status span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #000;
    border-radius: 50%;
    margin-left: 6px;
}

.upload-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 24px 16px;
    margin-bottom: 24px;
    text-align: center;
    position: relative;
    transition: border-color 0.2s;
}

.upload-section.drag-over {
    border-color: #000;
    background: #fafafa;
}

.drop-zone-text {
    font-size: 12px;
    color: #999;
    margin-top: 16px;
}

.file-input-wrapper {
    margin-bottom: 16px;
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.file-input-wrapper input[type=file] {
    display: none;
}

.file-input-label {
    display: inline-block;
    background: #000;
    color: #fff;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.file-input-label:hover {
    background: #333;
}

.file-input-label:active {
    transform: scale(0.98);
}

.btn-paste, .btn-camera {
    display: inline-block;
    background: #fff;
    color: #000;
    border: 1px solid #e0e0e0;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-paste:hover, .btn-camera:hover {
    background: #fafafa;
    border-color: #000;
}

.btn-paste:active, .btn-camera:active {
    transform: scale(0.98);
}

/* Camera Modal */
.camera-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.camera-modal.active {
    display: flex;
}

.camera-container {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.camera-container video,
.camera-container canvas {
    max-width: 100%;
    border-radius: 4px;
    background: #000;
}

.camera-controls {
    display: flex;
    gap: 12px;
}

.camera-controls button {
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-capture {
    background: #000;
    color: #fff;
    border: none;
}

.btn-capture:hover {
    background: #333;
}

.btn-cancel {
    background: #fff;
    color: #000;
    border: 1px solid #e0e0e0;
}

.btn-cancel:hover {
    background: #fafafa;
}

/* Transfers Queue */
#transfersQueue {
    display: none;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0;
}

#transfersQueue.active {
    display: flex;
}

.transfer-item {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 12px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.transfer-item.completed {
    background: #f0fdf4;
    border-color: #10b981;
}

.transfer-item.error {
    background: #fef2f2;
    border-color: #ef4444;
}

.transfer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 8px;
}

.transfer-info {
    flex: 1;
    min-width: 0;
}

.transfer-filename {
    font-size: 12px;
    font-weight: 600;
    color: #000;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.transfer-stats {
    font-size: 10px;
    color: #666;
}

.transfer-type {
    font-size: 18px;
    flex-shrink: 0;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: #000;
    transition: width 0.3s ease;
    border-radius: 3px;
}

.progress-fill.sending {
    background: #3b82f6;
}

.progress-fill.receiving {
    background: #10b981;
}

.progress-fill.completed {
    background: #10b981;
}

.progress-fill.error {
    background: #ef4444;
}

/* File Preview Modal */
.preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.preview-modal.active {
    display: flex;
}

.preview-container {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    position: relative;
}

.preview-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: #000;
    color: #fff;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.preview-close:hover {
    background: #333;
}

.preview-content img,
.preview-content video,
.preview-content audio {
    max-width: 100%;
    border-radius: 4px;
}

.preview-content iframe {
    width: 100%;
    height: 600px;
    border: none;
    border-radius: 4px;
}

/* QR Code */
.qr-code-container {
    margin-top: 16px;
    text-align: center;
    display: flex;
    justify-content: center;
}

.qr-code-container canvas {
    margin: 8px auto;
    display: block;
}

#fileName {
    font-size: 13px;
    color: #666;
    margin: 12px 0;
    min-height: 20px;
}

.btn-send {
    background: #000;
    color: #fff;
    border: none;
    padding: 14px 32px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-send:hover:not(:disabled) {
    background: #333;
}

.btn-send:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-send:disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
}

.files-header {
    font-size: 14px;
    font-weight: 600;
    color: #000;
    margin-bottom: 16px;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 12px;
}

.file-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.file-preview {
    width: 100%;
    height: 160px;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.file-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-icon {
    font-size: 48px;
    color: #d0d0d0;
}

.file-details {
    padding: 12px;
}

.file-name {
    font-size: 12px;
    font-weight: 500;
    color: #000;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 11px;
    color: #999;
    margin-bottom: 12px;
}

.file-actions {
    display: flex;
    gap: 8px;
}

.btn-action {
    flex: 1;
    background: #000;
    color: #fff;
    border: none;
    padding: 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-action:hover {
    background: #333;
}

.btn-action:active {
    transform: scale(0.95);
}

.btn-action.success {
    background: #10b981;
}

.btn-action.outline {
    background: #fff;
    color: #000;
    border: 1px solid #e0e0e0;
}

.btn-action.outline:hover {
    border-color: #000;
    background: #fafafa;
}

/* Non-image file layout */
.file-item.file-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 24px 16px;
}

.file-item.file-row .file-preview {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    margin-bottom: 12px;
}

.file-item.file-row .file-icon {
    font-size: 32px;
}

.file-item.file-row .file-details {
    width: 100%;
    padding: 0;
    margin-bottom: 16px;
}

.file-item.file-row .file-actions {
    width: 100%;
}

.file-item.file-row .btn-action {
    width: 100%;
    padding: 10px 24px;
    white-space: nowrap;
}

.file-item.file-row .file-name {
    margin-bottom: 4px;
    font-size: 13px;
    word-break: break-word;
}

.file-item.file-row .file-meta {
    margin-bottom: 0;
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: #000;
    color: #fff;
    padding: 14px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    z-index: 3000;
    transition: bottom 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 90%;
}

.toast.show {
    bottom: 24px;
}

.toast.success {
    background: #10b981;
}

.toast.warning {
    background: #f59e0b;
}

.toast-icon {
    font-size: 18px;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    body {
        padding: 8px;
    }

    .container {
        padding-top: 56px;
    }

    .room-container {
        padding: 24px 16px;
    }

    .room-container h2 {
        font-size: 18px;
    }

    .room-input {
        font-size: 24px;
        letter-spacing: 4px;
        padding: 14px 10px;
    }

    .generated-code {
        font-size: 28px;
        letter-spacing: 4px;
    }

    h1 {
        font-size: 16px;
    }

    .room-info {
        font-size: 10px;
    }

    .room-code-display {
        font-size: 12px;
        padding: 3px 8px;
    }

    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .file-preview {
        height: 140px;
    }

    .file-name {
        font-size: 11px !important;
    }

    .file-meta {
        font-size: 10px !important;
    }

    .btn-action {
        font-size: 10px !important;
        padding: 7px !important;
    }

    .upload-section {
        padding: 20px 12px;
    }

    .file-input-label,
    .btn-paste,
    .btn-camera {
        font-size: 12px;
        padding: 10px 16px;
    }
    
    .file-input-wrapper {
        flex-direction: column;
        gap: 8px;
    }
    
    .file-input-wrapper button,
    .file-input-wrapper label {
        width: 100%;
    }
    
    .camera-container {
        max-width: 95%;
        padding: 16px;
    }
    
    .camera-container video {
        width: 100%;
        height: auto;
    }
    
    .camera-controls {
        flex-direction: column;
        width: 100%;
    }
    
    .camera-controls button {
        width: 100%;
    }
    
    .qr-code-container canvas {
        width: 100px !important;
        height: 100px !important;
    }

    .btn-send {
        font-size: 12px;
        padding: 10px 20px;
    }
}

@media (max-width: 380px) {
    .files-grid {
        grid-template-columns: 1fr;
    }

    .room-input {
        font-size: 20px;
    }

    .file-input-wrapper {
        flex-direction: column;
    }
}

