/* Reset & Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #f59e0b;
  --secondary-color: #0ea5e9;
  --dark-color: #1e293b;
  --light-color: #f8fafc;
  --text-color: #334155;
  --border-color: #e2e8f0;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--light-color);
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
  padding: 20px;
}

.login-box {
  background-color: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 3rem;
  width: 100%;
  max-width: 450px;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-header h1 {
  font-size: 2rem;
  color: var(--dark-color);
  margin-bottom: 0.5rem;
}

.login-header p {
  color: var(--text-color);
  opacity: 0.8;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 600;
  color: var(--dark-color);
}

.form-group input,
.form-group textarea {
  padding: 0.875rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Form select styling for better mobile support */
.form-group select {
  padding: 0.875rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  background-color: #fff;
  cursor: pointer;
  transition: border-color 0.3s;
  color: var(--text-color);
}

.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
}

.form-group small {
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.875rem;
}

.error-message {
  color: var(--danger-color);
  font-size: 0.875rem;
  min-height: 20px;
}

.btn {
  padding: 0.875rem 2rem;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s;
  border: none;
  cursor: pointer;
  font-size: 1rem;
}

.btn-primary {
  background-color: var(--primary-color);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background-color: #d97706;
}

.btn-secondary {
  background-color: var(--border-color);
  color: var(--text-color);
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

.login-footer {
  margin-top: 2rem;
  text-align: center;
}

.login-footer p {
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.login-footer a {
  color: var(--secondary-color);
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

/* Dashboard Layout */
.dashboard-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--dark-color);
  color: #fff;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 2rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.sidebar-header p {
  opacity: 0.7;
  font-size: 0.875rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  color: #fff;
  text-decoration: none;
  transition: background-color 0.3s;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
  background-color: var(--primary-color);
}

.nav-icon {
  font-size: 1.25rem;
}

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-logout {
  width: 100%;
  background-color: var(--danger-color);
  color: #fff;
}

.btn-logout:hover {
  background-color: #dc2626;
}

/* Main Content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.dashboard-header {
  background-color: #fff;
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-header h1 {
  font-size: 1.75rem;
  color: var(--dark-color);
}

.user-info {
  color: var(--text-color);
}

.content-section {
  padding: 2rem;
}

.section-actions {
  margin-bottom: 2rem;
}

#userFormContainer .modal-container {
    width: 100%;
    max-width: none;   /* remove default limit */
}

#userFormContainer .modal-content {
    width: 100%;
}

#userForm {
    width: 100%;
}

#userForm .form-group input {
    width: 100%;      /* make all inputs fill the container */
    box-sizing: border-box;
}

/* Product Form */
.product-form-container {
  background-color: #fff;
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.form-header h2 {
  color: var(--dark-color);
}

.btn-close {
  background: none;
  border: none;
  font-size: 2rem;
  color: var(--text-color);
  cursor: pointer;
  line-height: 1;
}

.btn-close:hover {
  color: var(--danger-color);
}

.product-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.form-actions {
  display: flex;
  gap: 1rem;
}

.form-actions .btn {
  flex: 1;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-color);
}

/* Added styles for multiple image upload and preview */
.image-upload-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.upload-hint {
  text-align: center;
  color: var(--text-color);
  opacity: 0.7;
  font-size: 0.875rem;
  margin: 0;
}

.image-preview-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.image-preview-item {
  position: relative;
  width: 100%;
  height: 120px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-color);
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 28px;
  height: 28px;
  background-color: var(--danger-color);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  line-height: 1;
  transition: background-color 0.3s;
}

.image-preview-remove:hover {
  background-color: #dc2626;
}

.image-url-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.image-url-input {
  padding: 0.875rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

.image-url-input:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Products Table */
.products-table-container {
  background-color: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.products-table {
  width: 100%;
  border-collapse: collapse;
}

.products-table thead {
  background-color: var(--light-color);
}

.products-table th {
  padding: 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--dark-color);
  border-bottom: 2px solid var(--border-color);
}

.products-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.product-image-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
}

.product-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-edit,
.btn-delete {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all 0.3s;
}

.btn-edit {
  background-color: var(--secondary-color);
  color: #fff;
}

.btn-edit:hover {
  background-color: #0284c7;
}

.btn-delete {
  background-color: var(--danger-color);
  color: #fff;
}

.btn-delete:hover {
  background-color: #dc2626;
}

/* Settings */
.settings-container {
  background-color: #fff;
  border-radius: 12px;
  padding: 2rem;
  box-shadow: var(--shadow);
  max-width: 600px;
}

.settings-container h2 {
  color: var(--dark-color);
  margin-bottom: 1.5rem;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Admin Custom Modals */
.admin-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: adminFadeIn 0.2s ease-out;
}

.admin-modal-overlay.active {
  display: flex;
}

.admin-modal {
  background-color: #fff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 450px;
  width: 90%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  animation: adminSlideUp 0.3s ease-out;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.admin-modal-icon {
  font-size: 3rem;
  text-align: center;
  margin-bottom: 0.5rem;
}

.admin-modal-icon-info {
  filter: grayscale(0);
}

.admin-modal-icon-warning {
  filter: grayscale(0);
}

.admin-modal-content {
  text-align: center;
}

.admin-modal-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--dark-color);
  margin-bottom: 0.75rem;
}

.admin-modal-message {
  font-size: 1rem;
  color: var(--text-color);
  line-height: 1.6;
}

.admin-modal-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

.admin-modal-actions .btn {
  flex: 1;
  padding: 0.875rem 1.5rem;
}

.admin-modal-alert .admin-modal-actions {
  justify-content: center;
}

.admin-modal-alert .admin-modal-actions .btn {
  min-width: 120px;
}

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

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

/* Added profile image preview styling for round avatars in testimonials and news */
.profile-image-preview {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.profile-image-preview-item {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--primary-color);
  background-color: var(--light-color);
}

.profile-image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.testimonial-image-preview {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.testimonial-image-preview .image-preview-item {
  width: 120px;
  height: 120px;
}

/* Responsive Design */
@media (max-width: 768px) {
  .dashboard-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  /* Added horizontal scrolling for tables on mobile */
  .products-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .products-table {
    font-size: 0.875rem;
    min-width: 600px;
  }

  .products-table th,
  .products-table td {
    padding: 0.75rem 0.5rem;
  }

  .product-image-thumb {
    width: 40px;
    height: 40px;
  }

  .image-preview-container {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .image-preview-item {
    height: 100px;
  }

  .admin-modal {
    max-width: 90%;
    padding: 1.5rem;
  }

  .admin-modal-icon {
    font-size: 2.5rem;
  }

  .admin-modal-title {
    font-size: 1.25rem;
  }

  .admin-modal-message {
    font-size: 0.9375rem;
  }

  .admin-modal-actions {
    flex-direction: column;
  }

  .admin-modal-actions .btn {
    width: 100%;
  }
}

/* Extra small devices (mobile phones) optimization */
@media (max-width: 480px) {
  .dashboard-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .dashboard-header h1 {
    font-size: 1.5rem;
  }

  .products-table {
    min-width: 500px;
    font-size: 0.75rem;
  }

  .products-table th,
  .products-table td {
    padding: 0.5rem 0.25rem;
  }

  .product-image-thumb {
    width: 35px;
    height: 35px;
  }

  .btn-edit,
  .btn-delete {
    padding: 0.4rem 0.75rem;
    font-size: 0.75rem;
  }

  .product-actions {
    flex-direction: column;
    gap: 0.25rem;
  }

  .content-section {
    padding: 1rem;
  }

  .section-actions {
    margin-bottom: 1rem;
  }

  .product-form-container {
    padding: 1rem;
    margin-bottom: 1rem;
  }

  .form-header h2 {
    font-size: 1.25rem;
  }

  .sidebar-nav {
    padding: 0.5rem 0;
  }

  .nav-item {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
  }

  .nav-icon {
    font-size: 1rem;
  }

  .sidebar-header {
    padding: 1rem;
  }

  .sidebar-header h2 {
    font-size: 1.25rem;
  }
}
