/* =============================================
   VYRAX3D SaaS - Estilo Profissional
   Sistema Multi-Tenant de Gestão
   ============================================= */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #0ea5e9;
  --success: #22c55e;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #334155;
  --bg-hover: #334155;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --border: #334155;
  --border-light: #475569;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
}

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

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

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

/* ============ LAYOUT ============ */
.app-container { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.sidebar-header .logo { max-width: 140px; height: auto; margin-bottom: 8px; }
.sidebar-header h2 { font-size: 16px; color: var(--primary-light); font-weight: 700; }
.sidebar-header .plan-badge {
  display: inline-block;
  padding: 2px 10px;
  background: var(--primary);
  color: white;
  border-radius: 20px;
  font-size: 11px;
  margin-top: 6px;
}

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-light);
  border-left-color: var(--primary);
}

.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }

.nav-section-title {
  padding: 16px 20px 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
}

.user-details { flex: 1; min-width: 0; }
.user-details .name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-details .email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 24px;
  min-height: 100vh;
}

/* ============ HEADER ============ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.page-header .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #16a34a; color: white; }

.btn-warning { background: var(--warning); color: #1e293b; }
.btn-warning:hover { background: #d97706; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; color: white; }

.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); color: white; }

.btn-outline { background: transparent; color: var(--primary-light); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }
.btn-icon { padding: 8px; }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.card:hover { border-color: var(--border-light); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 { font-size: 16px; font-weight: 600; }

/* ============ STAT CARDS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue { background: rgba(14, 165, 233, 0.15); color: var(--secondary); }
.stat-icon.green { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.stat-icon.orange { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.stat-icon.red { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.stat-icon.purple { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }

.stat-info { flex: 1; }
.stat-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ============ TABLES ============ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead { background: var(--bg-secondary); }

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

tr:hover td { background: rgba(99, 102, 241, 0.05); }
tr:last-child td { border-bottom: none; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }

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

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal { transform: scale(1); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg-input);
  color: var(--text-secondary);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition);
}

.modal-close:hover { background: var(--danger); color: white; }

.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: rgba(34, 197, 94, 0.15); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: rgba(6, 182, 212, 0.15); color: var(--info); }
.badge-primary { background: rgba(99, 102, 241, 0.15); color: var(--primary-light); }
.badge-secondary { background: rgba(100, 116, 139, 0.15); color: var(--text-secondary); }

/* ============ ALERTS ============ */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background: rgba(34, 197, 94, 0.1); border: 1px solid rgba(34, 197, 94, 0.3); color: var(--success); }
.alert-warning { background: rgba(245, 158, 11, 0.1); border: 1px solid rgba(245, 158, 11, 0.3); color: var(--warning); }
.alert-danger { background: rgba(239, 68, 68, 0.1); border: 1px solid rgba(239, 68, 68, 0.3); color: var(--danger); }
.alert-info { background: rgba(6, 182, 212, 0.1); border: 1px solid rgba(6, 182, 212, 0.3); color: var(--info); }

/* ============ TOAST ============ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease, fadeOut 0.3s ease 3.7s forwards;
  max-width: 400px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); color: #1e293b; }
.toast-info { background: var(--info); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }

/* ============ SEARCH & FILTERS ============ */
.search-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-input input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
}

.search-input svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
}

/* ============ LOADING ============ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text-secondary); }
.empty-state p { font-size: 14px; margin-bottom: 20px; }

/* ============ AUTH PAGES ============ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  padding: 20px;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.auth-card .logo-section {
  text-align: center;
  margin-bottom: 32px;
}

.auth-card .logo-section img { max-width: 120px; margin-bottom: 12px; }
.auth-card .logo-section h1 { font-size: 22px; color: var(--primary-light); }
.auth-card .logo-section p { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

.auth-card .form-group { margin-bottom: 20px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-secondary);
}

.auth-footer a { color: var(--primary-light); font-weight: 600; }

/* ============ CHART CONTAINERS ============ */
.chart-container {
  position: relative;
  height: 300px;
  padding: 10px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

/* ============ MOBILE TOGGLE ============ */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 200;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: flex; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
  .charts-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stat-value { font-size: 20px; }
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ============ LANDING PAGE ============ */
.landing-hero {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 20px;
}

.landing-hero h1 {
  font-size: 48px;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #6366f1, #0ea5e9);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 16px;
}

.landing-hero .subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  max-width: 600px;
  margin-bottom: 32px;
}

.landing-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  max-width: 1000px;
  width: 100%;
  margin-top: 40px;
}

.landing-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: left;
  transition: var(--transition);
}

.landing-card:hover {
  border-color: var(--primary);
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.landing-card .icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  font-size: 24px;
}

.landing-card h3 { font-size: 18px; margin-bottom: 8px; }
.landing-card p { font-size: 14px; color: var(--text-secondary); }

/* ============ ADMIN SPECIFIC ============ */
.admin-user-row { display: flex; align-items: center; gap: 12px; }
.admin-user-row .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}

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

/* ============ GRID UTILS ============ */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ============ MISC ============ */
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
