/* ============================================================
   MediaNet Platform — Admin UI Stylesheet
   Mobile-first, no external frameworks
   ============================================================ */

:root {
  --primary:    #1a56db;
  --primary-d:  #1240a0;
  --success:    #0e9f6e;
  --danger:     #e02424;
  --warning:    #c27803;
  --text:       #111827;
  --text-muted: #6b7280;
  --border:     #e5e7eb;
  --bg:         #f3f4f6;
  --white:      #ffffff;
  --sidebar-w:  240px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #cbd5e1;
  --topbar-h:   56px;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.1),0 1px 2px rgba(0,0,0,.06);
  --shadow-lg:  0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1);
}

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

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- SIDEBAR ---- */
#sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex; flex-direction: column;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform .25s ease;
  overflow-y: auto;
}

body.sidebar-open #sidebar { transform: translateX(0); }

#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}

body.sidebar-open #sidebar-overlay { display: block; }

.sidebar-brand {
  padding: 1.2rem 1rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  display: flex; align-items: center; gap: .6rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-user {
  padding: .9rem 1rem;
  display: flex; align-items: center; gap: .7rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  font-size: .82rem;
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .9rem;
  flex-shrink: 0;
}

.user-name { color: #fff; font-weight: 600; font-size: .83rem; }
.user-role { color: var(--sidebar-text); font-size: .73rem; }

.nav-menu { list-style: none; padding: .5rem 0; flex: 1; }

.nav-section {
  padding: .8rem 1rem .3rem;
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 600;
}

.nav-item a {
  display: flex; align-items: center; gap: .65rem;
  padding: .55rem 1rem;
  color: var(--sidebar-text);
  font-size: .88rem;
  border-radius: var(--radius);
  margin: 0 .4rem;
  transition: background .15s, color .15s;
}

.nav-item a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-item.active a { background: var(--primary); color: #fff; }
.nav-icon { width: 18px; text-align: center; }

/* ---- TOPBAR ---- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.2rem;
  box-shadow: var(--shadow);
}

.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  font-size: 1.3rem; color: var(--text); padding: .2rem .4rem;
}

.page-title { font-size: 1rem; font-weight: 700; flex: 1; }

.topbar-right { display: flex; align-items: center; gap: .8rem; }

.cart-badge {
  background: var(--primary);
  color: #fff; padding: .3rem .7rem;
  border-radius: 999px; font-size: .8rem; font-weight: 600;
}
.cart-badge:hover { background: var(--primary-d); text-decoration: none; }

/* ---- MAIN CONTENT ---- */
#main-content { min-height: 100vh; }
.page-body { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

@media (min-width: 900px) {
  #sidebar { transform: translateX(0); }
  body.has-sidebar #main-content { margin-left: var(--sidebar-w); }
  #sidebar-overlay { display: none !important; }
  .sidebar-toggle { display: none; }
}

/* ---- ALERTS ---- */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.2rem;
  font-size: .9rem;
  font-weight: 500;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }

/* ---- CARDS ---- */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.card-header {
  padding: .9rem 1.2rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 600; font-size: .95rem;
}

.card-body { padding: 1.2rem; }

/* ---- STATS GRID ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  box-shadow: var(--shadow);
}

.stat-label { font-size: .75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 800; margin: .2rem 0; }
.stat-sub   { font-size: .78rem; color: var(--text-muted); }

.stat-card.primary { border-left: 4px solid var(--primary); }
.stat-card.success { border-left: 4px solid var(--success); }
.stat-card.warning { border-left: 4px solid var(--warning); }
.stat-card.danger  { border-left: 4px solid var(--danger); }

/* ---- GRID LAYOUT ---- */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.mb-1   { margin-bottom: 1rem; }
.mb-2   { margin-bottom: 1.5rem; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }

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

th {
  text-align: left;
  padding: .65rem 1rem;
  background: #f9fafb;
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

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

tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

/* ---- FORMS ---- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; }
.form-full  { grid-column: 1 / -1; }

label { font-size: .82rem; font-weight: 600; color: var(--text-muted); }

input[type="text"], input[type="email"], input[type="number"],
input[type="date"], input[type="password"], input[type="tel"],
select, textarea {
  width: 100%;
  padding: .55rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.1);
}

textarea { min-height: 80px; resize: vertical; }

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border: none; border-radius: var(--radius);
  font-size: .88rem; font-weight: 600;
  cursor: pointer; font-family: inherit;
  transition: background .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: scale(.98); }
.btn:hover  { text-decoration: none; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-d); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-outline  { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }

/* ---- BADGES ---- */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.badge-available  { background: #d1fae5; color: #065f46; }
.badge-booked     { background: #dbeafe; color: #1e40af; }
.badge-reserved   { background: #fef3c7; color: #92400e; }
.badge-maintenance{ background: #fee2e2; color: #991b1b; }
.badge-blocked    { background: #f3f4f6; color: #374151; }
.badge-active     { background: #d1fae5; color: #065f46; }
.badge-confirmed  { background: #dbeafe; color: #1e40af; }
.badge-draft      { background: #f3f4f6; color: #6b7280; }
.badge-completed  { background: #ede9fe; color: #5b21b6; }
.badge-cancelled  { background: #fee2e2; color: #991b1b; }
.badge-paid       { background: #d1fae5; color: #065f46; }
.badge-partial    { background: #fef3c7; color: #92400e; }
.badge-unpaid     { background: #fee2e2; color: #991b1b; }
.badge-high       { background: #fee2e2; color: #991b1b; }
.badge-medium     { background: #fef3c7; color: #92400e; }
.badge-low        { background: #d1fae5; color: #065f46; }

/* ---- PHOTO GRID ---- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: .5rem;
}

.photo-grid img {
  width: 100%; height: 90px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ---- ASSET CARDS ---- */
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.asset-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .2s;
}

.asset-card:hover { box-shadow: var(--shadow-lg); }

.asset-card-img {
  height: 140px;
  background: #e5e7eb;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
}

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

.asset-card-body { padding: .9rem; }

.asset-id-code {
  font-size: .72rem;
  font-family: monospace;
  background: #f3f4f6;
  padding: .15rem .4rem;
  border-radius: 4px;
  color: var(--text-muted);
  font-weight: 600;
}

.asset-name { font-weight: 700; margin: .4rem 0 .2rem; font-size: .95rem; }
.asset-loc  { font-size: .8rem; color: var(--text-muted); }
.asset-rate { font-size: 1.1rem; font-weight: 800; color: var(--primary); margin: .5rem 0; }

/* ---- PAGINATION ---- */
.pagination {
  display: flex; gap: .4rem; justify-content: center;
  margin-top: 1.5rem; flex-wrap: wrap;
}

.pagination a, .pagination span {
  padding: .4rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .85rem;
  color: var(--text);
  background: var(--white);
}

.pagination a:hover    { background: var(--bg); text-decoration: none; }
.pagination .current   { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled  { color: var(--text-muted); pointer-events: none; }

/* ---- MISC ---- */
.text-muted  { color: var(--text-muted); }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.fw-bold     { font-weight: 700; }
.small       { font-size: .82rem; }
.mono        { font-family: monospace; }
.mt-1        { margin-top: 1rem; }
.flex-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }

/* ---- FILTER BAR ---- */
.filter-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
  display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end;
}

.filter-bar select, .filter-bar input { width: auto; min-width: 140px; }

/* ---- SUMMARY BOX ---- */
.summary-box {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}

.summary-row {
  display: flex; justify-content: space-between;
  padding: .3rem 0;
  font-size: .9rem;
  border-bottom: 1px solid var(--border);
}

.summary-row:last-child { border-bottom: none; }
.summary-row.total { font-weight: 800; font-size: 1.05rem; color: var(--primary); }

/* ---- RESPONSIVE ---- */
@media (max-width: 600px) {
  .page-body { padding: 1rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid  { grid-template-columns: 1fr; }
  .flex-between { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; }
  .filter-bar select, .filter-bar input { width: 100%; }
}

/* ---- LOGIN PAGE ---- */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

.login-box {
  background: var(--white);
  border-radius: 12px;
  padding: 2rem;
  width: 100%; max-width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.4);
}

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

.login-logo h2 { font-size: 1.3rem; font-weight: 800; margin-top: .5rem; }
.login-logo p  { color: var(--text-muted); font-size: .85rem; }
