/* =========================================================
   Admin Dashboard CSS - Afnan Paints
   Target: body.admin-layout > .admin-shell > sidebar + content
   RTL + Cairo font
   ========================================================= */

:root{
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  --primary: #2563eb;
  --primary-600: #1d4ed8;

  --success: #16a34a;
  --danger: #dc2626;

  --shadow: 0 10px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
}

/* Base */
*{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  font-family: "Cairo", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
}

/* Links */
a{ color: inherit; }
a:focus, button:focus, input:focus, select:focus, textarea:focus{
  outline: 2px solid rgba(37, 99, 235, .25);
  outline-offset: 2px;
}

/* =========================================================
   Layout
   ========================================================= */
.admin-shell{
  min-height: 100vh;
  display: flex;
}

/* Sidebar */
.admin-sidebar{
  position: sticky;
  top: 0;
  height: 100vh;
  width: 260px;
  flex: 0 0 260px;

  background: #0f172a;
  color: #e2e8f0;
  border-inline-end: 1px solid rgba(148,163,184,.18);
  padding: 18px 14px;
}

.sidebar-brand{
  font-weight: 900;
  font-size: 16px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.06);
  margin-bottom: 12px;
}

.sidebar-nav{
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.sidebar-link{
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px 12px;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  font-weight: 800;
  font-size: 13px;

  transition: background .15s ease, transform .05s ease, border-color .15s ease;
  border: 1px solid transparent;
}

.sidebar-link:hover{
  background: rgba(255,255,255,.08);
}

.sidebar-link:active{
  transform: translateY(1px);
}

.sidebar-link.active{
  background: rgba(59,130,246,.18);
  border-color: rgba(59,130,246,.35);
}

/* Content column */
.admin-content{
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.admin-topbar{
  position: sticky;
  top: 0;
  z-index: 50;

  display: flex;
  align-items: center;
  justify-content: space-between;

  height: 64px;
  padding: 0 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar-left,
.topbar-right{
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title{
  font-weight: 900;
  font-size: 15px;
  color: var(--text);
}

.topbar-toggle{
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}

.topbar-toggle:hover{ background: #f8fafc; }

.topbar-user{
  color: #334155;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 10px;
  background: #f1f5f9;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.topbar-action{
  height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 900;
  font-size: 13px;
  color: var(--text);
}

.topbar-action:hover{ background: #f8fafc; }

/* Main */
.admin-main{
  flex: 1;
  min-height: 0;
  padding: 16px 18px 22px;
}

/* Page container */
.admin-page{
  margin-top: 12px;
}

/* =========================================================
   Breadcrumbs
   ========================================================= */
.admin-breadcrumbs{
  margin: 0 0 14px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(15,23,42,.02);
}

.admin-breadcrumbs ol{
  list-style: none;
  margin: 0;
  padding: 0;

  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.admin-breadcrumbs li{
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  font-size: 13px;
  color: #334155;
}

.admin-breadcrumbs li + li::before{
  content: "›";
  margin: 0 6px;
  color: #94a3b8;
  font-weight: 900;
}

.admin-breadcrumbs a{
  color: var(--primary);
  text-decoration: none;
  font-weight: 900;
}
.admin-breadcrumbs a:hover{ text-decoration: underline; }

/* =========================================================
   Alerts (Flash)
   ========================================================= */
.admin-alert{
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);

  font-weight: 900;
  font-size: 13px;

  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-alert-success{
  border-color: rgba(22,163,74,.30);
  background: rgba(22,163,74,.10);
  color: #166534;
}
.admin-alert-success::before{ content: "✓"; font-weight: 900; }

.admin-alert-error{
  border-color: rgba(220,38,38,.30);
  background: rgba(220,38,38,.10);
  color: #991b1b;
}
.admin-alert-error::before{ content: "⚠"; font-weight: 900; }

/* =========================================================
   Common UI: Buttons / Badges
   ========================================================= */
.btn-primary, .btn-secondary, .btn-danger{
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 9px 12px;
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  line-height: 1;
}

.btn-primary{
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover{ background: var(--primary-600); }

.btn-secondary{
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover{ background: #f8fafc; }

.btn-danger{
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover{ filter: brightness(.95); }

.badge-success, .badge-danger{
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid transparent;
}

.badge-success{
  background: rgba(22,163,74,.12);
  color: var(--success);
  border-color: rgba(22,163,74,.25);
}

.badge-danger{
  background: rgba(220,38,38,.12);
  color: var(--danger);
  border-color: rgba(220,38,38,.25);
}

/* Inline form */
.inline-form{ display: inline; }

/* =========================================================
   Table (works whether x-admin.table renders <table> or wraps it)
   ========================================================= */
table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

thead th{
  text-align: right;
  font-weight: 900;
  font-size: 13px;
  padding: 14px 12px;
  background: #f1f5f9;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td{
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
  color: #0f172a;
}

tbody tr:hover td{
  background: #fbfdff;
}

tbody tr:last-child td{ border-bottom: none; }

td .btn-secondary, td .btn-danger{
  margin-inline-start: 6px;
}

/* Swatch */
.color-swatch{
  width: 22px;
  height: 22px;
  display: inline-block;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* =========================================================
   Footer
   ========================================================= */
.admin-footer{
  margin-top: auto;
  padding: 14px 18px;
  text-align: center;

  font-size: 13px;
  font-weight: 800;
  color: var(--muted);

  background: var(--card);
  border-top: 1px solid var(--border);
}

/* =========================================================
   Responsive (mobile)
   ========================================================= */
@media (max-width: 992px){
  .admin-shell{
    flex-direction: column;
  }

  .admin-sidebar{
    position: fixed;
    top: 0;
    bottom: 0;
    inset-inline-start: 0;
    width: 270px;
    transform: translateX(110%);
    transition: transform .2s ease;
    z-index: 100;
  }

  /* Add this class on body with JS when sidebar is open */
  body.sidebar-open .admin-sidebar{
    transform: translateX(0);
  }

  .admin-main{
    padding: 14px;
  }

  .topbar-user{ display: none; }
}

/* Optional: improve table on small screens */
@media (max-width: 640px){
  thead{ display: none; }
  table, tbody, tr, td{ display: block; width: 100%; }
  tbody tr{
    border-bottom: 1px solid var(--border);
  }
  tbody td{
    border-bottom: none;
    padding: 10px 12px;
  }
}


/* =========================================================
   Dashboard: Grids, Cards, Lists, Quick Actions
   ========================================================= */

/* Grid system */
.admin-grid{
  display: grid;
  gap: 14px;
}

/* Stats cards grid */
.stats-grid{
  grid-template-columns: repeat(12, 1fr);
}

.stats-grid > *{
  grid-column: span 3; /* 4 cards per row on desktop */
}

/* Two columns section */
.two-columns{
  grid-template-columns: repeat(12, 1fr);
}

.two-columns > *{
  grid-column: span 6;
}

/* Card (in case x-admin.card outputs a wrapper you can target) */
.admin-card,
.card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Card header/body utility (works if the component has these elements) */
.admin-card-header,
.card-header{
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  background: #fbfdff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin-card-title,
.card-title{
  font-weight: 900;
  font-size: 14px;
  color: var(--text);
}

.admin-card-body,
.card-body{
  padding: 14px;
}

/* If card is only text number (stats) */
.admin-stat{
  font-size: 26px;
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
}
.admin-stat-sub{
  margin-top: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

/* Lists */
.admin-list{
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-list li{
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-weight: 800;
  font-size: 13px;
  color: #1f2937;
}

.admin-list li:last-child{
  border-bottom: none;
}

/* Quick actions row */
.admin-actions-row{
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Improve buttons spacing inside actions row */
.admin-actions-row .btn-primary,
.admin-actions-row .btn-secondary,
.admin-actions-row .btn-danger{
  height: 42px;
  padding: 0 14px;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 1200px){
  .stats-grid > *{ grid-column: span 4; } /* 3 per row */
}

@media (max-width: 900px){
  .stats-grid > *{ grid-column: span 6; } /* 2 per row */
  .two-columns > *{ grid-column: span 12; } /* 1 per row */
}

@media (max-width: 520px){
  .stats-grid > *{ grid-column: span 12; } /* 1 per row */
  .admin-actions-row{ flex-direction: column; }
  .admin-actions-row .btn-primary,
  .admin-actions-row .btn-secondary,
  .admin-actions-row .btn-danger{
    width: 100%;
    justify-content: center;
  }
}


/* =========================================================
   Forms: Grid + Inputs + Selects + Textareas + Toggle
   (compatible with common component markup patterns)
   ========================================================= */

/* Grid layout for forms */
.form-grid{
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 14px;
  align-items: start;
}

/* Default: each field spans 6 columns (2 per row) */
.form-grid > *{
  grid-column: span 6;
}

/* Textareas usually take full width */
.form-grid textarea,
.form-grid .textarea,
.form-grid .field-textarea,
.form-grid [data-field="textarea"]{
  min-height: 120px;
}

/* If your textarea components are wrapped, force them full row */
.form-grid > *:has(textarea){
  grid-column: span 12;
}

/* Generic form field wrapper (covers many component outputs) */
.form-grid .form-field,
.form-grid .field,
.form-grid .input-group,
.form-grid .form-group{
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Labels */
.form-grid label,
.form-grid .field-label,
.form-grid .form-label{
  font-weight: 900;
  font-size: 13px;
  color: #0f172a;
}

/* Controls */
.form-grid input[type="text"],
.form-grid input[type="number"],
.form-grid input[type="email"],
.form-grid input[type="password"],
.form-grid input[type="tel"],
.form-grid input[type="url"],
.form-grid input[type="search"],
.form-grid select,
.form-grid textarea{
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  font-size: 13px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

.form-grid textarea{
  resize: vertical;
  min-height: 120px;
  line-height: 1.7;
}

/* Placeholder */
.form-grid input::placeholder,
.form-grid textarea::placeholder{
  color: #94a3b8;
  font-weight: 700;
}

/* Focus */
.form-grid input:focus,
.form-grid select:focus,
.form-grid textarea:focus{
  border-color: rgba(37, 99, 235, .55);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

/* Disabled */
.form-grid input:disabled,
.form-grid select:disabled,
.form-grid textarea:disabled{
  background: #f1f5f9;
  cursor: not-allowed;
  opacity: .85;
}

/* Help text (if used) */
.form-grid .help,
.form-grid .form-help,
.form-grid .hint{
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

/* Validation errors (if used) */
.form-grid .error,
.form-grid .form-error,
.form-grid .invalid-feedback{
  font-size: 12px;
  font-weight: 800;
  color: var(--danger);
}

.form-grid input.is-invalid,
.form-grid select.is-invalid,
.form-grid textarea.is-invalid{
  border-color: rgba(220,38,38,.55);
  box-shadow: 0 0 0 4px rgba(220,38,38,.10);
}

/* Toggle (supports common patterns) */
.form-grid .toggle,
.form-grid .switch,
.form-grid .form-toggle,
.form-grid [data-toggle]{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

/* If component outputs checkbox + label */
.form-grid input[type="checkbox"]{
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* Make last row nicer */
.form-grid > *:last-child{
  margin-top: 2px;
}

/* =========================================================
   Responsive
   ========================================================= */
@media (max-width: 900px){
  .form-grid > *{ grid-column: span 12; }
}

/* =========================================================
   Images Manager (Product images)
   ========================================================= */
.admin-images-manager{
  margin-top: 14px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.admin-images-manager h3{
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 900;
  color: var(--text);
}

/* Space between file inputs (works even if x-admin.file outputs wrappers) */
.admin-images-manager > * + *{
  margin-top: 12px;
}

/* Generic styling for file inputs if component outputs input[type=file] */
.admin-images-manager input[type="file"]{
  width: 100%;
  border: 1px dashed rgba(148,163,184,.65);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fbfdff;
  font-weight: 800;
  font-size: 13px;
}

/* Files label if present */
.admin-images-manager label{
  display: inline-block;
  margin-bottom: 6px;
  font-weight: 900;
  font-size: 13px;
  color: var(--text);
}

/* Existing images grid */
.images-grid{
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 12px;
}

.image-item{
  grid-column: span 3;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(15,23,42,.05);
  min-height: 110px;

  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
}

.image-item span{
  font-weight: 900;
  font-size: 13px;
  color: #334155;
}

/* Optional: placeholder “image” look */
.image-item::before{
  content: "";
  width: 64px;
  height: 64px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, #f1f5f9, #ffffff);
  display: block;
  margin-inline-end: 10px;
}

/* If you later place an <img> inside .image-item */
.image-item img{
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

/* Responsive */
@media (max-width: 1200px){
  .image-item{ grid-column: span 4; }
}
@media (max-width: 900px){
  .image-item{ grid-column: span 6; }
}
@media (max-width: 520px){
  .image-item{ grid-column: span 12; }
  .image-item::before{ display: none; }
}


/* =========================================================
   Admin Form Wrapper
   ========================================================= */
.admin-form{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

/* Space between sections inside form */
.admin-form > * + *{
  margin-top: 14px;
}

/* Make the submit button look like form actions */
.admin-form > .btn-primary[type="submit"],
.admin-form button.btn-primary[type="submit"]{
  margin-top: 16px;
  height: 44px;
  padding: 0 16px;
  border-radius: 12px;
}

/* Optional: keep submit visible on long forms */
@media (min-width: 901px){
  .admin-form > .btn-primary[type="submit"],
  .admin-form button.btn-primary[type="submit"]{
    position: sticky;
    bottom: 14px;
    z-index: 10;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
  }
}

/* If you want the submit button aligned */
.admin-form > .btn-primary{
  justify-content: center;
}

/* =========================================================
   Extra Badges: info / secondary
   ========================================================= */
.badge-info,
.badge-secondary{
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid transparent;
}

.badge-info{
  background: rgba(37,99,235,.12);          /* primary tint */
  color: var(--primary);
  border-color: rgba(37,99,235,.25);
}

.badge-secondary{
  background: rgba(100,116,139,.12);        /* slate tint */
  color: #475569;
  border-color: rgba(100,116,139,.25);
}

/* =========================================================
   Products table tweaks
   ========================================================= */
table th:last-child,
table td:last-child{
  white-space: nowrap;
}

table td{
  line-height: 1.6;
}

table td .btn-secondary,
table td .btn-danger{
  height: 38px;
  padding: 0 12px;
}

/* Price cell emphasis (works generally) */
table td:nth-child(4){
  font-weight: 900;
  color: #0f172a;
}

/* =========================================================
   Pagination (generic styling; will apply if your pagination
   outputs <nav> <ul> <li> <a> or similar)
   ========================================================= */
.pagination,
nav[aria-label="Pagination"]{
  margin-top: 14px;
}

.pagination ul,
nav[aria-label="Pagination"] ul{
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.pagination a,
.pagination span,
nav[aria-label="Pagination"] a,
nav[aria-label="Pagination"] span{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  text-decoration: none;
  font-weight: 900;
  font-size: 13px;
  color: #0f172a;
}

.pagination a:hover,
nav[aria-label="Pagination"] a:hover{
  background: #f8fafc;
}

.pagination .active span,
nav[aria-label="Pagination"] .active span{
  background: rgba(37,99,235,.12);
  border-color: rgba(37,99,235,.25);
  color: var(--primary);
}

.pagination .disabled span,
nav[aria-label="Pagination"] .disabled span{
  opacity: .6;
  cursor: not-allowed;
  background: #f1f5f9;
}

.admin-dl{
  margin: 0;
  display: grid;
  gap: 10px;
}
.admin-dl > div{
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
}
.admin-dl > div:last-child{ border-bottom: none; }
.admin-dl dt{ font-weight: 900; color: #0f172a; }
.admin-dl dd{ margin: 0; font-weight: 800; color: #334155; }
@media (max-width: 640px){
  .admin-dl > div{ grid-template-columns: 1fr; }
}

/* =========================================================
   Admin Pagination Wrapper
   ========================================================= */
.admin-pagination{
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

/* Laravel usually outputs: <nav> <ul class="pagination"> <li> <a|span> */
.admin-pagination nav{
  width: 100%;
  display: flex;
  justify-content: center;
}

.admin-pagination .pagination{
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.admin-pagination .page-item{ display: inline-flex; }

.admin-pagination .page-link,
.admin-pagination .page-item span{
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 38px;
  height: 38px;
  padding: 0 12px;

  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;

  text-decoration: none;
  font-weight: 900;
  font-size: 13px;
  color: #0f172a;
}

.admin-pagination .page-link:hover{
  background: #f8fafc;
}

.admin-pagination .page-item.active span{
  background: rgba(37,99,235,.12);
  border-color: rgba(37,99,235,.25);
  color: var(--primary);
}

.admin-pagination .page-item.disabled span{
  opacity: .6;
  cursor: not-allowed;
  background: #f1f5f9;
}
