:root {
  --primary-color: #2c3e50;
  --secondary-color: #3498db;
  --success-color: #27ae60;
  --danger-color: #e74c3c;
  --light-bg: #ecf0f1;
  --border-color: #bdc3c7;
  --text-dark: #2c3e50;
  --text-light: #7f8c8d;
}

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

body {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  min-height: 100vh;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-dark);
}

/* Navbar */
.navbar {
  background: rgba(44, 62, 80, 0.7) !important;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-bottom: 1px solid rgba(52, 152, 219, 0.3);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 1rem 2rem !important;
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 1px;
  color: var(--secondary-color) !important;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.navbar .btn-outline-light {
  border: 2px solid var(--secondary-color);
  color: var(--secondary-color);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  background: rgba(52, 152, 219, 0.1);
  position: relative;
  overflow: hidden;
}

.navbar .btn-outline-light::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: var(--secondary-color);
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: -1;
}

.navbar .btn-outline-light:hover {
  color: white;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
  transform: translateY(-2px);
}

.navbar .btn-outline-light:hover::before {
  left: 0;
}

/* Container */
.container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 2rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

/* Headers */
h4 {
  color: var(--primary-color);
  font-weight: 700;
  margin-bottom: 1.5rem;
  border-bottom: 3px solid var(--secondary-color);
  padding-bottom: 0.5rem;
  display: inline-block;
}

h5 {
  color: var(--primary-color);
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 1rem;
}

/* Forms */
.form-control,
.form-select,
textarea.form-control {
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus,
textarea.form-control:focus {
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.15);
  outline: none;
}

/* Buttons */
.btn {
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
  text-transform: uppercase;
  font-size: 0.875rem;
  letter-spacing: 0.5px;
  padding: 0.6rem 1.2rem;
}

.btn-primary {
  background: linear-gradient(90deg, var(--secondary-color), #2980b9);
  border: none;
  box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4);
  background: linear-gradient(90deg, #2980b9, #1abc9c);
}

.btn-success {
  background: linear-gradient(90deg, var(--success-color), #229954);
  border: none;
  box-shadow: 0 4px 15px rgba(39, 174, 96, 0.3);
}

.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.btn-outline-primary,
.btn-outline-secondary {
  border-width: 2px;
  border-radius: 8px;
}

.btn-outline-primary:hover {
  background: var(--secondary-color);
  border-color: var(--secondary-color);
  transform: translateY(-2px);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
}

/* Message validation badges */
.badge-validated {
  background: linear-gradient(90deg, #2ecc71, #27ae60);
  color: white;
  font-weight: 700;
}

.badge-invalid {
  background: linear-gradient(90deg, #e74c3c, #c0392b);
  color: white;
  font-weight: 700;
}

/* List Group */
.list-group-item {
  border: 2px solid var(--light-bg);
  border-radius: 8px;
  margin-bottom: 0.75rem;
  transition: all 0.3s ease;
  padding: 1.25rem;
}

.list-group-item:hover {
  border-color: var(--secondary-color);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.15);
}

/* Alerts */
.alert {
  border-radius: 8px;
  border: none;
  padding: 1rem;
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.alert-danger {
  background: linear-gradient(135deg, #fadbd8 0%, #f5b7b1 100%);
  color: #922b21;
}

.alert-success {
  background: linear-gradient(135deg, #d5f4e6 0%, #abebc6 100%);
  color: #145a32;
}

/* Chat Styles */
.chat {
  max-width: 100%;
  margin: 0 auto;
  background: #f8f9fa;
  border-radius: 12px;
  padding: 1.5rem;
  max-height: 600px;
  overflow-y: auto;
}

.item {
  display: flex;
  margin-bottom: 1rem;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.item.incoming {
  justify-content: flex-start;
}

.item.outgoing {
  justify-content: flex-end;
}

.bubble {
  padding: 12px 16px;
  border-radius: 18px;
  display: inline-block;
  max-width: 70%;
  word-wrap: break-word;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.bubble.incoming {
  background: white;
  color: var(--text-dark);
  border: 1px solid var(--border-color);
}

.bubble.outgoing {
  background: linear-gradient(90deg, var(--success-color), #229954);
  color: white;
}

.sender {
  font-weight: 700;
  font-size: 0.85em;
  margin-bottom: 4px;
  opacity: 0.8;
}

.meta {
  font-size: 0.75em;
  opacity: 0.7;
  margin-top: 6px;
  text-align: right;
}

/* Child Profile */
.child-photo {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  object-fit: cover;
  border: 4px solid var(--secondary-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.child-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--light-bg), #bdc3c7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-light);
  font-weight: 600;
  border: 4px solid var(--border-color);
}

/* Modal */
.modal-content {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  background: white;
}

.modal-header {
  background: white;
  color: var(--text-dark);
  border-radius: 12px 12px 0 0;
  border: none;
  border-bottom: 2px solid var(--secondary-color);
}

.modal-header .modal-title {
  font-weight: 700;
  color: var(--primary-color);
}

.modal-header .btn-close {
  filter: brightness(0);
}

.modal-body {
  padding: 2rem;
}

.modal-body .form-label {
  color: var(--text-dark);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.modal-body .form-control,
.modal-body .form-select,
.modal-body textarea.form-control {
  border: 2px solid var(--border-color);
  color: var(--text-dark);
}

.modal-body .form-control:focus,
.modal-body .form-select:focus {
  border-color: var(--secondary-color);
  color: var(--text-dark);
  box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.15);
}

/* Calendar */
.fc {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.fc .fc-button-primary {
  background-color: var(--secondary-color) !important;
  border-color: var(--secondary-color) !important;
  text-transform: uppercase;
  font-size: 0.85rem;
  font-weight: 600;
}

.fc .fc-button-primary:hover {
  background-color: #2980b9 !important;
}

.fc .fc-button-primary.fc-button-active {
  background-color: var(--primary-color) !important;
}

.fc-event {
  border: none !important;
  background: linear-gradient(135deg, var(--secondary-color), #2980b9) !important;
  cursor: pointer !important;
  transition: all 0.3s ease;
}

.fc-event:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.fc-event-title {
  font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
    margin-top: 1rem;
  }

  .bubble {
    max-width: 85%;
  }

  .navbar {
    padding: 0.75rem 1rem !important;
  }

  .navbar-brand {
    font-size: 1.2rem;
  }

  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
  }

  /* Mobile top bar when logged in */
  .mobile-top {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0 0.75rem;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    z-index: 1100;
    color: white;
  }

  .mobile-top .navbar-brand{ color: white !important; font-size: 1.05rem; }

  /* Ensure sidebar behaves off-canvas on small screens */
  .sidebar {
    width: 80%;
    max-width: 320px;
    transform: translateX(-100%);
    left: 0;
    top: 0;
    height: 100vh;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  /* When logged in, on small screens we don't offset content — content should take full width and be padded for top bar */
  .has-sidebar .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding-top: 56px; /* reserve for mobile top bar */
  }

  /* Overlay that appears when sidebar is open */
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1110; /* behind sidebar but above content */
    display: none;
    opacity: 0;
    transition: opacity 0.18s ease;
  }

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

/* Footer */
footer {
  background: var(--primary-color);
  color: white;
  text-align: center;
  padding: 2rem;
  margin-top: 3rem;
}

/* Sidebar Menu */
.page-wrapper {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: linear-gradient(135deg, var(--primary-color) 0%, #34495e 100%);
  color: white;
  padding: 0;
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease;
  z-index: 1120; /* above overlay so clicks go to menu */
}

.sidebar-header {
  padding: 2rem 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 1px;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
}

.sidebar-toggle span {
  width: 25px;
  height: 3px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s ease;
  display: block;
}

.sidebar-menu {
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  color: white;
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-left-color: var(--secondary-color);
  padding-left: 1.8rem;
  color: var(--secondary-color);
}

.sidebar-item:active,
.sidebar-item.active {
  background: rgba(52, 152, 219, 0.3);
  border-left-color: var(--secondary-color);
  color: var(--secondary-color);
}

.sidebar-icon {
  font-size: 1.5rem;
  width: 30px;
  text-align: center;
}

.sidebar-text {
  font-weight: 500;
  flex: 1;
}

.sidebar-divider {
  margin: 1rem 1.5rem;
  border-color: rgba(255, 255, 255, 0.1);
}

.sidebar-logout {
  color: #e74c3c;
  margin-top: auto;
}

.sidebar-logout:hover {
  background: rgba(231, 76, 60, 0.15);
  border-left-color: #e74c3c;
  color: #e74c3c;
}

.main-content {
  flex: 1;
  margin-left: 0;
  width: 100%;
  transition: margin-left 0.3s ease, width 0.3s ease;
}

/* When sidebar is present (logged in), offset main content */
.has-sidebar .main-content {
  margin-left: 280px;
  width: calc(100% - 280px);
}

.navbar-top {
  background: linear-gradient(90deg, var(--primary-color), var(--secondary-color)) !important;
  padding: 1rem 2rem !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 !important;
  border-radius: 0 !important;
}

.navbar-top .navbar-brand {
  color: white !important;
}

/* Mobile Responsivo Sidebar */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    transform: translateX(-100%);
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
  }

  footer {
    margin-left: 0;
  }
}