/* ===== ADMIN PANEL STYLES ===== */

/* VARIABLES */
:root {
  --green: #2e7d32;
  --green-light: #4caf50;
  --orange: #f57c00;
  --orange-light: #ff9800;
  --red: #d32f2f;
  --red-light: #ef5350;
  --white: #fff;
  --gray: #757575;
  --gray-light: #f5f5f5;
  --border: #e0e0e0;
  --radius: 12px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', sans-serif; background: var(--gray-light); color: #222; }
a { text-decoration: none; color: inherit; }
img { width: 100%; display: block; }

/* ============================================
   LOGIN SCREEN
   ============================================ */
.login-container {
  display: none;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
}

.login-container.show {
  display: flex;
}

.login-card {
  background: white;
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 400px;
}

.login-header {
  text-align: center;
  margin-bottom: 30px;
}

.login-header h1 {
  color: var(--green);
  margin-bottom: 5px;
}

.login-header p {
  color: var(--gray);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-weight: 600;
  color: #333;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.hint {
  font-size: 12px;
  color: var(--gray);
  text-align: center;
  margin-top: 10px;
}

/* ============================================
   ADMIN LAYOUT
   ============================================ */
.admin-wrapper {
  display: flex !important;
  height: 100vh;
  overflow: hidden;
}

.admin-sidebar {
  width: 250px;
  background: var(--green);
  color: white;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 8px rgba(0,0,0,0.1);
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-header h2 {
  font-size: 1.3rem;
}

.close-sidebar {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
  display: flex;
  flex-direction: column;
}

.nav-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  padding: 12px 16px;
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.2s, color 0.2s;
  border-left: 4px solid transparent;
}

.nav-btn:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.nav-btn.active {
  background: rgba(255,255,255,0.15);
  color: white;
  border-left-color: var(--orange);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.2);
}

.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.admin-header {
  background: white;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-title {
  font-size: 1.3rem;
  font-weight: 600;
  flex: 1;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.hamburger-admin {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  margin-right: 10px;
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   BUTTONS
   ============================================ */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-edit,
.btn-delete,
.btn-logout,
.btn-logout-sm,
.btn-remove,
.btn-delete-sm {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--green);
  color: white;
}

.btn-primary:hover {
  background: #1b5e20;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--gray-light);
  color: #333;
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e0e0e0;
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #c62828;
  transform: translateY(-1px);
}

.btn-logout,
.btn-logout-sm {
  background: var(--orange);
  color: white;
}

.btn-logout:hover,
.btn-logout-sm:hover {
  background: #e65100;
}

.btn-edit {
  background: var(--green-light);
  color: white;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-edit:hover {
  background: var(--green);
}

.btn-delete,
.btn-delete-sm {
  background: var(--red-light);
  color: white;
  padding: 6px 12px;
  font-size: 12px;
}

.btn-delete:hover,
.btn-delete-sm:hover {
  background: var(--red);
}

.btn-remove {
  background: var(--red-light);
  color: white;
  padding: 6px 10px;
  font-size: 12px;
}

/* ============================================
   DASHBOARD
   ============================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  font-size: 2.5rem;
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--gray);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--green);
}

.dashboard-section {
  background: white;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.dashboard-section h3 {
  margin-bottom: 16px;
  color: #333;
}

/* ============================================
   PRODUCTS & CATEGORIES GRID
   ============================================ */
.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.tab-header h2 {
  color: #333;
}

.tab-header div {
  display: flex;
  gap: 8px;
}

.tab-header div button {
  white-space: nowrap;
}

.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.search-bar input,
.search-bar select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.search-bar input {
  flex: 1;
}

.search-bar select {
  min-width: 180px;
}

.products-grid,
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.product-card,
.category-card {
  background: white;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
}

.product-card:hover,
.category-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.product-image {
  width: 100%;
  height: 200px;
  overflow: hidden;
  background: var(--gray-light);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-info,
.category-header {
  padding: 16px;
}

.product-info h4,
.category-header h4 {
  margin-bottom: 6px;
  color: #333;
}

.category {
  font-size: 12px;
  color: var(--gray);
  margin-bottom: 8px;
}

.price {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 8px;
}

.stock-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.stock-badge.in-stock {
  background: #e8f5e9;
  color: var(--green);
}

.stock-badge.out-stock {
  background: #ffebee;
  color: var(--red);
}

.product-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
}

.product-actions button {
  flex: 1;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.count {
  background: var(--green-light);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

/* ============================================
   FORMS & MODALS
   ============================================ */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.image-upload-area {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.image-upload-area:hover {
  border-color: var(--green);
  background: rgba(46, 125, 50, 0.05);
}

.image-upload-area input[type="file"] {
  display: none;
}

#image-preview-container {
  position: relative;
  max-width: 200px;
  margin: 16px auto;
}

#image-preview {
  border-radius: 8px;
  max-width: 100%;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--gray-light);
  border-radius: 3px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  width: 0%;
  transition: width 0.3s;
}

/* MODAL */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: white;
  padding: 24px;
  border-radius: var(--radius);
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  color: #333;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--gray);
  transition: color 0.2s;
}

.modal-close:hover {
  color: #333;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.confirm-modal {
  text-align: center;
}

.confirm-modal h2 {
  margin-bottom: 12px;
}

.confirm-modal p {
  color: var(--gray);
  margin-bottom: 20px;
}

/* ============================================
   SETTINGS
   ============================================ */
.settings-card {
  background: white;
  padding: 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.settings-card h3 {
  margin-bottom: 12px;
  color: #333;
}

.setting-hint {
  font-size: 13px;
  color: var(--gray);
  margin-bottom: 16px;
}

.setting-hint a {
  color: var(--green);
  font-weight: 600;
}

.api-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  display: none;
}

.api-status.success {
  display: block;
  background: #e8f5e9;
  color: var(--green);
}

.danger-zone {
  border: 2px solid var(--red-light);
  background: #ffebee;
}

.danger-zone h3 {
  color: var(--red);
}

/* ============================================
   RATES TABLE
   ============================================ */
.rates-info {
  background: #e8f5e9;
  border-left: 4px solid var(--green);
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  color: #2e7d32;
}

.rates-table-wrapper {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  overflow-x: auto;
}

.rates-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.rates-table thead {
  background: var(--gray-light);
  border-bottom: 2px solid var(--border);
}

.rates-table th {
  padding: 12px;
  text-align: left;
  font-weight: 600;
  color: #333;
}

.rates-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.rates-table tbody tr:hover {
  background: #f9f9f9;
}

.rates-table tbody tr:last-child td {
  border-bottom: none;
}

.btn-edit-sm {
  background: var(--green-light);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.2s;
}

.btn-edit-sm:hover {
  background: var(--green);
}

.rate-display-info {
  background: var(--gray-light);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.rate-display-info p {
  margin: 4px 0;
  font-size: 14px;
}

.bulk-preview {
  background: var(--gray-light);
  padding: 12px;
  border-radius: 8px;
  margin: 16px 0;
  max-height: 200px;
  overflow-y: auto;
}

.bulk-preview h4 {
  margin-bottom: 8px;
  color: #333;
  font-size: 13px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 250px;
    transform: translateX(-100%);
    z-index: 200;
    border-right: 1px solid var(--border);
  }

  .admin-sidebar.open {
    transform: translateX(0);
  }

  .close-sidebar {
    display: block;
  }

  .hamburger-admin {
    display: block;
  }

  .admin-content {
    padding: 16px;
  }

  .tab-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .tab-header button {
    width: 100%;
  }

  .tab-header div {
    width: 100%;
    flex-direction: column;
  }

  .tab-header div button {
    width: 100%;
  }

  .search-bar {
    flex-direction: column;
  }

  .search-bar select {
    min-width: auto;
  }

  .products-grid,
  .categories-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .modal-content {
    max-width: 90%;
  }
}

@media (max-width: 480px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions button {
    width: 100%;
  }

  .product-actions {
    flex-direction: column;
  }

  .product-actions button {
    width: 100%;
  }

  .rates-table {
    font-size: 12px;
  }

  .rates-table th,
  .rates-table td {
    padding: 8px;
  }

  .btn-edit-sm {
    padding: 4px 8px;
    font-size: 11px;
  }
}
