@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================================================================
   DESIGN TOKENS
   ============================================================================================ */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --border: #e4e8ee;
  --text: #1e2433;
  --text-muted: #6b7280;

  --primary: #4682b4;
  --primary-dark: #386691;
  --primary-soft: #eaf2f8;

  --danger: #ce735c;
  --success: #69b645;
  --warning: #e7bc52;
  --info: #4599b6;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 4px 14px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, .16);

  --sidebar-w: 264px;
  --topbar-h: 64px;

  --ease: cubic-bezier(.4, 0, .2, 1);

  --z-content: 1;
  --z-topbar: 900;
  --z-backdrop: 999;
  --z-sidebar: 1000;
  --z-popup: 1500;
  --z-alert: 2000;
}

body.dark {
  --bg: #14171c;
  --surface: #1b1f27;
  --surface-alt: #20242d;
  --border: #2c313c;
  --text: #e7e9ee;
  --text-muted: #9aa2b1;

  --primary: #6fa8d6;
  --primary-dark: #4682b4;
  --primary-soft: #223244;
}

/* ============================================================================================
   RESET & BASE
   ============================================================================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.45;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}

a {
  color: var(--primary);
}

::selection {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.alert { padding: 14px 16px; margin: 10px 0; border-radius: var(--radius-sm); font-size: .95em; }
.alert-success { background-color: #eaf7e5; color: #2f6b1a; }
.alert-error { background-color: #fbeae6; color: #8a3524; }
body.dark .alert-success { background-color: #1d3016; color: #9fd98a; }
body.dark .alert-error { background-color: #3a2018; color: #f0a08c; }

/* ============================================================================================
   SIDEBAR
   ============================================================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform .3s var(--ease), background-color .25s var(--ease), border-color .25s var(--ease);
  z-index: var(--z-sidebar);
}

.sidebar.active {
  transform: translateX(0);
  box-shadow: var(--shadow-lg);
}

/* Backdrop shown behind the sidebar on smaller screens */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  opacity: 0;
  transition: opacity .25s var(--ease);
  z-index: var(--z-backdrop);
}

.sidebar.active ~ .sidebar-backdrop {
  display: block;
  opacity: 1;
}

/* First item in the sidebar acts as its header/brand + collapse handle */
.sidebar > .men_item:first-child {
  flex: 0 0 auto;
  justify-content: center;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.sidebar > .men_item:first-child:hover {
  background: transparent;
}

.sidebar > .men_item:first-child img {
  max-width: 70%;
}

/* ============================================================================================
   TOPBAR
   ============================================================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  height: var(--topbar-h);
  width: 100%;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: var(--z-topbar);
  transition: background-color .25s var(--ease), border-color .25s var(--ease);
}

.toggle-btn {
  display: inline-flex;
  align-items: center;
  font-size: 1.5rem;
  line-height: 0;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background-color .2s var(--ease);
}

.toggle-btn:hover {
  background-color: var(--surface-alt);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.topbar-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
  min-width: 0;
}

.topbar-greeting {
  font-size: .92em;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.topbar-greeting strong {
  font-weight: 600;
}

.topbar-company {
  font-size: .78em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.user-info img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--primary-soft);
  flex-shrink: 0;
}

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color .2s var(--ease), transform .15s var(--ease);
  flex-shrink: 0;
}

.topbar-icon-btn:hover {
  background-color: var(--primary-soft);
}

.topbar-icon-btn:active {
  transform: scale(.92);
}

/* ============================================================================================
   MAIN CONTENT
   ============================================================================================ */
.main-content {
  margin-left: 0;
  padding: 0 4px 4px 0;
  width: 100%;
  transition: margin-left .3s var(--ease);
}

.main {
  margin-left: 0;
  padding: calc(var(--topbar-h) + 14px) 14px 14px 14px;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  transition: margin-left .3s var(--ease);
}

@media (min-width: 992px) {
  .sidebar.active ~ .main {
    margin-left: var(--sidebar-w);
  }
}

h1, h2 {
  margin-bottom: 16px;
}

/* ============================================================================================
   TABLE
   ============================================================================================ */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

th, td {
  padding: 12px;
  border: 1px solid var(--border);
  text-align: left;
}

th {
  background-color: var(--surface-alt);
  color: var(--text);
  font-weight: 600;
}

/* ============================================================================================
   FORMS & INPUTS
   ============================================================================================ */
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  margin-top: 5px;
  margin-bottom: 5px;
  font-family: inherit;
  font-size: .95em;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  transition: border-color .2s var(--ease), box-shadow .2s var(--ease);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(70, 130, 180, .18);
}

input:disabled, select:disabled, textarea:disabled {
  background-color: var(--surface-alt);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ============================================================================================
   BUTTONS
   ============================================================================================ */
.btn {
  padding: 8px 14px;
  margin-top: 5px;
  margin-bottom: 5px;
  background-color: var(--primary);
  color: white;
  border: none;
  font-size: 1em;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter .2s var(--ease), transform .1s var(--ease), box-shadow .2s var(--ease);
}

.btn:hover {
  filter: brightness(1.08);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: scale(.97);
}

.btn-icono {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  padding: 8px 14px;
  margin-top: 5px;
  margin-bottom: 5px;
  border: none;
  background-color: var(--primary);
  color: white;
  font-family: inherit;
  font-size: .95em;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter .2s var(--ease), transform .1s var(--ease), box-shadow .2s var(--ease);
}

.btn-icono i {
  font-size: 18px;
}

.btn-icono:hover {
  filter: brightness(1.08);
  box-shadow: var(--shadow-sm);
}

.btn-icono:active {
  transform: scale(.97);
}
/* === Buttons Special Iconos Tab=== */
.btn-icono-tab {
  display: inline-flex;       /* Necesario si usas íconos o contenido adicional */
  align-items: center;        /* Centrado vertical */
  justify-content: center;    /* Centrado horizontal */
  gap: 6px;
  /*padding: 10px 18px;*/

  padding: 7px;
  margin-top: 5px;
  margin-bottom: 5px;

  border: none;
  background-color: #007bff;
  color: white;
  font-size: 1em;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.3s;
}

.btn-icono-tab i {
  font-size: 18px;
}

.btn-icono-tab:hover {
  background-color: #0056b3;
}
/* ============================================================================================
   CARDS
   ============================================================================================ */
.card, .card-2 {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
  transition: background-color .25s var(--ease);
}

.card { padding: 20px; }
.card-2 { padding: 10px; }

.card-title, .card-2-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 1.05em;
  font-weight: 600;
  letter-spacing: .2px;
  color: var(--text);
  background-color: var(--primary-soft);
  border-bottom: 1px solid var(--border);
}

.card-title {
  margin: -20px -20px 18px -20px;
  padding: 14px 20px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-2-title {
  margin: -10px -10px 10px -10px;
  padding: 12px 14px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-title > i, .card-2-title > i {
  color: var(--primary);
  font-size: 1.1em;
}

.card-title a, .card-2-title a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--primary);
  cursor: pointer;
  transition: background-color .2s var(--ease);
}

.card-title a:hover, .card-2-title a:hover {
  background-color: rgba(70, 130, 180, .14);
}

.card-title a i, .card-2-title a i {
  font-size: 1.15em;
}

body.dark .card-title, body.dark .card-2-title {
  background-color: var(--primary-soft);
}

/* ============================================================================================
   RESPONSIVE
   ============================================================================================ */
@media (max-width: 767px) {
  .sidebar {
    width: min(84vw, 300px);
  }

  .topbar {
    padding: 0 12px;
  }

  .topbar-greeting, .topbar-company {
    max-width: 38vw;
  }
}

@media (max-width: 480px) {
  .topbar-company {
    display: none;
  }

  .topbar-greeting {
    max-width: 50vw;
  }

  .main {
    padding: calc(var(--topbar-h) + 10px) 8px 8px 8px;
  }
}

.login-form-wrap {
  width: 100%;
  max-width: 380px;
}

.centrado {
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--border);
}

/* ============================================================================================
   DARK MODE
   ============================================================================================ */
body.dark table th {
  background-color: var(--surface-alt);
  color: var(--text);
}

body.dark table td {
  background-color: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

body.dark input,
body.dark select,
body.dark textarea {
  background-color: var(--surface-alt);
  border-color: var(--border);
  color: var(--text);
}
