/* Tooli Asesores — diseño UTB */

:root {
  --utb-blue: #003087;
  --utb-blue-dark: #001f5c;
  --utb-blue-light: #1e73be;
  --utb-accent: #5eead4;
  --utb-accent-dark: #14b8a6;
  --bg: #f6f8fb;
  --surface: #ffffff;
  --border: #e5e9f0;
  --text: #1f2937;
  --text-muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 3px rgba(0, 48, 135, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 48, 135, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 48, 135, 0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--utb-blue); text-decoration: none; }
a:hover { color: var(--utb-blue-dark); text-decoration: underline; }

button, .btn {
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--utb-blue);
  color: white;
}
.btn-primary:hover { background: var(--utb-blue-dark); box-shadow: var(--shadow-md); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }

.btn-secondary {
  background: white;
  color: var(--utb-blue);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--utb-blue); background: #f8fafc; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}
.btn-ghost:hover { background: #f1f5f9; color: var(--text); }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--text);
  width: 100%;
  transition: border 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--utb-blue);
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.1);
}

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.field { margin-bottom: 16px; }
.field-help { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: var(--utb-blue); border: 1px solid #bfdbfe; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ===== Login ===== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-side {
  background: linear-gradient(135deg, var(--utb-blue) 0%, var(--utb-blue-dark) 100%);
  padding: 48px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-side::before {
  content: "";
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.2) 0%, transparent 70%);
  border-radius: 50%;
}
.login-side::after {
  content: "";
  position: absolute;
  bottom: -150px; left: -50px;
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(94, 234, 212, 0.15) 0%, transparent 70%);
  border-radius: 50%;
}
.login-side .logo {
  height: 48px;
  filter: brightness(0) invert(1);
  position: relative;
  z-index: 1;
}
.login-side h1 {
  font-size: 36px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}
.login-side h1 span { color: var(--utb-accent); }
.login-side p {
  font-size: 16px;
  opacity: 0.85;
  max-width: 420px;
  position: relative;
  z-index: 1;
}
.login-side .footer-text {
  font-size: 13px;
  opacity: 0.6;
  position: relative;
  z-index: 1;
}

.login-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  background: var(--bg);
}
.login-form {
  width: 100%;
  max-width: 380px;
}
.login-form h2 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--utb-blue);
}
.login-form .subtitle {
  color: var(--text-muted);
  margin-bottom: 28px;
}

@media (max-width: 768px) {
  .login-page { grid-template-columns: 1fr; }
  .login-side { padding: 32px; min-height: 200px; }
  .login-side h1 { font-size: 24px; }
  .login-side p { display: none; }
  .login-side .footer-text { display: none; }
}

/* ===== App layout ===== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--utb-blue);
  color: white;
  display: flex;
  flex-direction: column;
  padding: 24px 0;
}
.sidebar .logo-wrap {
  padding: 0 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 16px;
}
.sidebar .logo-wrap img {
  height: 32px;
  filter: brightness(0) invert(1);
}
.sidebar .logo-wrap .product {
  font-size: 13px;
  opacity: 0.7;
  margin-top: 6px;
}
.sidebar nav { flex: 1; padding: 0 12px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  color: rgba(255,255,255,0.8);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
  text-decoration: none;
  cursor: pointer;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); color: white; text-decoration: none; }
.sidebar nav a.active {
  background: var(--utb-accent);
  color: var(--utb-blue-dark);
  font-weight: 600;
}
.sidebar nav a .icon { font-size: 18px; width: 20px; text-align: center; }

.sidebar .user-block {
  padding: 16px 24px 0;
  border-top: 1px solid rgba(255,255,255,0.1);
  margin-top: 16px;
}
.sidebar .user-block .name { font-weight: 600; font-size: 14px; }
.sidebar .user-block .role { font-size: 12px; opacity: 0.6; margin-bottom: 12px; }
.sidebar .user-block button {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  font-size: 12px;
  padding: 6px 12px;
  width: 100%;
}
.sidebar .user-block button:hover { background: rgba(255,255,255,0.1); }

.main {
  padding: 32px 40px;
  overflow-y: auto;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}
.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--utb-blue);
}
.page-header .subtitle { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.card h2 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.card .desc { color: var(--text-muted); font-size: 14px; margin-bottom: 16px; }

/* Hero shortcut tiles (Chatwoot, Grafana) */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.hero-tile {
  position: relative;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 28px;
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: white;
  overflow: hidden;
  transition: all 0.2s;
  font-family: inherit;
  border: none;
  cursor: pointer;
  text-align: left;
  width: 100%;
  min-height: 140px;
}
.hero-tile:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  text-decoration: none;
  color: white;
}
.hero-tile.chatwoot {
  background: linear-gradient(135deg, var(--utb-blue) 0%, var(--utb-blue-light) 100%);
}
.hero-tile.grafana {
  background: linear-gradient(135deg, #14b8a6 0%, #06b6d4 100%);
}
.hero-tile::after {
  content: "↗";
  position: absolute;
  top: 16px;
  right: 20px;
  font-size: 22px;
  opacity: 0.6;
}
.hero-tile .hero-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
}
.hero-tile .hero-info h2 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.hero-tile .hero-info p {
  font-size: 14px;
  opacity: 0.9;
  line-height: 1.4;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Tool cards (smaller) */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.tool-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  font-family: inherit;
  color: inherit;
}
.tool-card:hover {
  border-color: var(--utb-blue);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.tool-card .tool-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(0, 48, 135, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: var(--utb-blue);
  margin-bottom: 12px;
}
.tool-card .tool-icon.accent { background: rgba(94, 234, 212, 0.2); color: var(--utb-accent-dark); }
.tool-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.tool-card p { font-size: 13px; color: var(--text-muted); }

/* Stats cards (dashboard home) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--utb-blue);
}

/* Modal / panels */
.tool-panel {
  background: white;
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  max-width: 560px;
  margin: 0 auto;
}
.tool-panel h2 { font-size: 22px; color: var(--utb-blue); margin-bottom: 8px; }
.tool-panel .desc { color: var(--text-muted); margin-bottom: 24px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: inherit;
}
.back-link:hover { color: var(--utb-blue); }

.result-block {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-top: 20px;
  border-left: 4px solid var(--utb-accent);
}
.result-block .row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.result-block .row:last-child { border: none; }
.result-block .label { font-size: 13px; color: var(--text-muted); }
.result-block .value { font-weight: 600; }

/* Tablas */
table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
th, td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
th {
  background: #f9fafb;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
tr:last-child td { border: none; }
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 48, 135, 0.1);
  color: var(--utb-blue);
}
.badge.admin { background: rgba(94, 234, 212, 0.3); color: var(--utb-accent-dark); }
.badge.asesor { background: rgba(0, 48, 135, 0.1); color: var(--utb-blue); }

/* Mobile */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px; }
}
