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

:root {
  --primary-color: #2196F3;
  --primary-dark: #1976D2;
  --secondary-color: #4CAF50;
  --danger-color: #f44336;
  --warning-color: #ff9800;
  --success-color: #4CAF50;
  --text-dark: #333;
  --text-light: #666;
  --border-color: #e0e0e0;
  --background-light: #f5f5f5;
  --sidebar-bg: #263238;
  --sidebar-text: #eceff1;
  --shadow: 0 2px 4px rgba(0,0,0,0.1);
}

body {
  font-family: 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-dark);
  background: var(--background-light);
}

html[dir="rtl"] body {
  font-family: 'Cairo', 'Segoe UI', sans-serif;
}

.app-container {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.logo {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 20px;
}

.logo h1 {
  font-size: 24px;
  font-weight: bold;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 10px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 15px;
  background: transparent;
  color: var(--sidebar-text);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.3s ease;
  text-align: right;
}

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

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

.nav-btn .icon {
  font-size: 20px;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 30px;
  overflow-y: auto;
  background: var(--background-light);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Sales Section */
.sales-container {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  height: 100%;
}

.products-section {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.products-section h2 {
  margin-bottom: 20px;
  font-size: 20px;
  color: var(--text-dark);
}

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

.product-card {
  background: white;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.product-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.2);
  transform: translateY(-2px);
}

.product-card.out-of-stock {
  opacity: 0.6;
  cursor: not-allowed;
}

.product-name {
  font-weight: bold;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.product-price {
  font-size: 20px;
  color: var(--primary-color);
  font-weight: bold;
  margin-bottom: 8px;
}

.product-stock {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 10px;
}

.add-to-cart-btn {
  width: 100%;
  padding: 8px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.3s;
}

.add-to-cart-btn:hover {
  background: var(--primary-dark);
}

.product-card.out-of-stock .add-to-cart-btn {
  background: #ccc;
  cursor: not-allowed;
}

/* Cart Section */
.cart-section {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.cart-section h2 {
  margin-bottom: 20px;
  font-size: 20px;
}

.cart-items {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 20px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px;
  min-height: 300px;
}

.empty-cart {
  text-align: center;
  color: var(--text-light);
  padding: 40px 20px;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
  background: #fafafa;
}

.cart-item:last-child {
  border-bottom: none;
}

.cart-item-info {
  flex: 1;
  text-align: right;
}

.cart-item-name {
  font-weight: bold;
  margin-bottom: 4px;
}

.cart-item-price {
  color: var(--primary-color);
  font-weight: bold;
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 10px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-color);
  background: white;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.3s;
}

.qty-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.remove-btn {
  background: var(--danger-color);
  color: white;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.3s;
}

.remove-btn:hover {
  background: #d32f2f;
}

/* Cart Summary */
.cart-summary {
  background: var(--background-light);
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 15px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 14px;
}

.summary-row:last-child {
  margin-bottom: 0;
}

.summary-row.final {
  border-top: 2px solid var(--border-color);
  padding-top: 10px;
  font-size: 18px;
  font-weight: bold;
  color: var(--primary-color);
}

.discount-input {
  width: 80px;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: left;
}

/* Buttons */
.cart-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
  transition: all 0.3s;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.btn-secondary:hover {
  background: #555;
}

/* Products Management */
.products-management {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.management-header h2 {
  font-size: 24px;
}

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

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

.products-table th {
  padding: 12px;
  text-align: right;
  font-weight: bold;
  border-bottom: 2px solid var(--border-color);
}

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

.products-table tbody tr:hover {
  background: #f9f9f9;
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.edit-btn {
  background: var(--primary-color);
  color: white;
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.delete-btn {
  background: var(--danger-color);
  color: white;
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.4);
  animation: fadeIn 0.3s ease;
}

.modal.active {
  display: flex;
  justify-content: center;
  align-items: center;
}

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

.modal-content {
  background-color: white;
  padding: 30px;
  border-radius: 8px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  animation: slideIn 0.3s ease;
}

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

.modal-content h3 {
  margin-bottom: 20px;
  font-size: 20px;
}

.close {
  color: #aaa;
  float: left;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  line-height: 20px;
}

.close:hover {
  color: #000;
}

html[dir="rtl"] .close {
  float: right;
}

/* Form */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-weight: bold;
  color: var(--text-dark);
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

.form-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

/* Reports */
.reports-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.reports-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 2px solid var(--border-color);
}

.filter-group {
  display: flex;
  flex-direction: column;
}

.filter-group label {
  font-weight: bold;
  margin-bottom: 5px;
}

.filter-group input {
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.report-results {
  margin-top: 20px;
}

/* Receipt */
.receipt {
  background: white;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: center;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  max-height: 500px;
  overflow-y: auto;
}

.receipt-header {
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px dashed var(--border-color);
}

.receipt-header h3 {
  font-size: 16px;
  margin-bottom: 5px;
}

.receipt-items {
  margin: 15px 0;
  text-align: center;
}

.receipt-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
  font-size: 11px;
}

.receipt-footer {
  margin-top: 15px;
  padding-top: 10px;
  border-top: 2px dashed var(--border-color);
  font-weight: bold;
}

.receipt-content {
  max-width: 400px;
  max-height: 600px;
}

.receipt-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 20px;
}

/* Settings */
.settings-container {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
  max-width: 600px;
}

.settings-form {
  margin-top: 20px;
}

/* Responsive */
@media (max-width: 1200px) {
  .sales-container {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    flex-direction: row;
    padding: 0;
    height: auto;
  }

  .logo {
    padding: 10px;
    border-bottom: none;
    border-right: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 0;
  }

  .nav-menu {
    flex-direction: row;
    flex: 1;
    padding: 0 10px;
  }

  .nav-btn {
    padding: 10px;
    font-size: 12px;
  }

  .nav-btn .icon {
    font-size: 16px;
  }

  .main-content {
    padding: 15px;
  }

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

  .cart-buttons {
    grid-template-columns: 1fr;
  }
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background-light);
}

::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #999;
}
