/* =========================================
   نور السلم - عمارة 295 - التنسيقات
   ========================================= */

:root {
  --primary: #1a237e;
  --primary-light: #5c6bc0;
  --primary-glow: rgba(26, 35, 126, 0.15);
  --success: #2e7d32;
  --success-light: #a5d6a7;
  --success-bg: #e8f5e9;
  --danger: #c62828;
  --danger-light: #ef9a9a;
  --danger-bg: #ffebee;
  --warning: #f57f17;
  --warning-bg: #fff8e1;
  --gold: #ffd54f;
  --gray: #757575;
  --gray-light: #f5f5f5;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', 'Tahoma', Arial, sans-serif;
  background: linear-gradient(135deg, #0a0e27 0%, #12163a 30%, #1a1f4e 60%, #0d1233 100%);
  color: #e0e0e0;
  padding-bottom: 80px;
  margin: 0;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ========== خلفية متحركة - تأثيرات الإضاءة والكهرباء ========== */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(255, 215, 0, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(100, 181, 246, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(255, 235, 59, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* برق (lightning) flashes */
@keyframes lightningFlash {
  0%, 100% { opacity: 0; }
  0.5% { opacity: 0.08; }
  1% { opacity: 0; }
  2% { opacity: 0.03; }
  2.5% { opacity: 0; }
}

body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.05), rgba(100,181,246,0.03));
  pointer-events: none;
  z-index: 0;
  animation: lightningFlash 8s ease-in-out infinite;
}

/* جزيئات كهربائية عائمة */
@keyframes floatParticle {
  0% { transform: translateY(0) translateX(0) scale(1); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translateY(-100vh) translateX(50px) scale(0); opacity: 0; }
}

@keyframes floatParticle2 {
  0% { transform: translateY(0) translateX(0) scale(0.5); opacity: 0; }
  10% { opacity: 0.4; }
  90% { opacity: 0.4; }
  100% { transform: translateY(-80vh) translateX(-30px) scale(1.5); opacity: 0; }
}

.particle-container {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.6), transparent);
  width: 4px;
  height: 4px;
  animation: floatParticle 6s ease-in-out infinite;
  box-shadow: 0 0 6px rgba(255, 215, 0, 0.3), 0 0 12px rgba(255, 215, 0, 0.1);
}

.particle:nth-child(2n) {
  width: 3px; height: 3px;
  background: radial-gradient(circle, rgba(100, 181, 246, 0.5), transparent);
  box-shadow: 0 0 8px rgba(100, 181, 246, 0.3);
  animation: floatParticle2 8s ease-in-out infinite;
  animation-delay: 2s;
}

.particle:nth-child(3n) {
  width: 5px; height: 5px;
  background: radial-gradient(circle, rgba(255, 235, 59, 0.5), transparent);
  box-shadow: 0 0 10px rgba(255, 235, 59, 0.2);
  animation: floatParticle 10s ease-in-out infinite;
  animation-delay: 4s;
}

.particle:nth-child(4n) {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4), transparent);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
  animation: floatParticle2 7s ease-in-out infinite;
  animation-delay: 1s;
}

/* الصفحة الرئيسية والبطاقات فوق الخلفية */
.app-header, .stats-row, .floor-section, .form-section, .bottom-nav {
  position: relative;
  z-index: 1;
}

/* ========== بطاقات شفافة ========== */
.stat-card, .floor-section, .form-card, .payment-item, .apartment-card {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.apartment-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.floor-header {
  background: rgba(255, 255, 255, 0.08);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #ffd54f;
}

.floor-apartments {
  background: rgba(255, 255, 255, 0.03);
  gap: 1px;
}

.stat-card .stat-label,
.apartment-card .apt-name,
.apartment-card .paid-date {
  color: rgba(255, 255, 255, 0.6);
}

.apt-name {
  color: rgba(255, 255, 255, 0.6) !important;
}

.floor-header i {
  color: #ffd54f;
}

.app-header {
  background: linear-gradient(135deg, rgba(13, 18, 51, 0.95), rgba(26, 35, 126, 0.9), rgba(44, 62, 144, 0.85));
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 215, 0, 0.15);
}

.bottom-nav {
  background: rgba(10, 14, 39, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.bottom-nav a {
  color: rgba(255, 255, 255, 0.5);
}

.bottom-nav a.active,
.bottom-nav a:hover {
  color: #ffd54f;
}

.bottom-nav a.active::after {
  background: #ffd54f;
}

.form-card input[type="file"] {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
}

.form-card select,
.form-card input[type="text"] {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.form-card select option {
  background: #12163a;
  color: white;
}

.form-card select:focus,
.form-card input[type="text"]:focus {
  border-color: #ffd54f;
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.1);
}

.form-card label {
  color: rgba(255, 255, 255, 0.8);
}

.form-card h3 {
  color: #ffd54f;
}

.payment-item {
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.payment-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.toast-message {
  background: rgba(20, 20, 40, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-apt-item {
  background: rgba(255, 255, 255, 0.04);
}

.admin-apt-item input {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.9);
}

.admin-apt-item input:focus {
  border-color: #ffd54f;
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.1);
}

#cycleInfo, #amountDisplay {
  color: rgba(255, 255, 255, 0.6) !important;
}

/* ========== الأنيميشن ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes glow {
  0%, 100% { box-shadow: 0 0 8px rgba(26,35,126,0.2); }
  50% { box-shadow: 0 0 20px rgba(26,35,126,0.4); }
}

/* ========== الهيدر ========== */
.app-header {
  background: linear-gradient(135deg, var(--primary), #283593, var(--primary-light));
  color: white;
  padding: 24px 16px 20px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(26, 35, 126, 0.25);
}

.app-header h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.app-header h1 i {
  animation: float 3s ease-in-out infinite;
}

.app-header p {
  font-size: 13px;
  opacity: 0.9;
  margin: 6px 0 0 0;
}

/* ========== الإحصائيات ========== */
.stats-row {
  display: flex;
  gap: 10px;
  padding: 16px;
  margin: -8px auto 0;
  max-width: 500px;
  animation: fadeInUp 0.5s ease-out;
}

.stat-card {
  flex: 1;
  background: white;
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: all 0.3s ease;
  cursor: default;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.stat-card .stat-number {
  font-size: 26px;
  font-weight: 800;
  display: block;
  transition: all 0.3s;
}

.stat-card .stat-label {
  font-size: 12px;
  color: var(--gray);
  margin-top: 2px;
  font-weight: 500;
}

.stat-card.paid .stat-number { color: var(--success); }
.stat-card.unpaid .stat-number { color: var(--danger); }
.stat-card.total .stat-number { color: var(--primary); }

/* ========== باند المتبقي ========== */
@keyframes slideInBanner {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.unpaid-banner {
  animation: slideInBanner 0.4s ease-out;
}

/* ========== أقسام الأدوار ========== */
.floor-section {
  margin: 12px 16px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: fadeInUp 0.5s ease-out;
  transition: all 0.3s;
}

.floor-section:hover {
  box-shadow: var(--shadow);
}

.floor-header {
  background: linear-gradient(135deg, var(--gray-light), #eef0f4);
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  border-bottom: 1px solid #e8e8e8;
}

.floor-apartments {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: #e8e8e8;
}

/* ========== بطاقة الشقة ========== */
.apartment-card {
  background: white;
  padding: 14px 8px 12px;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  cursor: pointer;
}

.apartment-card:hover {
  background: #fafbfc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  z-index: 1;
}

.apartment-card .apt-number {
  font-size: 20px;
  font-weight: 800;
  color: var(--primary);
  transition: all 0.3s;
}

.apartment-card:hover .apt-number {
  color: var(--primary-light);
}

.apartment-card .apt-name {
  font-size: 12px;
  color: var(--gray);
  margin: 2px 0 8px;
  min-height: 18px;
}

.apartment-card .status-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  transition: all 0.3s;
}

.apartment-card .status-badge.paid {
  background: var(--success-bg);
  color: var(--success);
  box-shadow: 0 0 0 1px var(--success-light);
}

.apartment-card .status-badge.unpaid {
  background: var(--danger-bg);
  color: var(--danger);
  animation: pulse 2s ease-in-out infinite;
  box-shadow: 0 0 0 1px var(--danger-light);
}

.apartment-card .paid-date {
  font-size: 10px;
  color: var(--gray);
  margin-top: 4px;
}

.apartment-card .receipt-link {
  display: inline-block;
  font-size: 11px;
  color: var(--primary-light);
  text-decoration: none;
  margin-top: 4px;
  padding: 2px 8px;
  border-radius: 12px;
  transition: all 0.3s;
}

.apartment-card .receipt-link:hover {
  background: rgba(92, 107, 192, 0.1);
  text-decoration: none;
  transform: scale(1.05);
}

/* ========== الأزرار السفلية ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav a {
  flex: 1;
  text-align: center;
  padding: 10px 4px 8px;
  color: var(--gray);
  text-decoration: none;
  font-size: 11px;
  transition: all 0.3s;
  position: relative;
}

.bottom-nav a::after {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 3px 3px;
  transition: width 0.3s;
}

.bottom-nav a.active::after {
  width: 60%;
}

.bottom-nav a:hover,
.bottom-nav a.active {
  color: var(--primary);
}

.bottom-nav a i {
  display: block;
  font-size: 22px;
  margin-bottom: 2px;
  transition: all 0.3s;
}

.bottom-nav a.active i {
  transform: translateY(-2px);
}

/* ========== الفورم ========== */
.form-section {
  max-width: 480px;
  margin: 20px auto;
  padding: 0 16px;
  animation: fadeInUp 0.4s ease-out;
}

.form-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px 20px;
  transition: all 0.3s;
}

.form-card:hover {
  box-shadow: var(--shadow);
}

.form-card h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--primary);
}

.form-card label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  display: block;
  color: #444;
}

.form-card .required::after {
  content: ' *';
  color: var(--danger);
}

.form-card select,
.form-card input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.3s;
  margin-bottom: 16px;
  background: white;
}

.form-card select:focus,
.form-card input[type="text"]:focus {
  border-color: var(--primary-light);
  outline: none;
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.form-card input[type="file"] {
  width: 100%;
  padding: 10px;
  border: 2px dashed #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.3s;
  margin-bottom: 16px;
  background: #fafafa;
  cursor: pointer;
}

.form-card input[type="file"]:hover {
  border-color: var(--primary-light);
  background: #f0f2ff;
}

.btn-submit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--success), #1b5e20);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(46, 125, 50, 0.3);
}

.btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(46, 125, 50, 0.4);
}

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

.btn-submit:disabled {
  background: #a5d6a7;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* ========== معاينة الصورة ========== */
.receipt-preview {
  margin: 10px 0 16px;
  text-align: center;
  display: none;
  animation: scaleIn 0.3s ease-out;
}

.receipt-preview img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
  border: 3px solid #e0e0e0;
  box-shadow: var(--shadow-sm);
}

/* ========== السجل ========== */
.payment-container {
  max-width: 500px;
  margin: 0 auto 80px;
  animation: fadeInUp 0.4s ease-out;
}

.payment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border-bottom: 1px solid #f0f0f0;
  transition: all 0.3s;
  animation: fadeIn 0.3s ease-out;
}

.payment-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.payment-item:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.payment-item:hover {
  background: #fafbfc;
}

.payment-item .pi-apt {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  min-width: 50px;
}

.payment-item .pi-info {
  flex: 1;
}

.payment-item .pi-info .pi-name {
  font-size: 14px;
  font-weight: 600;
}

.payment-item .pi-info .pi-date {
  font-size: 11px;
  color: var(--gray);
}

.payment-item .pi-receipt {
  color: var(--primary-light);
  text-decoration: none;
  font-size: 20px;
  transition: all 0.3s;
  padding: 6px;
  border-radius: 50%;
}

.payment-item .pi-receipt:hover {
  background: rgba(92, 107, 192, 0.1);
  transform: scale(1.15);
}

/* ========== الإعدادات ========== */
.admin-apt-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: white;
  border-bottom: 1px solid #f0f0f0;
  transition: all 0.3s;
}

.admin-apt-item:hover {
  background: #fafbfc;
}

.admin-apt-item:first-child {
  border-radius: var(--radius) var(--radius) 0 0;
}

.admin-apt-item:last-child {
  border-bottom: none;
  border-radius: 0 0 var(--radius) var(--radius);
}

.admin-apt-item .admin-apt-num {
  font-weight: 700;
  min-width: 40px;
  color: var(--primary);
  font-size: 15px;
}

.admin-apt-item input {
  flex: 1;
  padding: 8px 10px;
  border: 2px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all 0.3s;
}

.admin-apt-item input:focus {
  border-color: var(--primary-light);
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ========== مؤشر التحميل ========== */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
  animation: fadeIn 0.5s;
}

.loading .spinner {
  display: inline-block;
  width: 44px;
  height: 44px;
  border: 4px solid #e0e0e0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

.loading p {
  margin-top: 16px;
  font-size: 14px;
}

/* ========== الإشعارات ========== */
.toast-message {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #333;
  color: white;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 999;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 90%;
  text-align: center;
  pointer-events: none;
  box-shadow: var(--shadow-lg);
}

.toast-message.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-message.success {
  background: var(--success);
}

.toast-message.error {
  background: var(--danger);
}

/* ========== نافذة عرض الإيصال ========== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease-out;
}

.modal-overlay.show {
  display: flex;
}

.modal-overlay img {
  max-width: 92%;
  max-height: 90%;
  border-radius: var(--radius-sm);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  animation: scaleIn 0.3s ease-out;
}

.modal-overlay .close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  color: white;
  font-size: 32px;
  cursor: pointer;
  background: rgba(0,0,0,0.3);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s;
}

.modal-overlay .close-modal:hover {
  background: rgba(255,255,255,0.2);
  transform: rotate(90deg);
}

/* ========== صفحة التأكيد ========== */
.success-page {
  text-align: center;
  padding: 50px 20px;
  animation: scaleIn 0.5s ease-out;
}

.success-page .success-icon {
  font-size: 72px;
  color: var(--success);
  animation: float 3s ease-in-out infinite;
}

.success-page h2 {
  margin: 16px 0 10px;
  color: var(--success);
  font-size: 24px;
}

.success-page p {
  color: var(--gray);
  margin-bottom: 30px;
}

/* ========== توافق الموبايل ========== */
@media (min-width: 600px) {
  .floor-apartments {
    grid-template-columns: repeat(4, 1fr);
  }

  .app-header h1 {
    font-size: 28px;
  }

  .stats-row {
    max-width: 600px;
  }
}

@media (min-width: 900px) {
  .container-main {
    max-width: 800px;
    margin: 0 auto;
  }
  .stats-row {
    max-width: 800px;
  }
}
