/* ============================================
   PLANTFEEL — Admin Panel
   ============================================ */

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

:root {
  --green-dark:  #1a3a2a;
  --green-mid:   #2D6A4F;
  --green-light: #52b788;
  --green-pale:  #d8f3dc;
  --bg:          #f0f4f2;
  --surface:     #ffffff;
  --text:        #1a1a1a;
  --text-muted:  #6b7a72;
  --border:      #dde5e0;
  --danger:      #e63946;
  --danger-pale: #fde8ea;
  --shadow:      0 2px 12px rgba(0,0,0,.08);
  --radius:      10px;
}

body { font-family: 'Nunito', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }

/* ── LOGIN ── */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
  z-index: 1000;
}
.login-box {
  background: var(--surface); border-radius: 16px; padding: 2.5rem 2rem;
  width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,.25);
  text-align: center;
}
.login-logo { width: 60px; height: 60px; border-radius: 12px; object-fit: cover; margin-bottom: 1rem; }
.login-box h2 { font-size: 1.5rem; color: var(--green-dark); margin-bottom: .25rem; }
.login-box p { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.75rem; }
.login-box .form-group { margin-bottom: 1rem; text-align: left; }
.login-box label { display: block; font-size: .8rem; font-weight: 700; color: var(--text-muted); margin-bottom: .35rem; text-transform: uppercase; letter-spacing: .05em; }
.login-box input { width: 100%; padding: .75rem 1rem; border: 1.5px solid var(--border); border-radius: 8px; font-size: 1rem; outline: none; transition: border-color .2s; }
.login-box input:focus { border-color: var(--green-mid); }
.login-error { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin-bottom: .75rem; }
.btn-login {
  width: 100%; padding: .85rem; background: var(--green-mid); color: #fff;
  border: none; border-radius: 8px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: background .2s;
}
.btn-login:hover { background: var(--green-dark); }
.btn-login:disabled { opacity: .6; cursor: not-allowed; }

/* ── LAYOUT ── */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px; flex-shrink: 0; background: var(--green-dark); color: #fff;
  display: flex; flex-direction: column; padding: 1.5rem 0;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand img { width: 36px; height: 36px; border-radius: 8px; object-fit: cover; }
.sidebar-brand span { font-size: 1.1rem; font-weight: 800; }
.sidebar-brand strong { color: var(--green-light); }

.sidebar nav { flex: 1; padding: 1rem 0; }
.sidebar nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem 1.25rem; color: rgba(255,255,255,.65);
  text-decoration: none; font-weight: 600; font-size: .95rem;
  border-left: 3px solid transparent; transition: all .15s;
}
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar nav a.active { color: #fff; background: rgba(255,255,255,.1); border-left-color: var(--green-light); }
.sidebar nav a .nav-icon { font-size: 1.1rem; }

/* ── NAV GROUP (Config + submenu) ── */
.nav-group { display: flex; flex-direction: column; }
.nav-parent { cursor: pointer; }
.nav-caret { margin-left: auto; font-size: .75rem; transition: transform .2s; }
.nav-parent.open .nav-caret { transform: rotate(180deg); }
.nav-submenu {
  max-height: 0; overflow: hidden; display: flex; flex-direction: column;
  background: rgba(0,0,0,.12); transition: max-height .2s ease;
}
.nav-submenu.open { max-height: 200px; }
.nav-submenu a {
  padding: .6rem 1.25rem .6rem 2.75rem; color: rgba(255,255,255,.6);
  text-decoration: none; font-weight: 600; font-size: .88rem;
  border-left: 3px solid transparent; transition: all .15s;
}
.nav-submenu a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-submenu a.active { color: #fff; background: rgba(255,255,255,.1); border-left-color: var(--green-light); }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.1);
}
.sidebar-user-email { font-size: .8rem; color: rgba(255,255,255,.5); margin-bottom: .5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout {
  width: 100%; padding: .5rem; background: rgba(255,255,255,.08); color: rgba(255,255,255,.8);
  border: 1px solid rgba(255,255,255,.15); border-radius: 6px; cursor: pointer; font-size: .85rem; transition: all .15s;
}
.btn-logout:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── MAIN ── */
.admin-main { flex: 1; display: flex; flex-direction: column; overflow: auto; }

.tab-content { display: none; flex: 1; padding: 2rem; }
.tab-content.active { display: block; }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.75rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h1 { font-size: 1.6rem; color: var(--green-dark); }
.page-header-sub { font-size: .9rem; color: var(--text-muted); margin-top: .15rem; }

.header-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .6rem 1.1rem; border-radius: 8px; border: none; cursor: pointer; font-size: .875rem; font-weight: 700; transition: all .15s; }
.btn-primary { background: var(--green-mid); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border: 1.5px solid var(--border); }
.btn-secondary:hover { border-color: var(--green-mid); color: var(--green-mid); }
.btn-danger { background: var(--danger-pale); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-export { background: var(--green-pale); color: var(--green-dark); border: 1.5px solid var(--green-light); }
.btn-export:hover { background: var(--green-mid); color: #fff; }
.btn-sm { padding: .35rem .65rem; font-size: .78rem; }

/* ── STATS ── */
.stats-row { display: flex; gap: 1rem; margin-bottom: 1.75rem; flex-wrap: wrap; }
.stat-card {
  background: var(--surface); border-radius: var(--radius); padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow); flex: 1; min-width: 140px;
}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--green-mid); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ── TABLE ── */
.table-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-toolbar {
  display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.search-input {
  flex: 1; min-width: 200px; max-width: 340px;
  padding: .55rem .9rem; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: .9rem; outline: none; transition: border-color .2s;
}
.search-input:focus { border-color: var(--green-mid); }
.table-count { margin-left: auto; font-size: .82rem; color: var(--text-muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th { background: var(--bg); color: var(--text-muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; padding: .75rem 1rem; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f7fbf8; }
tbody td { padding: .8rem 1rem; vertical-align: middle; }
tbody td.td-actions { white-space: nowrap; display: flex; gap: .4rem; }

.badge { display: inline-block; padding: .2rem .55rem; border-radius: 20px; font-size: .75rem; font-weight: 700; }
.badge-ars { background: #e8f4fd; color: #1565c0; }
.badge-usd { background: #e8fdf0; color: #1b6b3a; }

.empty-state { text-align: center; padding: 3rem; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: .75rem; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 1rem;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 540px;
  box-shadow: 0 24px 64px rgba(0,0,0,.2); overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; color: var(--green-dark); }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); line-height: 1; padding: .2rem .4rem; border-radius: 6px; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 1.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.modal-body .full { grid-column: 1 / -1; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .75rem; }

.form-group label { display: block; font-size: .78rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: .35rem; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: .6rem .85rem; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .9rem; font-family: inherit; outline: none; transition: border-color .2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--green-mid); }
.form-group textarea { resize: vertical; min-height: 72px; }

/* ── USUARIOS ── */
.users-grid { display: grid; grid-template-columns: 1fr 360px; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .users-grid { grid-template-columns: 1fr; } }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); font-weight: 700; color: var(--green-dark); font-size: .95rem; }
.card-body { padding: 1.25rem; }

.user-row { display: flex; align-items: center; justify-content: space-between; padding: .65rem 0; border-bottom: 1px solid var(--border); gap: .5rem; }
.user-row:last-child { border-bottom: none; }
.user-email { font-size: .9rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.user-meta { font-size: .75rem; color: var(--text-muted); margin-top: .1rem; }

/* ── CONFIRM DIALOG ── */
.confirm-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; z-index: 600; padding: 1rem;
}
.confirm-overlay.hidden { display: none; }
.confirm-box {
  background: var(--surface); border-radius: 14px; padding: 2rem; max-width: 360px;
  width: 100%; text-align: center; box-shadow: 0 24px 64px rgba(0,0,0,.2);
}
.confirm-box h4 { font-size: 1.1rem; margin-bottom: .5rem; }
.confirm-box p { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.5rem; }
.confirm-actions { display: flex; gap: .75rem; justify-content: center; }

/* ── TOAST ── */
.toast-wrap { position: fixed; bottom: 1.5rem; right: 1.5rem; display: flex; flex-direction: column; gap: .5rem; z-index: 700; }
.toast {
  background: var(--green-dark); color: #fff; padding: .75rem 1.25rem;
  border-radius: 10px; font-size: .875rem; font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.2); animation: slideIn .2s ease;
  display: flex; align-items: center; gap: .5rem;
}
.toast.error { background: var(--danger); }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── ADMIN TOGGLE ── */
.admin-toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.admin-toggle input { opacity: 0; width: 0; height: 0; }
.admin-toggle-slider {
  position: absolute; inset: 0; background: #ccc; border-radius: 24px;
  cursor: pointer; transition: background .2s;
}
.admin-toggle-slider::before {
  content: ''; position: absolute; width: 18px; height: 18px;
  left: 3px; top: 3px; background: white; border-radius: 50%;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.admin-toggle input:checked + .admin-toggle-slider { background: var(--green-mid); }
.admin-toggle input:checked + .admin-toggle-slider::before { transform: translateX(20px); }

/* ── RESPONSIVE ── */
@media (max-width: 700px) {
  .sidebar { width: 200px; }
  .tab-content { padding: 1.25rem; }
  .modal-body { grid-template-columns: 1fr; }
}
