/* --- الإعدادات الأساسية والتصميم العام --- */
body {
    margin: 0;
    font-family: 'Tajawal', sans-serif; /* استخدام الخط العربي الجميل */
    background-color: #0a041f; /* خلفية أزرق ليلي داكن */
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; /* لإخفاء أي أجزاء زائدة من الخلفية المتحركة */
}

/* --- Loader for Joiner UI --- */
.loader {
    border: 5px solid #f3f3f3; /* Light grey */
    border-top: 5px solid #3a7bd5; /* Blue */
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 30px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* --- التصميم الزجاجي (Glassmorphism) --- */
.glass-container {
    width: 90%;
    max-width: 400px;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    text-align: center;
    z-index: 2; /* للتأكد من أنه فوق الخلفية */
}

/* --- تصميم محتويات الحاوية --- */
.app-header h1 {
    margin: 0;
    font-size: 2.5rem;
    color: #ffffff;
    font-weight: 700;
}

.app-header p {
    margin-top: 5px;
    color: #c0c0c0;
}

.qr-code-placeholder {
    width: 200px;
    height: 200px;
    background-color: #ffffff;
    border-radius: 10px;
    margin: 30px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: #333;
}
 
.action-button {
    background: linear-gradient(90deg, #00d2ff 0%, #3a7bd5 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.action-button:hover {
    transform: scale(1.05);
}

/* --- الخلفية المتحركة (لإضافة لمسة جمالية) --- */
.background-animation {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(58,123,213,0.3) 0%, rgba(10,4,31,0) 60%);
    animation: rotate 20s linear infinite;
    z-index: 1;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Styling for Transfer UI --- */
#messages {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 10px;
    height: 150px;
    overflow-y: auto;
    text-align: right;
    margin-bottom: 20px;
}

#messages p {
    margin: 5px;
    padding: 8px;
    border-radius: 8px;
    max-width: 80%;
    word-wrap: break-word;
}

#messages .sent {
    background-color: #3a7bd5;
    margin-left: auto;
}

#messages .received {
    background-color: #4a4a4a;
    margin-right: auto;
}

.message-input-container {
    display: flex;
    gap: 10px;
}

#msg-input {
    flex-grow: 1;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: transparent;
    color: white;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 1rem;
}

#send-btn {
    background: #00d2ff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
}

/* --- Styling for File Transfer UI --- */
#transfer-container {
    width: 100%;
    transition: opacity 0.5s ease;
}

#drop-zone {
    border: 3px dashed rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 50px 20px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#drop-zone.drag-over {
    background-color: rgba(0, 210, 255, 0.2);
    border-color: rgba(0, 210, 255, 0.8);
}

#drop-zone p {
    margin: 0;
    font-size: 1.2rem;
    pointer-events: none; /* لمنع النص من اعتراض أحداث السحب */
}

#file-input {
    display: none; /* إخفاء حقل الإدخال الفعلي */
}

/* --- تصميم قسم حالة النقل --- */
#transfer-status {
    margin-top: 20px;
    height: 120px; /* ارتفاع ثابت لمنع اهتزاز الواجهة */
    overflow-y: auto;
}

.file-progress {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    text-align: left;
}

.file-progress .file-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-inner {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00d2ff 0%, #3a7bd5 100%);
    transition: width 0.2s linear;
}

/* --- الإعدادات الأساسية والتصميم العام --- */
body {
    margin: 0;
    font-family: 'Tajawal', sans-serif;
    background-color: #0a041f;
    color: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
}

/* --- Loader for Joiner UI --- */
.loader {
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3a7bd5;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 30px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* --- التصميم الزجاجي (Glassmorphism) --- */
.glass-container {
    width: 90%;
    max-width: 400px;
    padding: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    text-align: center;
    z-index: 2;
    transition: all 0.3s ease; /* إضافة انتقال ناعم */
}

/* --- تصميم محتويات الحاوية --- */
.app-header h1 {
    margin: 0;
    font-size: 2.5rem;
    color: #ffffff;
    font-weight: 700;
}

.app-header p {
    margin-top: 5px;
    color: #c0c0c0;
    font-size: 1rem;
    min-height: 20px; /* لمنع اهتزاز الواجهة عند تغير النص */
}
/* --- تحسين: حالة الاتصال --- */
.connection-status.success { color: #4caf50; }
.connection-status.error { color: #ff6b6b; }


.qr-code-placeholder {
    width: 200px;
    height: 200px;
    background-color: #ffffff;
    border-radius: 10px;
    margin: 30px auto;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.8rem;
    color: #333;
}
 
.action-button {
    background: linear-gradient(90deg, #00d2ff 0%, #3a7bd5 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-top: 10px;
}

.action-button:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 20px rgba(0, 210, 255, 0.3);
}

/* --- تحسين: زر ثانوي --- */
.action-button.secondary {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.4);
}
.action-button.secondary:hover {
    background: rgba(255, 255, 255, 0.3);
    box-shadow: none;
}


/* --- الخلفية المتحركة --- */
.background-animation {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(58,123,213,0.3) 0%, rgba(10,4,31,0) 60%);
    animation: rotate 20s linear infinite;
    z-index: 1;
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}


/* --- Styling for File Transfer UI --- */
#transfer-container {
    width: 100%;
    transition: opacity 0.5s ease;
}

#drop-zone {
    border: 3px dashed rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    padding: 50px 20px;
    cursor: pointer;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

#drop-zone.drag-over {
    background-color: rgba(0, 210, 255, 0.2);
    border-color: rgba(0, 210, 255, 0.8);
}

#drop-zone p {
    margin: 0;
    font-size: 1.2rem;
    pointer-events: none;
}

#file-input {
    display: none;
}

/* --- تصميم قسم حالة النقل --- */
#transfer-status {
    margin-top: 20px;
    min-height: 100px; /* ارتفاع أدنى لمنع اهتزاز الواجهة */
    overflow-y: auto;
}

.file-progress {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 10px;
    text-align: left;
}

.file-progress .file-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: bold;
}
.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-inner {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #00d2ff 0%, #3a7bd5 100%);
    transition: width 0.2s linear;
}
/* --- تحسين: ألوان لحالات مختلفة --- */
.progress-bar-inner.success { background: linear-gradient(90deg, #43e97b 0%, #38f9d7 100%); }
.progress-bar-inner.error { background: #ff6b6b; }


.file-progress .status-text {
    font-size: 0.8rem;
    margin-top: 5px;
    color: #c0c0c0;
}

.file-progress .status-text.success {
    color: #4caf50;
    font-weight: bold;
}
.file-progress .status-text.error {
    color: #ff6b6b;
    font-weight: bold;
}

.file-progress .status-text {
    font-size: 0.8rem;
    margin-top: 5px;
    color: #c0c0c0;
}

.file-progress .status-text.success {
    color: #4caf50;
    font-weight: bold;
}