/* =============================================
   dashboard.css — Dashboard & App Pages
   Glassmorphism dark theme
   Reusable across: dashboard, publish, contracts, identity, admin
   ============================================= */

/* ── Layout ── */
.app-layout {
  display: flex;
  min-height: 100vh;
  padding-top: 80px;
}

/* Sticky (not fixed) so the sidebar lives inside .app-layout and naturally
   ends when the layout ends. Fixed positioning made it overlap the footer,
   which renders below .app-layout at full width. */
.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  position: sticky;
  top: 80px;
  align-self: flex-start;
  height: calc(100vh - 80px);
  background: var(--bg-glass-heavy);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-right: var(--glass-border);
  padding: 1.5rem 0;
  overflow-y: auto;
  z-index: 10;
  transition: transform 0.3s;
}

.app-sidebar-nav { list-style: none; padding: 0; margin: 0; }

.app-sidebar-section {
  padding: 0.5rem 1.25rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-top: 1rem;
}

.app-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}

.app-sidebar-link:hover {
  background: rgba(255,255,255,0.04);
  color: var(--text-primary);
}

.app-sidebar-link.active {
  color: var(--primary-light);
  background: rgba(124, 58, 237, 0.08);
  border-left-color: var(--primary);
}

.app-sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}

.app-sidebar-link.active svg { opacity: 1; }

.app-sidebar-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.app-main {
  flex: 1;
  padding: 2rem;
  min-height: calc(100vh - 80px);
  min-width: 0; /* lets grid/flex children shrink instead of overflowing the viewport */
}

/* Primary action button rendered inline in the sidebar (Publicar propiedad).
   Looks like a gradient pill so the call-to-action stands apart from regular nav items. */
.app-sidebar-link.app-sidebar-link--primary {
  margin: 0.4rem 1rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff !important;
  font-weight: 600;
  border-left: 0;
  box-shadow: 0 6px 18px rgba(124, 58, 237, 0.32);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.app-sidebar-link.app-sidebar-link--primary svg { opacity: 1; }
.app-sidebar-link.app-sidebar-link--primary:hover {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(124, 58, 237, 0.45);
}
.app-sidebar-link.app-sidebar-link--primary.active { color: #fff !important; }

/* Admin items inside the user sidebar — hidden unless navbar.js confirmed
   role=admin via /auth/me (it toggles body.is-admin). Mirrors the navbar
   dropdown's .nav-dd-admin pattern. */
.app-sidebar-admin { display: none; }
body.is-admin .app-sidebar-admin { display: list-item; }
body.is-admin li.app-sidebar-section.app-sidebar-admin { display: list-item; }

/* ── Page Header ── */
.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
}

.page-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

/* ── Stats Cards Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--glass-shadow);
}

.stat-card-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.stat-card-icon {
  float: right;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.stat-card-icon.purple { background: rgba(124, 58, 237, 0.15); color: var(--primary-light); }
.stat-card-icon.cyan { background: rgba(6, 182, 212, 0.15); color: var(--secondary); }
.stat-card-icon.pink { background: rgba(244, 114, 182, 0.15); color: var(--accent); }
.stat-card-icon.green { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.stat-card-icon.yellow { background: rgba(251, 191, 36, 0.15); color: var(--warning); }

/* ── Glass Panel ── */
.panel {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.panel-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-body { padding: 1.5rem; }
.panel-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.05);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

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

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

.table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.table td {
  padding: 0.75rem 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(255,255,255,0.03);
  vertical-align: middle;
}

.table tbody tr:hover { background: rgba(255,255,255,0.02); }

/* ── Status Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-pending { background: rgba(251, 191, 36, 0.15); color: var(--warning); }
.badge-signed { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.badge-approved { background: rgba(52, 211, 153, 0.15); color: var(--success); }
.badge-rejected { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.badge-expired { background: rgba(100, 116, 139, 0.15); color: var(--text-muted); }
.badge-sent { background: rgba(96, 165, 250, 0.15); color: var(--info); }
.badge-draft { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
.badge-owner { background: rgba(124, 58, 237, 0.15); color: var(--primary-light); }
.badge-third-party { background: rgba(6, 182, 212, 0.15); color: var(--secondary); }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

/* ── Stepper (for multi-step forms) ── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
  padding: 0 1rem;
}

.step {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  flex: 1;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  border: 2px solid rgba(255,255,255,0.1);
  color: var(--text-muted);
  background: var(--bg-surface);
  flex-shrink: 0;
  transition: all 0.3s;
}

.step-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}

.step-line {
  flex: 1;
  height: 2px;
  background: rgba(255,255,255,0.08);
  margin: 0 0.5rem;
}

.step.active .step-number {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 0 15px var(--primary-glow);
}

.step.active .step-label { color: var(--primary-light); }

.step.done .step-number {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.step.done .step-label { color: var(--success); }
.step.done + .step-line { background: var(--success); }

/* ── File Upload Zone ── */
.upload-zone {
  border: 2px dashed rgba(255,255,255,0.1);
  border-radius: var(--radius-md);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.05);
}

.upload-zone-icon {
  font-size: 2rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.upload-zone-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.upload-zone-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255,255,255,0.03);
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.06);
  margin-top: 0.75rem;
}

.upload-preview-name {
  flex: 1;
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-preview-remove {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
}

/* ── Contract Viewer ── */
.contract-viewer {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius-md);
  padding: 2rem;
  max-height: 500px;
  overflow-y: auto;
  font-size: 0.875rem;
  line-height: 1.8;
  color: var(--text-secondary);
}

.contract-viewer h1 { font-size: 1.25rem; color: var(--text-primary); margin-bottom: 0.5rem; }
.contract-viewer h2 { font-size: 1.1rem; color: var(--primary-light); margin: 1rem 0 0.5rem; }
.contract-viewer h3 { font-size: 1rem; color: var(--text-primary); margin: 1.25rem 0 0.5rem; }
.contract-viewer h4 { font-size: 0.9rem; color: var(--text-primary); margin: 1rem 0 0.4rem; }

.contract-viewer table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
}

.contract-viewer th,
.contract-viewer td {
  padding: 0.5rem 0.75rem;
  border: 1px solid rgba(255,255,255,0.08);
  text-align: left;
  font-size: 0.8rem;
}

.contract-viewer th {
  background: rgba(255,255,255,0.04);
  font-weight: 600;
  color: var(--text-primary);
}

.contract-viewer ul,
.contract-viewer ol {
  padding-left: 1.5rem;
  margin: 0.5rem 0;
}

.contract-viewer li { margin-bottom: 0.3rem; }

.contract-viewer .signature-block {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 2px solid rgba(255,255,255,0.08);
}

/* ── Checkbox Confirm ── */
.confirm-check {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.2s;
}

.confirm-check:hover { border-color: var(--primary); }

.confirm-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.confirm-check-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ── Alert Box ── */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-info {
  background: rgba(96, 165, 250, 0.1);
  border: 1px solid rgba(96, 165, 250, 0.2);
  color: var(--info);
}

.alert-success {
  background: rgba(52, 211, 153, 0.1);
  border: 1px solid rgba(52, 211, 153, 0.2);
  color: var(--success);
}

.alert-warning {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.2);
  color: var(--warning);
}

.alert-danger {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--danger);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.75rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 1rem;
}

.pagination-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  transition: all 0.2s;
}

.pagination-btn:hover { background: rgba(255,255,255,0.05); }
.pagination-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-elevated);
  border: var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--glass-shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── Loading Skeleton ── */
.skeleton {
  background: linear-gradient(90deg, rgba(255,255,255,0.04) 25%, rgba(255,255,255,0.08) 50%, rgba(255,255,255,0.04) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  /* Drawer-style overlay on tablet/mobile — taken out of the flex flow so
     .app-main can use the full width when the sidebar is closed. */
  .app-sidebar {
    position: fixed;
    top: 80px;
    left: 0;
    bottom: 0;
    height: auto;
    transform: translateX(-100%);
  }
  .app-sidebar.open { transform: translateX(0); }
}

@media (max-width: 768px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .stepper { flex-wrap: wrap; }
  .step-line { display: none; }
  .app-main { padding: 1rem; }
  .panel-body { padding: 1rem; }
}

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .page-title { font-size: 1.35rem; }
}
