* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 50%, #7e22ce 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 10px;
}

.viewer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  background: rgba(255, 255, 255, 0.95);
  padding: 15px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 1400px;
  height: auto;
  min-height: 85vh;
}

#mediaContainer {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.media {
  max-width: 100%;
  max-height: 85vh;
  width: auto;
  height: auto;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 18px 28px;
  font-size: 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  font-weight: bold;
  min-width: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

button:hover {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  transform: scale(1.08);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

button:active {
  transform: scale(0.95);
}

#mediaName {
  text-align: center;
  color: #555;
  font-size: 16px;
  margin-top: 15px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Grid للوحة التحكم */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 25px;
  margin-top: 30px;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid div {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.grid div:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 30px rgba(102, 126, 234, 0.3);
  border-color: #667eea;
}

.grid img, .grid video {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  transition: transform 0.3s ease;
}

.grid div:hover img,
.grid div:hover video {
  transform: scale(1.05);
}

.grid p {
  font-size: 13px;
  color: #666;
  margin: 10px 0;
  font-weight: 500;
}

/* لوحة التحكم */
h2 {
  color: #2c3e50;
  margin-bottom: 20px;
  text-align: center;
  font-size: 28px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  padding: 20px;
  border-radius: 12px;
  border-left: 5px solid #667eea;
}

.add-btn {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  padding: 14px 30px;
  text-decoration: none;
  border-radius: 10px;
  color: white;
  font-weight: bold;
  transition: all 0.3s ease;
  display: inline-block;
  box-shadow: 0 5px 15px rgba(16, 185, 129, 0.4);
  font-size: 16px;
}

.add-btn:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(16, 185, 129, 0.6);
}

/* فورم الإضافة */
form {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  padding: 40px;
  border-radius: 16px;
  max-width: 550px;
  margin: 40px auto;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
  border: 2px solid rgba(102, 126, 234, 0.1);
}

form h2 {
  text-align: center;
  margin-bottom: 30px;
  font-size: 24px;
}

form label {
  display: block;
  margin-top: 20px;
  margin-bottom: 8px;
  color: #2c3e50;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.5px;
}

form input[type="text"],
form input[type="file"],
form select {
  width: 100%;
  padding: 12px 15px;
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 15px;
  transition: all 0.3s ease;
  background: white;
}

form input[type="text"]:focus,
form input[type="file"]:focus,
form select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

form input[type="submit"] {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 14px 30px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: bold;
  width: 100%;
  transition: all 0.3s ease;
  font-size: 16px;
  margin-top: 20px;
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

form input[type="submit"]:hover {
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6);
}

/* رسائل الخطأ والنجاح */
div[style*="background: #fee"] {
  border-left: 5px solid #dc3545 !important;
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.1) 0%, rgba(220, 53, 69, 0.05) 100%) !important;
  color: #721c24 !important;
  border-color: #f5c6cb !important;
}

div[style*="background: #efe"] {
  border-left: 5px solid #28a745 !important;
  background: linear-gradient(135deg, rgba(40, 167, 69, 0.1) 0%, rgba(40, 167, 69, 0.05) 100%) !important;
  color: #155724 !important;
  border-color: #c3e6cb !important;
}

/* رسالة عدم وجود محتويات */
p {
  text-align: center;
  color: #999;
}

/* Responsive للأجهزة الصغيرة */
@media (max-width: 1024px) {
  .viewer {
    flex-direction: column;
    min-height: auto;
    padding: 15px;
  }

  #mediaContainer {
    width: 100%;
    min-height: 60vh;
    max-height: 70vh;
  }

  .media {
    max-height: 60vh;
  }

  button {
    padding: 14px 20px;
    font-size: 18px;
    min-width: 50px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
  }

  .grid img, .grid video {
    height: 140px;
  }
}

@media (max-width: 768px) {
  body {
    padding: 8px;
  }

  .viewer {
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  #mediaContainer {
    min-height: 50vh;
    max-height: 60vh;
    padding: 15px;
  }

  .media {
    max-height: 50vh;
  }

  button {
    padding: 12px 18px;
    font-size: 16px;
    min-width: 45px;
  }

  #mediaName {
    font-size: 14px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 20px;
  }

  .grid div {
    padding: 12px;
  }

  .grid img, .grid video {
    height: 120px;
    margin-bottom: 8px;
  }

  .grid p {
    font-size: 11px;
  }

  form {
    padding: 25px;
    margin: 20px 15px;
  }

  .admin-header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  h2 {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 5px;
  }

  .viewer {
    gap: 8px;
    padding: 8px;
  }

  #mediaContainer {
    min-height: 45vh;
    max-height: 55vh;
    padding: 10px;
  }

  .media {
    max-height: 45vh;
  }

  button {
    padding: 10px 15px;
    font-size: 14px;
    min-width: 40px;
  }

  #mediaName {
    font-size: 12px;
    margin-top: 10px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 15px;
  }

  .grid div {
    padding: 10px;
  }

  .grid img, .grid video {
    height: 100px;
    margin-bottom: 6px;
  }

  .grid p {
    font-size: 10px;
    margin: 8px 0;
  }

  form {
    padding: 20px;
    margin: 15px 10px;
    border-radius: 12px;
  }

  form label {
    margin-top: 15px;
  }

  .add-btn {
    padding: 12px 20px;
    font-size: 14px;
  }

  h2 {
    font-size: 18px;
  }
}


/* Grid للوحة التحكم */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 25px;
  margin-top: 30px;
  animation: slideUp 0.5s ease;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.grid div {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  padding: 18px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  text-align: center;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

.grid div:hover {
  transform: translateY(-8px);
  box-shadow: 0 12px 30px rgba(102, 126, 234, 0.3);
  border-color: #667eea;
}

.grid img, .grid video {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 12px;
  transition: transform 0.3s ease;
}

.grid div:hover img,
.grid div:hover video {
  transform: scale(1.05);
}

.grid p {
  font-size: 13px;
  color: #666;
  margin: 10px 0;
  font-weight: 500;
}

/* لوحة التحكم */
h2 {
  color: #2c3e50;
  margin-bottom: 20px;
  text-align: center;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.add-btn {
  background: #28a745;
  padding: 12px 24px;
  text-decoration: none;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  transition: all 0.3s ease;
  display: inline-block;
}

.add-btn:hover {
  background: #218838;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

/* فورم الإضافة */
form {
  background: white;
  padding: 30px;
  border-radius: 8px;
  max-width: 500px;
  margin: 30px auto;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

form label {
  display: block;
  margin-top: 15px;
  margin-bottom: 5px;
  color: #333;
  font-weight: 500;
}

form input[type="text"],
form input[type="file"],
form select {
  width: 100%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  margin-bottom: 15px;
}

form input[type="text"]:focus,
form input[type="file"]:focus,
form select:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 5px rgba(102, 126, 234, 0.3);
}

form input[type="submit"] {
  background: #667eea;
  color: white;
  padding: 12px 30px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  width: 100%;
  transition: all 0.3s ease;
}

form input[type="submit"]:hover {
  background: #764ba2;
}

/* رسالة عدم وجود محتويات */
p {
  text-align: center;
  color: #999;
}

/* Responsive */
@media (max-width: 768px) {
  .viewer {
    flex-direction: column;
    gap: 20px;
    padding: 20px;
  }

  #mediaContainer {
    min-width: 100%;
    min-height: 300px;
  }

  .media {
    max-height: 300px;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}
