/* PrintBridge Portal - Sidebar Layout */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #1a202c;
  line-height: 1.6;
  background: #f7fafc;
}

/* ===== LOGIN PAGE STYLES ===== */
body:not(.app-shell) {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
}

.wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: white;
  border-radius: 16px;
  padding: 48px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 440px;
}

.logo {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  color: white;
}
.logo svg { width: 36px; height: 36px; }

/* ===== APP SHELL (Dashboard) ===== */
body.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: #1a202c;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 20px 22px;
  border-bottom: 1px solid #2d3748;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}
.brand-icon svg { width: 18px; height: 18px; }

.brand-name {
  font-size: 17px;
  font-weight: 700;
  color: white;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.nav-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #2d3748;
}

.nav-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #718096;
  padding: 0 12px 8px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #a0aec0;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.nav-item svg { flex-shrink: 0; }
.nav-item:hover {
  background: #2d3748;
  color: white;
}
.nav-item.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #2d3748;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 15px;
}

.user-info { flex: 1; min-width: 0; }
.user-name {
  font-size: 14px;
  font-weight: 600;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 12px;
  color: #718096;
  text-transform: capitalize;
}

.btn-logout {
  width: 100%;
  background: transparent;
  border: 1px solid #2d3748;
  color: #a0aec0;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.btn-logout:hover {
  background: #2d3748;
  color: white;
}

.main {
  flex: 1;
  padding: 32px 40px;
  overflow-y: auto;
  max-width: 1200px;
}

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

.page-header {
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}
.page-header h1 {
  font-size: 26px;
  color: #1a202c;
  margin-bottom: 4px;
}
.page-header p {
  color: #718096;
  font-size: 15px;
}

/* ===== Quick Cards (Overview) ===== */
.quick-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.quick-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  border: 1px solid #e2e8f0;
  transition: all 0.2s;
  cursor: pointer;
}
.quick-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  border-color: #667eea;
}

.quick-card-icon {
  font-size: 36px;
  flex-shrink: 0;
}

.quick-card-body h3 {
  font-size: 16px;
  margin-bottom: 4px;
  color: #1a202c;
}
.quick-card-body p {
  font-size: 13px;
  color: #718096;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
}
.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #718096;
  font-weight: 600;
}
.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: #1a202c;
  margin-top: 4px;
}
.status-ok { color: #22543d; }

/* ===== Forms and inputs ===== */
h1 { font-size: 24px; color: #1a202c; }
h2 { font-size: 17px; margin: 20px 0 10px; color: #2d3748; }
h3 { font-size: 15px; color: #2d3748; margin-bottom: 6px; }
.subtitle { color: #718096; font-size: 14px; margin-bottom: 24px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 5px;
}
.field input, .field select {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid #e2e8f0;
  border-radius: 7px;
  font-size: 14px;
  background: white;
  font-family: inherit;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: #667eea;
}
.form-row { display: flex; gap: 14px; }
.form-row > .field { flex: 1; }

.btn-primary {
  background: #667eea;
  color: white;
  border: none;
  padding: 11px 22px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: #5a67d8; }
.btn-primary:disabled { background: #cbd5e0; cursor: not-allowed; }
.btn-large { font-size: 15px; padding: 14px 28px; }

.btn-link {
  background: none;
  border: none;
  color: #667eea;
  cursor: pointer;
  font-size: 14px;
  text-decoration: underline;
}

.btn-mini {
  background: #edf2f7;
  border: 1px solid #cbd5e0;
  color: #2d3748;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  margin-right: 4px;
}
.btn-mini:hover { background: #cbd5e0; }
.btn-danger { background: #fed7d7; color: #c53030; border-color: #fc8181; }
.btn-danger:hover { background: #feb2b2; }

.btn-warn { background: #feebc8; color: #7b341e; border-color: #f6ad55; }
.btn-warn:hover { background: #fbd38d; }

.btn-success { background: #c6f6d5; color: #22543d; border-color: #68d391; }
.btn-success:hover { background: #9ae6b4; }

.row-inactive {
  opacity: 0.6;
  background: #f7fafc;
}
.row-inactive td:first-child::before {
  content: "🚫 ";
  margin-right: 4px;
}

.error {
  background: #fed7d7;
  color: #c53030;
  padding: 11px;
  border-radius: 7px;
  margin-bottom: 14px;
  font-size: 14px;
}

.status-box {
  background: #fff5b4;
  border-left: 4px solid #f59e0b;
  padding: 14px 18px;
  margin: 14px 0 22px;
  border-radius: 8px;
  color: #78350f;
}
.status-box ul {
  margin: 8px 0 0 20px;
  font-size: 14px;
}
.status-box li { margin-bottom: 3px; }

.install-actions {
  background: white;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #667eea;
  padding: 20px 24px;
  margin: 14px 0;
  border-radius: 8px;
}

.code-box {
  background: #1a202c;
  color: #e2e8f0;
  padding: 13px 16px;
  border-radius: 7px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
  position: relative;
  margin: 10px 0;
  word-break: break-all;
  white-space: pre-wrap;
}
.code-box code {
  background: transparent !important;
  color: #e2e8f0 !important;
  padding: 0 !important;
  font-size: inherit !important;
  border: none !important;
}

.btn-copy {
  position: absolute;
  top: 6px;
  right: 6px;
  background: #667eea;
  color: white;
  border: none;
  padding: 5px 11px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
}
.btn-copy:hover { background: #5a67d8; }

.install-status {
  margin-top: 18px;
  padding: 14px;
  border-radius: 8px;
  background: #e6fffa;
  color: #234e52;
  border-left: 4px solid #38b2ac;
  font-size: 14px;
}

.advanced {
  margin: 14px 0;
  padding: 16px 20px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}
.advanced summary {
  cursor: pointer;
  font-weight: 600;
  color: #4a5568;
  font-size: 15px;
}
.advanced[open] summary {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.lic-table, .users-table-real {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}
.lic-table th, .lic-table td,
.users-table-real th, .users-table-real td {
  text-align: left;
  padding: 11px 14px;
  border-bottom: 1px solid #e2e8f0;
}
.lic-table th, .users-table-real th {
  background: #f7fafc;
  font-weight: 600;
  color: #4a5568;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.lic-table tr:last-child td, .users-table-real tr:last-child td {
  border-bottom: none;
}

.badge-green {
  background: #c6f6d5;
  color: #22543d;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-orange {
  background: #feebc8;
  color: #7b341e;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-red {
  background: #fed7d7;
  color: #822727;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-blue {
  background: #bee3f8;
  color: #2a4365;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.info-table td {
  padding: 10px 0;
  border-bottom: 1px solid #e2e8f0;
}
.info-table td:first-child {
  width: 140px;
  color: #4a5568;
}

code {
  background: #edf2f7;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 12px;
}

.hint { font-size: 13px; color: #718096; margin-top: 8px; }

.success {
  background: #c6f6d5;
  color: #22543d;
  padding: 11px;
  border-radius: 7px;
  margin-bottom: 14px;
  font-size: 14px;
}

/* License Cards (My Licenses self-service) */
.license-cards {
  display: grid;
  gap: 20px;
}

.license-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.license-card-header {
  padding: 20px 24px;
  background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid #e2e8f0;
}

.license-tier-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tier-trial { background: #fef3c7; color: #78350f; }
.tier-starter { background: #dbeafe; color: #1e3a8a; }
.tier-business { background: #ddd6fe; color: #5b21b6; }
.tier-enterprise { background: #fae8ff; color: #701a75; }

.license-card-body {
  padding: 20px 24px;
}

.license-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  font-size: 13px;
  color: #4a5568;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid #e2e8f0;
}
.license-meta code {
  font-size: 11px;
}

.license-key-section {
  margin-bottom: 18px;
}
.license-key-section label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #4a5568;
  margin-bottom: 8px;
}

.license-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-secondary {
  background: white;
  color: #667eea;
  border: 1px solid #667eea;
  padding: 11px 22px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover {
  background: #667eea;
  color: white;
}

.renewal-pending {
  background: #fef3c7;
  color: #78350f;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  flex: 1;
}

.nav-badge {
  background: #ef4444;
  color: white;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  margin-left: auto;
  font-weight: 700;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #718096;
  background: white;
  border: 2px dashed #e2e8f0;
  border-radius: 12px;
}
.empty-state h3 {
  color: #2d3748;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.modal {
  background: white;
  border-radius: 12px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #e2e8f0;
}
.modal-header h2 {
  margin: 0;
  font-size: 18px;
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #a0aec0;
  padding: 4px 10px;
}
.modal-close:hover {
  color: #2d3748;
}
.modal-body {
  padding: 24px;
}
.modal-body h3 {
  font-size: 14px;
  margin-bottom: 4px;
  color: #2d3748;
}
.modal-body input[readonly], .modal-body textarea[readonly] {
  background: #f7fafc;
  cursor: pointer;
}
.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.5;
}

/* Mobile responsive */
@media (max-width: 768px) {
  body.app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .nav-item { padding: 8px 10px; font-size: 13px; }
  .main { padding: 20px; }
}

.footer {
  margin-top: 28px;
  text-align: center;
  font-size: 13px;
  color: #a0aec0;
}
.footer a { color: #667eea; text-decoration: none; }
