/* =========================================================
   EYJ Technologies — Admin dashboard stylesheet
   ========================================================= */

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

:root {
  --navy:          #0A1F4A;
  --cyan:          #06B3F0;
  --brand-gradient: linear-gradient(135deg, var(--navy) 0%, var(--cyan) 100%);

  --bg:            #F5F7FC;
  --bg-elevated:   #FFFFFF;
  --bg-elevated-2: #EEF2FB;
  --border:        #E1E8F2;
  --text:          #0A1F4A;
  --text-muted:    #5B6785;
  --primary:       #06B3F0;
  --primary-dark:  #0592C4;
  --primary-soft:  #E5F7FE;
  --accent:        #0A1F4A;
  --accent-soft:   #EAEEF7;
  --danger:        #D64545;
  --danger-soft:   #FDECEC;
  --success:       #16A879;
  --success-soft:  #E9FBF3;
  --radius:        10px;
  --shadow-sm: 0 1px 2px rgba(10,31,74,0.05), 0 1px 3px rgba(10,31,74,0.07);
  --shadow-md: 0 10px 26px -12px rgba(10,31,74,0.16);
  --font-head: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { overflow-x: hidden; width: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: var(--font-head); font-weight: 600; margin: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
p { color: var(--text-muted); }
code { font-family: 'SFMono-Regular', Menlo, Consolas, monospace; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: 8px; font-family: var(--font-head);
  font-weight: 600; font-size: 0.92rem; border: 1px solid transparent; cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }

/* ---------- Auth pages ---------- */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 14px; padding: 36px; box-shadow: var(--shadow-md);
}
.auth-card h1 { font-size: 1.4rem; margin-bottom: 6px; }
.auth-logo { width: 44px; height: 44px; margin-bottom: 14px; }
.auth-card .muted { font-size: 0.88rem; margin-bottom: 20px; }
.auth-card .small { margin-top: 18px; text-align: center; margin-bottom: 0; }

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

.admin-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(10,31,74,0.45);
  z-index: 65; opacity: 0; transition: opacity 0.25s ease;
}
.admin-backdrop.open { display: block; opacity: 1; }

.admin-sidebar {
  width: 220px; flex-shrink: 0; background: #fff;
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 22px 16px; position: sticky; top: 0; height: 100vh;
  transition: transform 0.3s ease;
}
.sidebar-toggle { display: none; }
.admin-topbar-left { display: flex; align-items: center; gap: 14px; }
.admin-brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; padding: 0 8px 24px; }
.admin-brand .mark { width: 30px; height: 30px; border-radius: 8px; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.admin-brand .brand-logo { width: 30px; height: 30px; }
.admin-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.admin-nav a { color: var(--text-muted); padding: 10px 12px; border-radius: 8px; font-size: 0.92rem; }
.admin-nav a:hover { background: var(--bg-elevated-2); color: var(--text); text-decoration: none; }
.admin-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.admin-sidebar-footer { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--border); padding-top: 14px; }
.admin-sidebar-footer a { padding: 8px 12px; font-size: 0.85rem; color: var(--text-muted); }
.admin-sidebar-footer a:hover { color: var(--text); text-decoration: none; }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 32px; border-bottom: 1px solid var(--border); background: #fff;
}
.admin-topbar h1 { font-size: 1.3rem; }
.admin-user { font-size: 0.85rem; color: var(--text-muted); }
.admin-content { padding: 28px 32px 60px; max-width: 1180px; }

/* ---------- Cards / panels ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
@media (max-width: 900px) { .stat-cards { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.stat-card .label { font-size: 0.82rem; color: var(--text-muted); }
.stat-card .value { font-family: var(--font-head); font-size: 1.9rem; font-weight: 700; }
.stat-card .hint { font-size: 0.78rem; color: var(--text-muted); }
.stat-card a { font-size: 0.82rem; }

.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { font-size: 1.05rem; }
.panel-head a { font-size: 0.85rem; }
.empty { font-size: 0.9rem; }

/* ---------- Forms ---------- */
.admin-form .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 640px) { .admin-form .form-grid { grid-template-columns: 1fr; } }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 6px; }
.field input[type=text], .field input[type=email], .field input[type=url],
.field input[type=password], .field input[type=date], .field input[type=number],
.field select, .field textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 11px 13px; color: var(--text); font-family: var(--font-body); font-size: 0.92rem;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.field input[type=file] { color: var(--text-muted); font-size: 0.85rem; }
.checkbox-field label { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--text); }
.checkbox-field input { width: auto; }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table-scroll { overflow-x: auto; }
.admin-table th {
  text-align: left; color: var(--text-muted); font-weight: 500; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 10px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .actions { display: flex; gap: 12px; flex-wrap: wrap; }
.admin-table .actions form { display: inline; }

.license-key { background: var(--bg-elevated-2); padding: 4px 8px; border-radius: 6px; letter-spacing: 0.03em; cursor: pointer; }

.link-action, .link-danger {
  background: none; border: none; padding: 0; font-size: 0.85rem; cursor: pointer; font-family: var(--font-body);
}
.link-action { color: var(--primary); }
.link-danger { color: var(--danger); }
.link-action:hover, .link-danger:hover { text-decoration: underline; }

/* ---------- Pills ---------- */
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.76rem; font-weight: 600; white-space: nowrap; }
.pill-active, .pill-software, .pill-approved { background: var(--success-soft); color: var(--success); }
.pill-inactive, .pill-revoked, .pill-rejected { background: var(--danger-soft); color: var(--danger); }
.pill-online_service { background: var(--primary-soft); color: var(--primary); }
.pill-general { background: var(--accent-soft); color: #5B6785; }
.pill-pending { background: #FFF6E5; color: #B5790B; }
.pill-expired { background: #EEF0F5; color: var(--text-muted); }

/* ---------- Messages ---------- */
.message-list { display: flex; flex-direction: column; gap: 14px; }
.message-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.message-card.unread { border-color: var(--primary); background: var(--primary-soft); }
.message-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; gap: 12px; }
.message-card p { color: var(--text); font-size: 0.92rem; margin: 0 0 12px; }
.message-card .actions { display: flex; gap: 14px; }

/* ---------- Notices ---------- */
.notice { padding: 13px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 0.9rem; line-height: 1.6; }
.notice.success { background: var(--success-soft); color: #0E8A5F; border: 1px solid #BDEFDA; }
.notice.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #F6CFCF; }
.notice code { background: rgba(10,31,74,0.06); padding: 2px 6px; border-radius: 4px; }

.muted { color: var(--text-muted); }
.muted.small, .small { font-size: 0.8rem; }

/* ---------- Responsive: admin dashboard ---------- */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; z-index: 70;
    box-shadow: var(--shadow-md);
    transform: translateX(-100%);
  }
  .admin-sidebar.open { transform: translateX(0); }

  .sidebar-toggle {
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 34px; height: 34px; background: none; border: 1px solid var(--border);
    border-radius: 8px; cursor: pointer; flex-shrink: 0;
  }
  .sidebar-toggle span { display: block; width: 16px; height: 2px; background: var(--text); margin: 0 auto; border-radius: 2px; }

  .admin-topbar { padding: 16px 18px; }
  .admin-topbar h1 { font-size: 1.05rem; }
  .admin-user { display: none; }
  .admin-content { padding: 18px 18px 48px; }

  .stat-cards { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .panel { padding: 18px; }
  .admin-form .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .stat-cards { grid-template-columns: 1fr; }
  .stat-card .value { font-size: 1.6rem; }
  .auth-card { padding: 26px; }
  .admin-table .actions { flex-direction: column; gap: 6px; align-items: flex-start; }
}
