/* ═══════════════════════════════════════════════════════════════════════
   PANEL ADMIN — PAU NOCELO PORTFOLIO (v2)
   ═══════════════════════════════════════════════════════════════════════ */

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

/* ── DARK (default) ── */
:root {
  --bg:        #111;
  --bg-2:      #1a1a1a;
  --bg-3:      #222;
  --bg-hover:  #282828;
  --bg-input:  #161616;
  --text:      #eee;
  --text-dim:  #777;
  --text-mid:  #aaa;
  --accent:    #e8ff47;
  --accent-d:  #c4d93c;
  --accent-text: #111;
  --border:    #333;
  --danger:    #f44;
  --danger-bg: rgba(255,68,68,0.1);
  --ok:        #4caf50;
  --ok-bg:     rgba(76,175,80,0.1);
  --warn:      #ff9800;
  --radius:    8px;
  --font:      'Inter', -apple-system, sans-serif;
  --sidebar-w: 250px;
}

/* ── LIGHT ── */
[data-theme="light"] {
  --bg:        #f5f5f3;
  --bg-2:      #fff;
  --bg-3:      #eee;
  --bg-hover:  #e8e8e5;
  --bg-input:  #fff;
  --text:      #111;
  --text-dim:  #888;
  --text-mid:  #555;
  --accent:    #111;
  --accent-d:  #333;
  --accent-text: #fff;
  --border:    #ddd;
  --danger:    #d32f2f;
  --danger-bg: rgba(211,47,47,0.08);
  --ok:        #2e7d32;
  --ok-bg:     rgba(46,125,50,0.08);
  --warn:      #ef6c00;
}


/* ═══════════════════════════════════════════
   RESET
   ═══════════════════════════════════════════ */

*,*::before,*::after { margin:0; padding:0; box-sizing:border-box; }
html { height:100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  height: 100%;
  -webkit-font-smoothing: antialiased;
  transition: background .3s, color .3s;
}
a { color: var(--accent); text-decoration: none; }
img { display:block; max-width:100%; }
::selection { background: var(--accent); color: var(--accent-text); }
::-webkit-scrollbar { width:6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius:3px; }


/* ═══════════════════════════════════════════
   THEME TOGGLE
   ═══════════════════════════════════════════ */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  color: var(--text);
  transition: all .2s;
}
.theme-toggle:hover { border-color: var(--text-dim); }


/* ═══════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════ */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.login-theme-btn { position: absolute; top: 24px; right: 24px; }
.login-box {
  width: 100%;
  max-width: 420px;
  margin: 0 20px;
  padding: 48px 36px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.login-logo {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 4px;
  text-align: center;
  margin-bottom: 4px;
}
.login-sub {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 40px;
  text-transform: uppercase;
}
.login-field { margin-bottom: 24px; }
.login-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.login-input {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.login-input:focus { border-color: var(--accent); }
.login-input::placeholder { color: var(--text-dim); }
.login-btn {
  display: block;
  width: 100%;
  padding: 16px;
  margin-top: 12px;
  background: var(--accent);
  color: var(--accent-text);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .2s;
}
.login-btn:hover { background: var(--accent-d); }
.login-btn:disabled { opacity:.5; cursor:not-allowed; }
.login-error {
  margin-top: 16px;
  padding: 14px;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  display: none;
}
.login-error.show { display: block; }


/* ═══════════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════════ */

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

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 28px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: background .3s;
}
.sidebar-logo {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
  padding: 0 24px;
  margin-bottom: 2px;
}
.sidebar-sub {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 0 24px;
  margin-bottom: 36px;
}
.sidebar-nav { flex: 1; }
.sidebar-section {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 24px 24px 8px;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 24px;
  color: var(--text-mid);
  font-size: 14px;
  transition: all .15s;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--bg-hover); color: var(--text); }
.sidebar-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: var(--bg-hover);
  font-weight: 600;
}
.sidebar-link .badge {
  margin-left: auto;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.sidebar-bottom {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}
.sidebar-user { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.sidebar-logout {
  font-size: 12px;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
}
.sidebar-logout:hover { color: var(--danger); }

/* ── Main content ── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 36px 48px;
  min-height: 100vh;
  width: calc(100% - var(--sidebar-w));
  max-width: 960px;
}


/* ═══════════════════════════════════════════
   PAGE HEADER
   ═══════════════════════════════════════════ */

.page-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.page-ttl { font-size: 22px; font-weight: 700; }
.page-ttl small { font-weight: 400; color: var(--text-dim); font-size: 13px; margin-left: 8px; }


/* ═══════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-3);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--text-dim); }
.btn-accent { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-group { display: flex; gap: 12px; flex-wrap: wrap; }


/* ═══════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════ */

.card {
  display: block;
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 24px;
  transition: background .3s;
}
.card-ttl {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}


/* ═══════════════════════════════════════════
   FORMS — CRITICAL: explicit sizing
   ═══════════════════════════════════════════ */

.form-group {
  display: block;
  width: 100%;
  margin-bottom: 24px;
}
.form-label {
  display: block;
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-mid);
  margin-bottom: 10px;
}
.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  transition: border-color .2s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text-dim); }
.form-textarea {
  resize: vertical;
  min-height: 140px;
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  width: 100%;
}
.form-row > * { min-width: 0; }
.form-hint {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}
.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding-top: 28px;
}
.form-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}
.form-check label {
  font-size: 14px;
  color: var(--text-mid);
  cursor: pointer;
  line-height: 1.3;
}


/* ═══════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════ */

.tbl-wrap { overflow-x: auto; width: 100%; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  color: var(--text-mid);
  vertical-align: middle;
}
tr:hover td { background: var(--bg-hover); }


/* ═══════════════════════════════════════════
   TAGS
   ═══════════════════════════════════════════ */

.tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tag-accent { background: rgba(232,255,71,0.15); color: var(--accent); }
[data-theme="light"] .tag-accent { background: #eee; color: #333; }
.tag-dim    { background: var(--bg-3); color: var(--text-dim); }
.tag-ok     { background: var(--ok-bg); color: var(--ok); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-warn   { background: rgba(255,152,0,0.12); color: var(--warn); }


/* ═══════════════════════════════════════════
   TOAST
   ═══════════════════════════════════════════ */

.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  padding: 16px 24px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 2000;
  max-width: 400px;
  animation: toastIn .3s;
}
.toast-ok  { border-color: var(--ok); color: var(--ok); }
.toast-err { border-color: var(--danger); color: var(--danger); }
@keyframes toastIn { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:translateY(0)} }


/* ═══════════════════════════════════════════
   EMPTY STATE
   ═══════════════════════════════════════════ */

.empty { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .4; }
.empty-text { font-size: 15px; }


/* ═══════════════════════════════════════════
   IMAGE GRID
   ═══════════════════════════════════════════ */

.img-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 20px;
}
.img-item { display: flex; flex-direction: column; gap: 6px; }
.img-caption {
  display: block;
  width: 100%;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  transition: border-color .2s;
}
.img-caption:focus { border-color: var(--accent); }
.img-caption::placeholder { color: var(--text-dim); }
.img-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 3px solid transparent;
}
.img-thumb img { width:100%; height:100%; object-fit:cover; }
.img-thumb.is-cover { border-color: var(--accent); }
.img-thumb-actions {
  position: absolute; top:6px; right:6px;
  display: flex; gap:4px; opacity:0; transition: opacity .2s;
}
.img-thumb:hover .img-thumb-actions { opacity:1; }
.img-act {
  width:30px; height:30px;
  display:flex; align-items:center; justify-content:center;
  background: rgba(0,0,0,.75);
  border:none; border-radius:6px;
  color:#fff; font-size:14px; cursor:pointer;
}
.img-act:hover { background: var(--accent); color: var(--accent-text); }
.img-act.del:hover { background: var(--danger); color: #fff; }


/* ═══════════════════════════════════════════
   UPLOAD ZONE
   ═══════════════════════════════════════════ */

.upload-zone {
  display: block;
  width: 100%;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.upload-zone:hover,
.upload-zone.drag { border-color: var(--accent); }
.upload-zone-text { font-size: 15px; font-weight: 600; color: var(--text-mid); margin-bottom: 6px; }
.upload-zone-hint { font-size: 13px; color: var(--text-dim); }
.upload-progress { margin-top:16px; height:4px; background:var(--bg-3); border-radius:2px; overflow:hidden; display:none; }
.upload-progress-bar { height:100%; background:var(--accent); width:0%; transition:width .3s; }


/* ═══════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════ */

.modal-bg {
  position:fixed; inset:0; background:rgba(0,0,0,.7);
  z-index:1500; display:flex; align-items:center; justify-content:center;
}
.modal-bg.hidden { display:none; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px;
  width:90%; max-width:580px; max-height:85vh; overflow-y:auto;
}
.modal-actions { display:flex; justify-content:flex-end; gap:12px; margin-top:24px; }

.msg-detail { max-width: 100%; }
.msg-from { font-weight:700; font-size:18px; margin-bottom:4px; }
.msg-email { font-size:14px; color:var(--text-dim); margin-bottom:16px; }
.msg-body {
  font-size:15px; line-height:1.7; color:var(--text-mid);
  white-space:pre-wrap; padding:20px;
  background:var(--bg); border-radius:var(--radius); border:1px solid var(--border);
}
.msg-date { font-size:12px; color:var(--text-dim); margin-top:16px; }


/* ═══════════════════════════════════════════
   DRAG & DROP
   ═══════════════════════════════════════════ */

.drag-handle {
  cursor: grab;
  color: var(--text-dim);
  font-size: 18px;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  transition: color .2s;
}
.drag-handle:hover { color: var(--accent); }
.drag-handle:active { cursor: grabbing; }
.drag-icon { display: inline; }
.move-btns { display: none; gap: 2px; }
.move-btn {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 10px;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all .2s;
  padding: 0;
}
.move-btn:hover { color: var(--accent); border-color: var(--accent); }
.move-btn-blank { width: 26px; height: 26px; }

.move-btns-img { display: none; gap: 4px; justify-content: center; padding: 4px 0; }
.img-bottom { display: flex; flex-direction: column; }

@media (max-width: 900px) {
  .drag-icon { display: none; }
  .move-btns { display: flex; }
  .move-btns-img { display: flex; }
  .drag-item { cursor: default; }
  .drag-item[draggable] { -webkit-user-drag: none; }
}

.drag-row { transition: background .15s; }
.drag-row.dragging { opacity: 0.4; background: var(--bg-hover); }
.drag-row.drag-over {
  border-top: 2px solid var(--accent);
}

.drag-item { transition: transform .15s, opacity .15s; cursor: grab; }
.drag-item.dragging { opacity: 0.3; transform: scale(0.95); }
.drag-item.drag-over-item {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius);
}
.drag-item:active { cursor: grabbing; }

.drag-placeholder {
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  opacity: 0.3;
}


/* ═══════════════════════════════════════════
   STATS DASHBOARD
   ═══════════════════════════════════════════ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}
.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
}
.stats-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width:900px) {
  .stats-cols { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.stats-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.stats-bar-label { flex: 1; color: var(--text-mid); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.stats-bar-value { font-weight: 700; color: var(--text); min-width: 40px; text-align: right; }
.stats-bar-fill {
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  min-width: 2px;
}
.stats-chart {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 120px;
  padding-top: 8px;
}
.stats-chart-bar {
  flex: 1;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.8;
  position: relative;
}
.stats-chart-bar:hover { opacity: 1; }
.stats-chart-bar[title]:hover::after {
  content: attr(title);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-2);
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-size: 10px;
  white-space: nowrap;
  border-radius: 4px;
  color: var(--text);
}


/* ═══════════════════════════════════════════
   SECTIONS
   ═══════════════════════════════════════════ */

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


/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

/* ═══════════════════════════════════════════
   ADMIN MOBILE HEADER
   ═══════════════════════════════════════════ */

.admin-mobile-hdr {
  display: none;
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  background: var(--bg-2); border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  align-items: center; gap: 12px;
}
.admin-mobile-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: var(--radius); padding: 6px 10px;
  font-size: 18px; color: var(--text); cursor: pointer;
}
.admin-mobile-logo { font-weight: 700; font-size: 16px; letter-spacing: 2px; flex: 1; }


/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */

@media (max-width:900px) {
  .admin-mobile-hdr { display: flex; }
  .admin-layout { flex-direction: column; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform .3s;
    z-index: 55;
    padding-top: 60px;
  }
  .sidebar.open { transform: translateX(0); }
  .main {
    margin-left: 0; padding: 72px 16px 24px;
    width: 100%; max-width: 100%;
  }
  .form-row { grid-template-columns: 1fr; }
  .page-hdr { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* Tables → stacked cards on mobile */
  .tbl-wrap table,
  .tbl-wrap thead,
  .tbl-wrap tbody,
  .tbl-wrap tr,
  .tbl-wrap th,
  .tbl-wrap td {
    display: block;
    width: 100%;
  }
  .tbl-wrap thead { display: none; }
  .tbl-wrap tr {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
  }
  .tbl-wrap td {
    padding: 4px 0;
    border: none;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
  }
  .tbl-wrap td:before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    min-width: 80px;
  }
  .tbl-wrap td:last-child {
    padding-top: 10px;
    margin-top: 6px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
  }
  .tbl-wrap tr:hover td { background: transparent; }

  /* Card padding on mobile */
  .card { padding: 20px; }
  .img-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
