/* =============================================
   FileShare — style.css
   تصميم حديث بثيم داكن مع RTL عربي
   ============================================= */

/* -------- المتغيرات -------- */
:root {
    --bg:           #0b0c1a;
    --bg2:          #111228;
    --card:         #161730;
    --card2:        #1d1f3a;
    --border:       #2a2d55;
    --primary:      #6c63ff;
    --primary-glow: rgba(108,99,255,.35);
    --secondary:    #00d2ff;
    --success:      #00e5a0;
    --danger:       #ff4d6d;
    --warning:      #ffa94d;
    --text:         #e2e4f0;
    --text2:        #8b8fa8;
    --text3:        #5a5d78;
    --radius:       14px;
    --radius-sm:    8px;
    --shadow:       0 8px 32px rgba(0,0,0,.45);
    --trans:        .25s ease;
}

/* -------- ريست أساسي -------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
    font-family: 'Segoe UI', 'Cairo', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    direction: rtl;
    overflow-x: hidden;
}

/* -------- خلفية الجسيمات -------- */
#particles {
    position: fixed; inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: .5;
}

/* -------- الهيدر -------- */
header {
    position: sticky; top: 0; z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 24px;
    background: rgba(11,12,26,.85);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
}

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    padding: 7px;
}
.logo-icon svg { color: #fff; width: 100%; height: 100%; }
.logo-text { font-size: 1.25rem; font-weight: 700; letter-spacing: -.5px; }
.logo-badge {
    font-size: .65rem; font-weight: 700;
    background: var(--primary);
    color: #fff;
    padding: 2px 7px; border-radius: 20px;
    letter-spacing: 1px;
}

.header-status {
    display: flex; align-items: center; gap: 7px;
    font-size: .8rem; color: var(--text2);
}
.status-dot {
    width: 8px; height: 8px; border-radius: 50%;
    transition: background var(--trans);
}
.status-dot.offline  { background: var(--text3); }
.status-dot.waiting  { background: var(--warning); animation: blink 1.2s infinite; }
.status-dot.online   { background: var(--success); animation: blink 2s infinite; }
.status-dot.transfer { background: var(--secondary); animation: blink .6s infinite; }

@keyframes blink {
    0%,100% { opacity: 1; }
    50%      { opacity: .3; }
}

/* -------- التبويبات -------- */
.tabs {
    position: sticky; top: 65px; z-index: 99;
    display: flex;
    background: rgba(11,12,26,.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
}
.tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px 16px;
    background: none; border: none; cursor: pointer;
    color: var(--text2);
    font-size: .9rem; font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: all var(--trans);
    direction: rtl;
}
.tab svg { width: 18px; height: 18px; flex-shrink: 0; }
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* -------- الأقسام الرئيسية -------- */
main {
    position: relative; z-index: 1;
    max-width: 640px;
    margin: 0 auto;
    padding: 24px 16px 80px;
}
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeUp .35s ease; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* -------- البطاقات -------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    animation: fadeUp .3s ease;
}
.card.hidden { display: none; }

.card-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 18px;
}
.card-header h2 { font-size: 1.05rem; font-weight: 600; }
.card-desc { color: var(--text2); font-size: .9rem; margin-bottom: 18px; }

.step-badge {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--primary);
    color: #fff; font-size: .8rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.step-badge.success { background: var(--success); color: #000; }

/* -------- منطقة الرفع -------- */
.upload-area {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all var(--trans);
    overflow: hidden;
    margin-bottom: 16px;
}
.upload-area:hover, .upload-area.drag-over {
    border-color: var(--primary);
    background: rgba(108,99,255,.06);
}
.upload-area.drag-over .upload-glow {
    opacity: 1;
}

.upload-glow {
    position: absolute; inset: 0;
    background: radial-gradient(ellipse at center, rgba(108,99,255,.15) 0%, transparent 70%);
    opacity: 0; transition: opacity var(--trans);
}
.upload-content { position: relative; z-index: 1; }
.upload-icon {
    width: 60px; height: 60px; margin: 0 auto 16px;
    background: rgba(108,99,255,.15);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: transform var(--trans);
}
.upload-area:hover .upload-icon { transform: translateY(-4px); }
.upload-icon svg { width: 28px; height: 28px; color: var(--primary); }
.upload-title { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.upload-sub { color: var(--text2); font-size: .85rem; margin: 8px 0; }
.upload-hint { color: var(--text3); font-size: .78rem; margin-top: 10px; }

/* -------- معلومات الملف -------- */
.file-info {
    display: flex; align-items: center; gap: 12px;
    background: var(--card2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-bottom: 16px;
    animation: fadeUp .2s ease;
}
.file-info.hidden { display: none; }
.file-icon-wrap { font-size: 2rem; flex-shrink: 0; }
.file-details { flex: 1; min-width: 0; }
.file-name { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-meta { font-size: .78rem; color: var(--text2); margin-top: 2px; }
.file-remove {
    background: none; border: none; cursor: pointer;
    color: var(--text3); font-size: 1rem;
    padding: 4px 8px; border-radius: var(--radius-sm);
    transition: all var(--trans);
}
.file-remove:hover { background: rgba(255,77,109,.15); color: var(--danger); }

/* -------- الأزرار -------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm); border: none; cursor: pointer;
    font-size: .9rem; font-weight: 600;
    transition: all var(--trans); text-decoration: none;
    direction: rtl;
}
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #5b52e8);
    color: #fff;
    box-shadow: 0 4px 20px var(--primary-glow);
}
.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--primary-glow);
}

.btn-secondary {
    background: var(--card2);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
    border-color: var(--secondary);
    color: var(--secondary);
    transform: translateY(-2px);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
    padding: 9px 18px; font-size: .85rem;
}
.btn-outline:hover { background: rgba(108,99,255,.1); }

.btn-success {
    background: linear-gradient(135deg, var(--success), #00b37a);
    color: #000; font-weight: 700;
    box-shadow: 0 4px 20px rgba(0,229,160,.25);
}
.btn-success:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,229,160,.35);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { transform: translateY(-2px); }

.full-width { width: 100%; }
.big-btn { padding: 15px 24px; font-size: 1rem; width: 100%; }

/* -------- بطاقة QR -------- */
.qr-card { }

.sender-status {
    display: flex; align-items: center; gap: 10px;
    background: rgba(255,169,77,.08);
    border: 1px solid rgba(255,169,77,.25);
    border-radius: var(--radius-sm);
    padding: 10px 14px; margin-bottom: 20px;
    font-size: .88rem; color: var(--warning);
}
.sender-status.connected {
    background: rgba(0,229,160,.08);
    border-color: rgba(0,229,160,.25);
    color: var(--success);
}
.sender-status.done {
    background: rgba(0,229,160,.08);
    border-color: rgba(0,229,160,.25);
    color: var(--success);
}

.pulse-ring {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 0 0 rgba(255,169,77,.4);
    animation: pulse 1.5s infinite;
    flex-shrink: 0;
}
.sender-status.connected .pulse-ring,
.sender-status.done .pulse-ring {
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(0,229,160,.4);
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255,169,77,.5); }
    70%  { box-shadow: 0 0 0 8px rgba(255,169,77,0); }
    100% { box-shadow: 0 0 0 0 rgba(255,169,77,0); }
}

.qr-layout {
    display: flex; align-items: center; gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
    margin-bottom: 20px;
}

.qr-wrapper {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}
#qrcode {
    background: #fff;
    padding: 12px; border-radius: var(--radius-sm);
    display: inline-block;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
#qrcode canvas, #qrcode img {
    display: block !important;
}
.qr-hint { font-size: .75rem; color: var(--text3); text-align: center; }

.qr-divider {
    display: flex; flex-direction: column; align-items: center;
    color: var(--text3); font-size: .8rem; gap: 6px;
}
.qr-divider::before, .qr-divider::after {
    content: ''; width: 1px; height: 30px;
    background: var(--border);
}

.code-section { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.code-label { font-size: .8rem; color: var(--text2); }
.code-display {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    min-width: 180px; text-align: center;
}
.code-chars {
    font-family: 'Courier New', monospace;
    font-size: 1.4rem; font-weight: 700;
    letter-spacing: 6px;
    color: var(--primary);
    display: block;
}
.copy-btn svg { width: 16px; height: 16px; }

/* -------- شريط التقدم -------- */
.progress-section {
    margin-top: 16px;
}
.progress-section.hidden { display: none; }
.progress-info {
    display: flex; justify-content: space-between;
    font-size: .82rem; color: var(--text2);
    margin-bottom: 6px;
}
.progress-track {
    height: 6px; background: var(--bg);
    border-radius: 99px; overflow: hidden;
}
.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 99px;
    width: 0%;
    transition: width .2s ease;
}
.progress-bar.recv {
    background: linear-gradient(90deg, var(--success), var(--secondary));
}
.progress-sub { font-size: .78rem; color: var(--text3); margin-top: 5px; text-align: center; }

/* -------- رسائل النجاح -------- */
.success-msg {
    display: flex; align-items: center; gap: 12px;
    background: rgba(0,229,160,.08);
    border: 1px solid rgba(0,229,160,.25);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-top: 14px;
    animation: fadeUp .3s ease;
}
.success-msg.hidden { display: none; }
.success-icon { font-size: 1.6rem; }
.success-title { font-weight: 600; color: var(--success); }
.success-sub { font-size: .8rem; color: var(--text2); margin-top: 2px; }

.expire-note {
    display: flex; align-items: center; gap: 6px;
    font-size: .78rem; color: var(--text3);
    margin-top: 14px;
}
.expire-note svg { width: 14px; height: 14px; flex-shrink: 0; }

/* -------- قسم الاستقبال -------- */
.receive-input-wrap { display: flex; flex-direction: column; gap: 12px; }
.code-input-group { display: flex; gap: 10px; }
.code-input {
    flex: 1;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text);
    font-size: 1rem; font-weight: 600;
    letter-spacing: 3px; text-align: center;
    font-family: 'Courier New', monospace;
    transition: border-color var(--trans);
    direction: ltr;
}
.code-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.code-input::placeholder { letter-spacing: 1px; font-weight: 400; font-family: inherit; color: var(--text3); }

.or-divider {
    display: flex; align-items: center; gap: 12px;
    color: var(--text3); font-size: .82rem;
}
.or-divider::before, .or-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}

/* -------- قسم الكاميرا -------- */
.camera-section { margin-top: 16px; animation: fadeUp .3s ease; }
.camera-section.hidden { display: none; }
.camera-wrapper {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    aspect-ratio: 1;
    max-height: 300px;
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 12px;
}
#cameraFeed {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.scan-frame {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
}
.scan-line {
    position: absolute;
    width: 70%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: scanMove 2s ease-in-out infinite;
    box-shadow: 0 0 8px var(--primary);
}
@keyframes scanMove {
    0%   { top: 15%; }
    50%  { top: 85%; }
    100% { top: 15%; }
}
.corner {
    position: absolute;
    width: 24px; height: 24px;
    border-color: var(--primary); border-style: solid;
}
.corner.tl { top: 12%; left: 15%;  border-width: 3px 0 0 3px; }
.corner.tr { top: 12%; right: 15%; border-width: 3px 3px 0 0; }
.corner.bl { bottom: 12%; left: 15%;  border-width: 0 0 3px 3px; }
.corner.br { bottom: 12%; right: 15%; border-width: 0 3px 3px 0; }
.camera-hint {
    position: absolute; bottom: 10px;
    font-size: .78rem; color: rgba(255,255,255,.7);
    background: rgba(0,0,0,.5); padding: 4px 10px; border-radius: 99px;
}

/* -------- بطاقة الاستقبال -------- */
.receive-progress-wrap { text-align: center; }
.connect-anim {
    display: flex; align-items: center; justify-content: center; gap: 6px;
    margin-bottom: 14px;
}
.connect-circle {
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--primary); opacity: .3;
    animation: bounce 1.2s ease infinite;
}
.connect-circle.c2 { animation-delay: .2s; }
.connect-circle.c3 { animation-delay: .4s; }
@keyframes bounce {
    0%,100% { transform: scale(1); opacity: .3; }
    50%      { transform: scale(1.5); opacity: 1; }
}
.receive-status-text { font-size: .95rem; color: var(--text2); margin-bottom: 16px; }

/* -------- معلومات الملف المستقبَل -------- */
.received-file-info {
    display: flex; align-items: center; gap: 14px;
    background: var(--card2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-bottom: 18px;
}
.recv-file-icon { font-size: 2.5rem; }
.recv-file-name { font-size: .95rem; font-weight: 600; word-break: break-all; }
.recv-file-meta { font-size: .8rem; color: var(--text2); margin-top: 3px; }

.save-section { display: flex; flex-direction: column; gap: 10px; }
.save-hint {
    display: flex; align-items: center; gap: 6px;
    font-size: .82rem; color: var(--text2);
}
.save-hint svg { width: 14px; height: 14px; flex-shrink: 0; color: var(--secondary); }

/* -------- Toast -------- */
.toast {
    position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
    background: var(--card2);
    border: 1px solid var(--border);
    border-radius: 99px;
    padding: 12px 22px;
    display: flex; align-items: center; gap: 8px;
    font-size: .88rem;
    box-shadow: 0 8px 30px rgba(0,0,0,.5);
    z-index: 9999;
    min-width: 220px; text-align: center; justify-content: center;
    animation: toastIn .3s ease;
    direction: rtl;
}
.toast.hidden { display: none; }
.toast.success { border-color: rgba(0,229,160,.4); color: var(--success); }
.toast.error   { border-color: rgba(255,77,109,.4); color: var(--danger); }
.toast.info    { border-color: rgba(108,99,255,.4); color: var(--primary); }
@keyframes toastIn {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* -------- Responsive -------- */
@media (max-width: 480px) {
    .qr-layout { flex-direction: column; }
    .qr-divider { flex-direction: row; }
    .qr-divider::before, .qr-divider::after {
        width: 30px; height: 1px;
    }
    .code-input-group { flex-direction: column; }
    .card { padding: 18px; }
    .code-chars { font-size: 1.2rem; letter-spacing: 4px; }
    header { padding: 12px 16px; }
}