@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700;800&display=swap');

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

:root {
  --black:   #0A0A0A;
  --gold:    #C9A96E;
  --gold-dk: #b8924f;
  --white:   #FFFFFF;
  --bg:      #F5F3EF;
  --border:  #E5E0D8;
  --gray:    #777;
  --red:     #D94F4F;
  --font:    'Montserrat', system-ui, sans-serif;
  --sidebar: 230px;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--black);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
input, textarea, select, button { font-family: var(--font); }

/* =====================================================
   LOGIN SCREEN
   ===================================================== */

.admin-login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--black);
  padding: 2rem;
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
}

.login-logo {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  margin-bottom: 1.5rem;
}

.login-logo span {
  font-weight: 400;
  color: var(--gold);
  margin-left: 0.4rem;
}

.login-card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  color: var(--gray);
}

.login-error {
  color: var(--red);
  font-size: 0.82rem;
  margin-bottom: 1rem;
  min-height: 1.2em;
}

/* =====================================================
   LAYOUT
   ===================================================== */

.admin-wrap {
  display: flex;
  min-height: 100vh;
}

/* =====================================================
   SIDEBAR
   ===================================================== */

.admin-sidebar {
  width: var(--sidebar);
  min-height: 100vh;
  background: var(--black);
  position: fixed;
  top: 0; left: 0;
  display: flex;
  flex-direction: column;
  padding: 2rem 1.4rem 1.5rem;
  z-index: 50;
}

.sidebar-logo {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: white;
  margin-bottom: 2.5rem;
}

.sidebar-logo span {
  color: var(--gold);
  font-weight: 400;
  margin-left: 0.35rem;
}

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

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  color: #999;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.2s, color 0.2s;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.07);
  color: white;
}

.sidebar-nav a.active {
  background: var(--gold);
  color: white;
}

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

.sidebar-user span {
  font-size: 0.75rem;
  color: #666;
  word-break: break-all;
}

/* =====================================================
   MAIN CONTENT AREA
   ===================================================== */

.admin-main {
  margin-left: var(--sidebar);
  flex: 1;
  padding: 2.5rem 2.5rem 4rem;
  max-width: calc(100vw - var(--sidebar));
}

.admin-section { display: none; }
.admin-section.active { display: block; }

/* =====================================================
   SECTION HEADER
   ===================================================== */

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

.section-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.section-header-controls {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* =====================================================
   CARD
   ===================================================== */

.admin-card {
  background: white;
  border-radius: 14px;
  border: 1px solid var(--border);
  overflow: hidden;
}

/* =====================================================
   TABLE
   ===================================================== */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th {
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray);
  border-bottom: 1px solid var(--border);
  background: #faf9f7;
}

.admin-table td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }

.admin-table tr:hover td { background: #fdf9f3; }

.table-thumb {
  width: 52px;
  height: 42px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg);
}

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

.empty-row td {
  text-align: center;
  color: var(--gray);
  padding: 3rem 1rem;
  font-size: 0.88rem;
}

/* =====================================================
   BUTTONS
   ===================================================== */

.admin-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--gold);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  letter-spacing: 0.01em;
}

.admin-btn:hover { background: var(--gold-dk); }
.admin-btn:active { transform: scale(0.97); }
.admin-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.admin-btn-ghost {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: var(--gray);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.admin-btn-ghost:hover { border-color: var(--black); color: var(--black); }

.admin-btn-danger {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: var(--red);
  border: 1.5px solid #f0c0c0;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.admin-btn-danger:hover { background: var(--red); color: white; border-color: var(--red); }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.78rem; }

/* =====================================================
   FORMS
   ===================================================== */

.admin-form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1.1rem;
}

.admin-form-group label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gray);
}

.admin-input {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.88rem;
  color: var(--black);
  background: white;
  transition: border-color 0.2s;
  outline: none;
}

.admin-input:focus { border-color: var(--gold); }

textarea.admin-input {
  resize: vertical;
  min-height: 90px;
  line-height: 1.6;
}

/* =====================================================
   IMAGE UPLOAD FIELD
   ===================================================== */

.img-input-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.img-tab-btn {
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--gray);
  transition: all 0.2s;
}

.img-tab-btn.active {
  background: var(--gold);
  color: white;
  border-color: var(--gold);
}

.img-panel { display: none; }
.img-panel.active { display: block; }

.upload-area {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  position: relative;
}

.upload-area:hover, .upload-area.drag-over {
  border-color: var(--gold);
  background: #fdf9f3;
}

.upload-area input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.upload-area p {
  font-size: 0.82rem;
  color: var(--gray);
  pointer-events: none;
}

.upload-area .upload-icon {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
  pointer-events: none;
}

.upload-preview {
  margin-top: 0.75rem;
  position: relative;
  display: inline-block;
}

.upload-preview img {
  max-height: 120px;
  border-radius: 8px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.upload-preview-remove {
  position: absolute;
  top: -8px; right: -8px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--red);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center;
}

.upload-progress {
  margin-top: 0.5rem;
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  display: none;
}

.upload-progress-bar {
  height: 100%;
  background: var(--gold);
  width: 0;
  transition: width 0.3s;
}

/* =====================================================
   MODAL
   ===================================================== */

.admin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.admin-modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.admin-modal h2 {
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 1.5rem;
  padding-right: 2rem;
}

.modal-close {
  position: absolute;
  top: 1.2rem; right: 1.3rem;
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--gray);
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover { color: var(--black); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

/* =====================================================
   TOAST NOTIFICATION
   ===================================================== */

.admin-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--black);
  color: white;
  padding: 0.85rem 1.4rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  z-index: 500;
  max-width: 320px;
}

.admin-toast.show { transform: translateY(0); opacity: 1; }
.admin-toast.toast-success { background: #2d7a4f; }
.admin-toast.toast-error   { background: var(--red); }

/* =====================================================
   RESPONSIVE
   ===================================================== */

@media (max-width: 768px) {

  /* Sidebar shrinks to a narrow icon-only strip */
  :root { --sidebar: 60px; }

  .admin-sidebar {
    width: 60px;
    padding: 1.5rem 0.5rem;
    align-items: center;
  }

  /* Hide logo text, keep it as a decorative dot */
  .sidebar-logo {
    font-size: 0;
    margin-bottom: 2rem;
  }
  .sidebar-logo::before {
    content: 'F';
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--gold);
    letter-spacing: 0;
  }

  /* Nav links — show only first letter as label */
  .sidebar-nav a {
    width: 40px;
    height: 40px;
    padding: 0;
    justify-content: center;
    font-size: 0;         /* hide full text */
    border-radius: 10px;
  }

  /* Show first letter only via ::first-letter doesn't work on inline — use data trick instead */
  .sidebar-nav a[data-section="categories"]::before { content: 'C'; font-size: 0.85rem; font-weight: 700; }
  .sidebar-nav a[data-section="products"]::before   { content: 'P'; font-size: 0.85rem; font-weight: 700; }
  .sidebar-nav a[data-section="settings"]::before   { content: 'S'; font-size: 0.85rem; font-weight: 700; }

  /* Hide email, shrink logout button */
  .sidebar-user { align-items: center; }
  .sidebar-user span { display: none; }
  .sidebar-user .admin-btn-ghost {
    font-size: 0;
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    justify-content: center;
  }
  .sidebar-user .admin-btn-ghost::before { content: '↪'; font-size: 1rem; }

  /* Main content takes remaining space */
  .admin-main {
    margin-left: 60px;
    padding: 1.2rem 0.9rem 4rem;
    max-width: calc(100vw - 60px);
  }

  /* Section header stacks vertically */
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .section-header h1 { font-size: 1.2rem; }

  .section-header-controls {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .section-header-controls .admin-btn,
  .section-header-controls .admin-input {
    width: 100%;
  }

  /* Tables scroll horizontally */
  .admin-card {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-table { min-width: 420px; }

  .col-tagline,
  .col-order { display: none; }

  .table-actions {
    flex-direction: column;
    gap: 0.3rem;
  }

  /* Modal full width from bottom */
  .admin-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .admin-modal {
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
    padding: 1.5rem 1rem;
  }

  .modal-footer {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-footer button {
    width: 100%;
    justify-content: center;
  }

  /* Toast full width */
  .admin-toast {
    bottom: 0; right: 0; left: 0;
    max-width: 100%;
    border-radius: 0;
    text-align: center;
  }

  /* Settings single column */
  .settings-grid {
    grid-template-columns: 1fr !important;
  }
}
