/* =============================================================================
 * Dashboard Styles - Clean Arabic RTL Admin Interface
 * ============================================================================= */

:root {
  --primary: #FF6A13;
  --primary-soft: rgba(255, 106, 19, 0.12);
  --bg: #F5F4F1;
  --surface: #FFFFFF;
  --surface-alt: #FAF8F5;
  --text: #1B1815;
  --text-muted: #6C655E;
  --border: #E5DED5;
  --danger: #D9381E;
  --success: #1F8A4C;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow: 0 4px 16px rgba(27, 24, 21, 0.06);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 100;
  background: #1B1815;
  color: #fff;
  padding: 0.75rem 1.35rem;
  border-radius: var(--radius-md);
  font-weight: 700;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.22);
  border-right: 4px solid var(--primary);
}

/* Login Screen */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  width: min(460px, 100%);
  box-shadow: var(--shadow);
}

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

.login-header h1 {
  margin: 0.45rem 0 0.25rem;
  font-size: 1.6rem;
}

.login-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.badge-pill {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.82rem;
}

.demo-login-box {
  margin-top: 1.5rem;
  padding-top: 1.15rem;
  border-top: 1px dashed var(--border);
  font-size: 0.86rem;
}

.demo-login-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 270px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #191512;
  color: #FAF6F2;
  padding: 1.35rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.5rem;
}

.sb-logo {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary);
  background: #2b241f;
}

.role-badge {
  display: inline-block;
  font-size: 0.72rem;
  background: rgba(255, 255, 255, 0.14);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  margin-top: 0.15rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.nav-item {
  background: transparent;
  color: rgba(250, 246, 242, 0.8);
  border: none;
  text-align: right;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.15s ease, color 0.15s ease;
}

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

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

.nav-counter {
  background: rgba(0, 0, 0, 0.28);
  color: #fff;
  font-size: 0.78rem;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.user-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: rgba(250, 246, 242, 0.75);
}

.user-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 175px;
}

.btn-link-danger {
  background: none;
  border: none;
  color: #ff8a75;
  font-weight: 700;
  cursor: pointer;
}

/* Main Panel */
.main-panel {
  padding: 1.75rem 2.2rem 3rem;
  max-width: 1280px;
  width: 100%;
}

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

.panel-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

.panel-header p {
  margin: 0.2rem 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.header-btn-group {
  display: flex;
  gap: 0.6rem;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(460px, 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.35rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 1rem;
  font-size: 1.12rem;
}

/* Forms */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.span-2 {
  grid-column: span 2;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.form-input {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

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

.file-input {
  font-size: 0.84rem;
  margin-top: 0.35rem;
}

.color-picker-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-picker-row input[type="color"] {
  width: 44px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
  cursor: pointer;
}

.upload-field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--border);
}

.highlight-box {
  background: var(--surface-alt);
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.thumb-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  flex-shrink: 0;
}

.thumb-preview.wide {
  width: 120px;
}

.sub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem 0 0.6rem;
}

.repeater-list, .stack-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.repeater-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 0.65rem;
  border-radius: var(--radius-sm);
}

.inline-add-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}

.gallery-thumbs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 0.6rem;
}

.gallery-thumb-card {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1;
}

.gallery-thumb-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-thumb-del {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(217, 56, 30, 0.9);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  font-size: 0.75rem;
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.15rem 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.58rem 1.15rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.84rem;
}

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

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

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

.btn-block {
  width: 100%;
}

.file-btn {
  cursor: pointer;
}

.form-error {
  color: var(--danger);
  font-weight: 700;
  font-size: 0.88rem;
  margin: 0;
}

/* Menu Tab */
.chips-manage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.cat-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-weight: 700;
}

.cat-pill button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.dash-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.dash-prod-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
}

.dash-prod-card.inactive {
  opacity: 0.6;
}

.dash-prod-card img {
  width: 100%;
  height: 155px;
  object-fit: cover;
}

.dash-prod-body {
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}

.dash-prod-actions {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 16, 13, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: min(640px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.modal-lg {
  width: min(760px, 100%);
}

.modal-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
}

.btn-icon {
  background: none;
  border: none;
  font-size: 1.15rem;
  cursor: pointer;
}

.modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 0.9rem 1.35rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.65rem;
}

.group-editor-card {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 0.8rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  font-weight: 600;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    height: auto;
  }
  .cards-grid, .form-grid-2 {
    grid-template-columns: 1fr;
  }
  .span-2 {
    grid-column: span 1;
  }
}
