/* Base variables */
:root {
  --primary-color: #000d86; /* Doña Carne Blue */
  --accent-color: #e03021;  /* Doña Carne Red */
  --yellow-brand: #ffe730;  /* Doña Carne Yellow */
  --dark-blue: #00063a;     /* Doña Carne Dark Blue */
  --bg-color: #f6f8fb;
  --text-dark: #2b2c34;
  --text-muted: #7e8299;
  --card-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
  --header-height: 58px;
  --nav-height: 64px;
}

/* Global Reset & Body */
body {
  font-family: 'Nunito', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-dark);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* Main Container spacing */
#app-main {
  flex: 1;
  padding-top: calc(var(--header-height) + 16px);
  padding-bottom: calc(var(--nav-height) + 24px);
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* --- App Header --- */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--header-height);
  background: var(--primary-color);
  border-bottom: 3px solid var(--yellow-brand);
  z-index: 1010;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

.header-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 16px;
  max-width: 600px;
  margin: 0 auto;
}

.logo-circ {
  background: var(--yellow-brand);
  color: var(--primary-color);
  font-weight: 900;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--yellow-brand);
  font-size: 0.85rem;
  margin-right: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.logo-text {
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 0.5px;
  font-size: 1rem;
}

#header-user-badge {
  background-color: rgba(255, 255, 255, 0.15) !important;
  color: #ffffff !important;
  font-weight: 700;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* --- App Bottom Navigation --- */
#app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: var(--nav-height);
  background: var(--primary-color);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  z-index: 1010;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
}

.nav-container {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 600;
  transition: all 0.2s ease;
  padding: 6px 12px;
}

.nav-link i {
  font-size: 1.25rem;
  margin-bottom: 2px;
  transition: transform 0.2s ease;
}

.nav-link:hover, .nav-link.active {
  color: var(--yellow-brand);
}

.nav-link.active i {
  transform: scale(1.15);
  color: var(--yellow-brand);
}

/* --- Login View --- */
#view-login {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  min-height: 100vh;
  background: radial-gradient(circle at center, var(--primary-color) 0%, var(--dark-blue) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1200;
  overflow-y: auto;
  padding: 20px 0;
}

.login-wrapper {
  max-width: 400px;
  margin: 0 auto;
  padding: 16px;
  width: 100%;
}

.brand-timbre {
  display: flex;
  justify-content: center;
  animation: float 3s ease-in-out infinite;
}

.brand-title {
  font-weight: 900;
  color: #ffffff;
  letter-spacing: 1.5px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.brand-subtitle {
  font-weight: 700;
  color: #ffffff;
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  margin-top: 8px;
}

.login-card {
  border-radius: 16px;
  background-color: #ffffff;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3) !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--dark-blue) 100%) !important;
  border-color: rgba(255, 231, 48, 0.3) !important;
  color: #ffffff !important;
  font-weight: 700;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  border-color: var(--yellow-brand) !important;
  color: var(--yellow-brand) !important;
  box-shadow: 0 6px 20px rgba(0, 13, 134, 0.4);
}

.btn-primary:active {
  transform: scale(0.98);
}

/* --- Module Cards (Home View) --- */
.welcome-banner {
  background: linear-gradient(135deg, #ffffff 0%, #f1f3f9 100%);
  padding: 20px;
  border-radius: 16px;
  border-left: 5px solid var(--accent-color);
  box-shadow: var(--card-shadow);
}

.module-card {
  background-color: #ffffff;
  border-radius: 14px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--card-shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
  height: 100%;
}

.module-card:not(.locked):active {
  transform: scale(0.96);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.module-icon {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px auto;
  font-size: 1.6rem;
  position: relative;
}

.module-title {
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.module-desc {
  font-size: 0.72rem;
  margin: 0;
}

/* Locked module overlay */
.module-card.locked {
  opacity: 0.65;
  background-color: #fafbfc;
}

.lock-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background-color: #6c757d;
  color: #fff;
  border-radius: 50%;
  font-size: 0.65rem;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #fff;
}

/* --- Tickets List & Cards --- */
.tickets-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ticket-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
  border-left: 4px solid transparent;
  transition: transform 0.15s ease;
}

.ticket-card:active {
  transform: scale(0.98);
}

.ticket-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ticket-code {
  font-weight: 800;
  color: var(--primary-color);
  font-size: 0.85rem;
}

.ticket-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.ticket-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-dark);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ticket-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.ticket-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Status Badges */
.badge-custom {
  font-size: 0.68rem;
  padding: 5px 8px;
  border-radius: 6px;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-ingresado { background-color: #e1f0ff; color: #0095ff; }
.badge-en_proceso { background-color: #fff4de; color: #ff9f43; }
.badge-resuelto { background-color: #c9f7f5; color: #1bc5bd; }
.badge-no_resuelto { background-color: #ffe2e5; color: #f64e60; }
.badge-cerrado { background-color: #e2e5ec; color: #3f4254; }
.badge-eliminado { background-color: #f3f6f9; color: #7e8299; }

/* Gravity Badges */
.badge-alta { background-color: rgba(224, 48, 33, 0.1); color: var(--accent-color); border-left: 2px solid var(--accent-color); }
.badge-media { background-color: rgba(255, 231, 48, 0.15); color: #c49400; border-left: 2px solid #ffc107; }
.badge-baja { background-color: rgba(25, 135, 84, 0.1); color: #198754; border-left: 2px solid #198754; }

/* Dynamic borders based on status */
.ticket-card.border-ingresado { border-left-color: #0095ff; }
.ticket-card.border-en_proceso { border-left-color: #ff9f43; }
.ticket-card.border-resuelto { border-left-color: #1bc5bd; }
.ticket-card.border-no_resuelto { border-left-color: #f64e60; }
.ticket-card.border-cerrado { border-left-color: #3f4254; }
.ticket-card.border-eliminado { border-left-color: #7e8299; }

/* --- Floating Action Button (FAB) --- */
.btn-fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-color);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 15px rgba(224, 48, 33, 0.4);
  border: none;
  z-index: 1000;
  transition: transform 0.2s ease, background 0.2s ease;
}

.btn-fab:active {
  transform: scale(0.9) rotate(45deg);
  background: #b02013;
}

/* --- Ticket Details View --- */
.detail-card {
  background: #ffffff;
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  margin-bottom: 20px;
}

.detail-img {
  width: 100%;
  max-height: 240px;
  object-fit: cover;
  border-radius: 10px;
  margin-top: 10px;
  margin-bottom: 15px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.detail-actions-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

/* Timeline/History Logs */
.timeline {
  position: relative;
  padding-left: 24px;
  list-style: none;
  margin-top: 15px;
  margin-bottom: 0;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 5px;
  bottom: 5px;
  width: 2px;
  background-color: #ebedf3;
}

.timeline-item {
  position: relative;
  margin-bottom: 18px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-dot {
  position: absolute;
  left: -22px;
  top: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: #cbd4e1;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 2px #ebedf3;
}

.timeline-dot.dot-active {
  background-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(224, 48, 33, 0.2);
}

.timeline-date {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.timeline-user {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-dark);
}

.timeline-comment {
  font-size: 0.78rem;
  color: #5e6278;
  background: #f8f9fa;
  padding: 8px 12px;
  border-radius: 8px;
  margin-top: 4px;
}

/* --- Profile View --- */
.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background-color: rgba(0, 13, 134, 0.1);
  color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 800;
  border: 3px solid var(--primary-color);
}

/* Form Controls Custom style */
.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.25rem rgba(0, 13, 134, 0.1);
}

/* Keyframes float */
@keyframes float {
  0% { transform: translateY(0px); }
  50% { transform: translateY(-8px); }
  100% { transform: translateY(0px); }
}

/* Helper spacing classes */
.px-2.5 { padding-left: 0.65rem; padding-right: 0.65rem; }
.py-2.5 { padding-top: 0.65rem; padding-bottom: 0.65rem; }
.border-grey { border: 1px solid #ebedf3; }
.italic { font-style: italic; }

/* SPA Views toggling */
.app-view {
  animation: slideIn 0.25s ease-out forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
