/* ═══════════════════════════════════════════════════════════════
   Patent Portal — Admin Panel Stylesheet
   ═══════════════════════════════════════════════════════════════ */

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

:root {
  --blue-dark:  #003366;
  --blue-mid:   #1a3c6e;
  --blue-light: #e8eef6;
  --gold:       #c9a227;
  --white:      #ffffff;
  --gray-bg:    #f0f2f5;
  --gray-light: #e0e3e8;
  --gray-mid:   #888;
  --gray-text:  #333;
  --red:        #c0392b;
  --red-light:  #fdecea;
  --green:      #1a7a3c;
  --green-light:#d4edda;
  --sidebar-w:  240px;
  --topbar-h:   56px;
  --radius:     3px;
  --shadow:     0 1px 3px rgba(0,0,0,.12);
}

html { font-size: 15px; }
body {
  font-family: 'PT Sans', 'Open Sans', 'Segoe UI', Arial, sans-serif;
  color: var(--gray-text);
  background: var(--gray-bg);
}
a { color: var(--blue-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
ul { list-style: none; }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  padding: .45rem 1.1rem;
  font-size: .85rem;
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  text-align: center;
  line-height: 1.3;
  text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn-primary  { background: var(--blue-dark); color: #fff; border-color: var(--blue-dark); }
.btn-primary:hover  { background: var(--blue-mid); border-color: var(--blue-mid); color:#fff; }
.btn-outline  { background: transparent; color: var(--blue-dark); border-color: var(--blue-dark); }
.btn-outline:hover  { background: var(--blue-dark); color: #fff; }
.btn-danger   { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover   { background: #a93226; border-color: #a93226; color:#fff; }
.btn-sm       { padding: .28rem .65rem; font-size: .78rem; }
.btn-block    { display: block; width: 100%; }

/* ── Alerts ───────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-left: 4px solid;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  font-size: .87rem;
}
.alert-success { background: var(--green-light); border-color: var(--green); color: #155724; }
.alert-error   { background: var(--red-light);   border-color: var(--red);   color: #721c24; }
.alert-info    { background: #d1ecf1;             border-color: #0c7090;      color: #0c5460; }
.alert ul { padding-left: 1.2em; list-style: disc; }
.alert ul li { margin-bottom: .2rem; }

/* ── Badges ───────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .18em .6em;
  font-size: .72rem;
  font-weight: 700;
  border-radius: 2px;
  white-space: nowrap;
  letter-spacing: .02em;
}
.status-active      { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status-nodata      { background: #e9ecef; color: #495057; border: 1px solid #ced4da; }
.status-warn        { background: #fff3cd; color: #856404; border: 1px solid #ffc107; }
.status-restorable  { background: #cce5ff; color: #004085; border: 1px solid #b8daff; }
.status-expired     { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.badge-admin        { background: var(--blue-light); color: var(--blue-dark); }
.badge-manager      { background: #e8f5e9; color: #2e7d32; }

/* ═══════════════════════════════════════════════════════════════
   ADMIN LAYOUT
   ═══════════════════════════════════════════════════════════════ */
.admin-body { min-height: 100vh; }

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

/* ── Sidebar ──────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--blue-dark);
  color: rgba(255,255,255,.85);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 200;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-brand {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-brand a {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--white);
  font-size: .9rem;
  font-weight: 700;
  text-decoration: none;
}
.sidebar-brand a:hover { color: var(--gold); }
.brand-icon { font-size: 1.2rem; }

.sidebar-nav { flex: 1; padding: .75rem 0; }
.sidebar-nav ul { display: flex; flex-direction: column; gap: 2px; }

.nav-section {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.4);
  padding: .85rem 1.25rem .3rem;
}

.sidebar-nav ul li a {
  display: block;
  padding: .55rem 1.25rem;
  color: rgba(255,255,255,.8);
  font-size: .85rem;
  border-left: 3px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
  text-decoration: none;
}
.sidebar-nav ul li a:hover,
.sidebar-nav ul li a.active {
  background: rgba(255,255,255,.08);
  color: var(--white);
  border-left-color: var(--gold);
  text-decoration: none;
}

.sidebar-user {
  padding: .9rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: .8rem;
}
.user-info {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: .6rem;
}
.user-icon { font-size: 1.3rem; }
.user-info strong { display: block; color: var(--white); font-size: .82rem; }
.user-info small  { color: rgba(255,255,255,.5); font-size: .72rem; }
.btn-logout {
  display: block;
  text-align: center;
  padding: .3rem;
  font-size: .78rem;
  color: rgba(255,255,255,.65);
  border: 1px solid rgba(255,255,255,.2);
  border-radius: var(--radius);
  transition: background .12s, color .12s;
}
.btn-logout:hover { background: rgba(255,255,255,.12); color: var(--white); text-decoration: none; }

/* ── Main area ────────────────────────────────────────────────── */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,.07);
}
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--gray-text);
  padding: .2rem .4rem;
}
.page-heading {
  flex: 1;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--blue-dark);
}

.admin-content {
  flex: 1;
  padding: 1.5rem;
}

/* ── Dashboard stats ──────────────────────────────────────────── */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-top: 3px solid var(--blue-dark);
  padding: 1.25rem 1.1rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.stat-card--green { border-top-color: var(--green); }
.stat-card--blue  { border-top-color: #1565c0; }
.stat-card--gold  { border-top-color: var(--gold); }
.stat-val { font-size: 1.9rem; font-weight: 700; color: var(--blue-dark); line-height: 1.1; }
.stat-lbl { font-size: .75rem; color: var(--gray-mid); text-transform: uppercase; letter-spacing: .05em; margin-top: .2rem; }

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.mt-4 { margin-top: 1.5rem; }

.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--gray-light);
  background: var(--gray-bg);
}
.card-header-row h2 { font-size: .95rem; font-weight: 700; color: var(--blue-dark); }

.card-footer-row {
  padding: .6rem 1.1rem;
  border-top: 1px solid var(--gray-light);
  font-size: .83rem;
  background: var(--gray-bg);
  text-align: right;
}

.table-info {
  padding: .5rem 1.1rem;
  font-size: .82rem;
  color: var(--gray-mid);
  border-bottom: 1px solid var(--gray-light);
}

/* ── Tables ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.data-table th {
  background: var(--gray-bg);
  border-bottom: 2px solid var(--gray-light);
  padding: .6rem .85rem;
  text-align: left;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--gray-mid);
  white-space: nowrap;
}
.data-table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--gray-light);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--blue-light); }
.row-inactive td { opacity: .55; }
.empty-row { text-align: center; color: var(--gray-mid); padding: 2rem; }
.col-num { width: 120px; }
.actions { white-space: nowrap; display: flex; gap: .35rem; }

/* ── Toolbar ──────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar-form {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  flex: 1;
}
.toolbar-form input,
.toolbar-form select {
  padding: .4rem .7rem;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  font-size: .85rem;
  background: var(--white);
  color: var(--gray-text);
}
.toolbar-form input:focus,
.toolbar-form select:focus {
  outline: none;
  border-color: var(--blue-dark);
  box-shadow: 0 0 0 2px rgba(0,51,102,.1);
}
.toolbar-form input { width: 240px; }

/* ── Pagination ───────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .25rem;
  padding: .75rem;
  border-top: 1px solid var(--gray-light);
  flex-wrap: wrap;
}
.page-link {
  display: inline-block;
  padding: .3rem .65rem;
  font-size: .82rem;
  border: 1px solid var(--gray-light);
  color: var(--blue-dark);
  border-radius: var(--radius);
  transition: background .12s, color .12s;
  text-decoration: none;
  min-width: 1.9rem;
  text-align: center;
}
.page-link:hover { background: var(--blue-dark); color: #fff; text-decoration: none; }
.page-link.active { background: var(--blue-dark); color: #fff; border-color: var(--blue-dark); pointer-events: none; }
.page-ellipsis { color: var(--gray-mid); font-size: .82rem; padding: .3rem .25rem; }

/* ═══════════════════════════════════════════════════════════════
   PATENT FORM
   ═══════════════════════════════════════════════════════════════ */
.patent-form { max-width: 1100px; }

.form-section {
  background: var(--white);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.form-section--required { border-top: 3px solid var(--blue-dark); }

.section-title {
  font-size: .85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--blue-dark);
  margin-bottom: .85rem;
  padding-bottom: .5rem;
  border-bottom: 1px solid var(--gray-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.required-note { font-size: .72rem; color: var(--gray-mid); text-transform: none; letter-spacing: 0; font-weight: 400; }

.form-group { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .75rem; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--gray-text); }
.form-group small  { font-size: .72rem; color: var(--gray-mid); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: .42rem .7rem;
  border: 1px solid #ccc;
  border-radius: var(--radius);
  font-size: .87rem;
  font-family: inherit;
  color: var(--gray-text);
  background: var(--white);
  transition: border-color .12s, box-shadow .12s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--blue-dark);
  box-shadow: 0 0 0 2px rgba(0,51,102,.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group--wide { flex: 2; }
.form-group--check { justify-content: flex-end; }
.form-row { display: flex; gap: .75rem; flex-wrap: wrap; }
.form-row > .form-group { flex: 1; min-width: 160px; }
.mt-2 { margin-top: .75rem; }

.req { color: var(--red); font-size: .85em; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .88rem;
  font-weight: normal !important;
}
.checkbox-label input[type="checkbox"] { width: 1rem; height: 1rem; cursor: pointer; }

.form-note { font-size: .82rem; color: var(--gray-mid); padding: .5rem 0; }

.form-actions {
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: 1rem 0;
}

/* ── File manager ─────────────────────────────────────────────── */
.files-manager { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .5rem; }
.file-row {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem .75rem;
  background: var(--gray-bg);
  border: 1px solid var(--gray-light);
  border-radius: var(--radius);
  font-size: .83rem;
}
.file-row .file-icon { font-size: 1.2rem; flex-shrink: 0; }
.file-row .file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .file-size { color: var(--gray-mid); white-space: nowrap; }
.file-count { font-size: .77rem; color: var(--gray-mid); margin-top: .25rem; }
.empty-note { font-size: .85rem; color: var(--gray-mid); }

.file-list-preview { margin-top: .5rem; }
.file-list-preview div {
  font-size: .8rem;
  color: var(--gray-text);
  padding: .2rem 0;
  border-bottom: 1px solid var(--gray-light);
}

/* ── Edit top actions ─────────────────────────────────────────── */
.edit-actions-top {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

/* ── Form card ────────────────────────────────────────────────── */
.form-card { padding: 1.5rem; max-width: 680px; }

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ═══════════════════════════════════════════════════════════════ */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue-mid) 100%);
}
.login-wrapper { width: 100%; max-width: 400px; padding: 1.5rem; }
.login-card {
  background: var(--white);
  border-radius: 4px;
  padding: 2.25rem;
  box-shadow: 0 4px 24px rgba(0,0,0,.3);
}
.login-header { text-align: center; margin-bottom: 1.75rem; }
.login-logo { margin-bottom: .85rem; }
.login-header h1 { font-size: 1.15rem; font-weight: 700; color: var(--blue-dark); margin-bottom: .3rem; }
.login-header p  { font-size: .83rem; color: var(--gray-mid); }
.login-footer { text-align: center; margin-top: 1.25rem; font-size: .82rem; }
.login-footer a { color: var(--blue-dark); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 860px) {
  .admin-sidebar {
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: block; }
  .stats-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .stats-cards { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-form { flex-direction: column; }
  .toolbar-form input { width: 100%; }
  .form-row { flex-direction: column; }
  .admin-content { padding: 1rem; }
}

/* ── Other priorities dynamic rows ────────────────────────────── */
.op-row { margin-bottom: .4rem; }
.op-row-fields { align-items: flex-end; flex-wrap: nowrap; }
.op-row-fields .form-group { margin-bottom: 0; }
.form-group--btn-only { flex: 0 0 auto; min-width: unset; justify-content: flex-end; }
.form-hint { font-size: .72rem; color: var(--gray-mid); display: block; margin-top: .35rem; }
.mt-1 { margin-top: .4rem; }

/* ── Image preview ────────────────────────────────────────────── */
.current-image-preview { display: flex; flex-direction: column; gap: .35rem; }

/* ── Image thumbnails in patent list ─────────────────────────── */
.data-table .thumb-cell img {
  width: 52px; height: 40px; object-fit: cover; border-radius: 2px;
  border: 1px solid var(--gray-light); display: block;
}

/* ── Banner form: section label ───────────────────────────────── */
.form-section-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--blue-dark);
  padding: .6rem 0 .3rem;
  border-bottom: 1px solid var(--gray-light);
  margin-bottom: .85rem;
  margin-top: .75rem;
  display: block;
}
.form-section-label small {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gray-mid);
  font-size: .7rem;
}