/* Smart Home Dashboard - Custom Styles */

:root {
  --primary-color: #4f46e5;
  --secondary-color: #8b5cf6;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --danger-color: #ef4444;
  --info-color: #3b82f6;

  --light-bg: #f8fafc;
  --light-card: #ffffff;
  --light-text: #1e293b;
  --light-border: #e2e8f0;

  --dark-bg: #0f172a;
  --dark-card: #1e293b;
  --dark-text: #f1f5f9;
  --dark-border: #334155;

  --transition: all 0.3s ease;
  --border-radius: 12px;
  --box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --box-shadow-hover: 0 8px 25px -8px rgba(0, 0, 0, 0.2);
}

/* Theme Overrides */
[data-bs-theme="light"] {
  --bs-body-bg: var(--light-bg);
  --bs-body-color: var(--light-text);
  --bs-border-color: var(--light-border);
}

[data-bs-theme="dark"] {
  --bs-body-bg: var(--dark-bg);
  --bs-body-color: var(--dark-text);
  --bs-border-color: var(--dark-border);
}

/* Global Styles */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    sans-serif;
  background: linear-gradient(
    135deg,
    var(--bs-body-bg) 0%,
    color-mix(in srgb, var(--bs-body-bg) 95%, var(--primary-color)) 100%
  );
  min-height: 100vh;
  transition: var(--transition);
}

/* Navigation */
.navbar {
  backdrop-filter: blur(10px);
  background: linear-gradient(
    135deg,
    var(--primary-color) 0%,
    var(--secondary-color) 100%
  ) !important;
  border: none;
  box-shadow: var(--box-shadow);
}

.navbar-brand {
  font-weight: 600;
  font-size: 1.25rem;
}

/* Cards */
.card {
  border: 1px solid var(--bs-border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  transition: var(--transition);
  background: var(--bs-body-bg);
  backdrop-filter: blur(10px);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--box-shadow-hover);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--bs-border-color);
  padding: 1.25rem;
}

.card-body {
  padding: 1.5rem;
}

/* Device Cards */
.device-card {
  height: 100%;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.device-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--primary-color),
    transparent
  );
  transition: var(--transition);
}

.device-card:hover::before {
  left: 100%;
}

.device-card.active {
  border-color: var(--success-color);
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.3);
}

/* Device Icons */
.device-icon {
  position: relative;
}

.device-icon i {
  font-size: 3rem;
  transition: var(--transition);
  color: #6b7280;
}

/* Bulb States */
.device-bulb.on {
  color: #fbbf24;
  filter: drop-shadow(0 0 20px rgba(251, 191, 36, 0.6));
  animation: bulbGlow 2s ease-in-out infinite alternate;
}

.device-bulb.off {
  color: #6b7280;
}

@keyframes bulbGlow {
  0% {
    filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.4));
  }
  100% {
    filter: drop-shadow(0 0 25px rgba(251, 191, 36, 0.8));
  }
}

/* Outlet States */
.device-outlet.on {
  color: var(--success-color);
  animation: pulse 2s infinite;
}

.device-outlet.off {
  color: #6b7280;
}

/* Plant States */
.device-plant.on {
  color: var(--success-color);
  animation: plantGrow 3s ease-in-out infinite alternate;
}

.device-plant.off {
  color: #6b7280;
}

@keyframes plantGrow {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.1);
  }
}

/* Door States */
.device-door.open {
  color: var(--info-color);
  transform: rotateY(15deg);
}

.device-door.closed {
  color: #6b7280;
}

/* AC States */
.device-ac.on {
  color: var(--info-color);
  animation: snowfall 1.5s linear infinite;
}

.device-ac.off {
  color: #6b7280;
}

@keyframes snowfall {
  0%,
  100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-5px);
  }
}

/* Switches */
.form-switch .form-check-input {
  width: 3rem;
  height: 1.5rem;
  background-size: contain;
  cursor: pointer;
  transition: var(--transition);
}

.form-switch .form-check-input:checked {
  background-color: var(--success-color);
  border-color: var(--success-color);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

.form-switch .form-check-input:focus {
  box-shadow: 0 0 0 0.25rem rgba(16, 185, 129, 0.25);
}

/* Buttons */
.device-button {
  transition: var(--transition);
  border-radius: 8px;
  padding: 0.5rem 1rem;
}

.device-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--box-shadow);
}

/* Status Text */
.status-text {
  font-weight: 500;
  transition: var(--transition);
}

.status-text.online {
  color: var(--success-color);
}

.status-text.offline {
  color: #6b7280;
}

/* Connection Status Badge */
.badge {
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-weight: 500;
}

/* Chart Container */
#sensorChart {
  max-height: 250px;
}

/* Current Values Display */
.fs-3 {
  margin-bottom: 0.5rem;
}

/* Theme Toggle */
#themeToggle {
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

#themeToggle:hover {
  transform: rotate(180deg);
}

/* Animations */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

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

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

/* Loading States */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top: 2px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .device-icon i {
    font-size: 2.5rem;
  }

  .card-body {
    padding: 1rem;
  }
}

@media (max-width: 576px) {
  .navbar-brand {
    font-size: 1rem;
  }

  .device-icon i {
    font-size: 2rem;
  }

  .card-title {
    font-size: 0.9rem;
  }

  .card-text {
    font-size: 0.8rem;
  }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bs-body-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--bs-border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary-color);
}

/* Toast Notifications */
.toast {
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  backdrop-filter: blur(10px);
}

/* Modal Improvements */
.modal-content {
  border-radius: var(--border-radius);
  border: 1px solid var(--bs-border-color);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  border-bottom: 1px solid var(--bs-border-color);
}

.modal-footer {
  border-top: 1px solid var(--bs-border-color);
}

/* Form Improvements */
.form-control {
  border-radius: 8px;
  border: 1px solid var(--bs-border-color);
  transition: var(--transition);
}

.form-control:focus {
  box-shadow: 0 0 0 0.25rem rgba(79, 70, 229, 0.25);
  border-color: var(--primary-color);
}

/* Utility Classes */
.glass-effect {
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.text-gradient {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.shadow-glow {
  box-shadow: 0 0 20px rgba(79, 70, 229, 0.3);
}

/* Footer Styles */
footer {
  margin-top: auto;
  background: var(--bs-body-bg);
  border-top: 1px solid var(--bs-border-color);
  position: relative;
  color: var(--bs-body-color);
}

[data-bs-theme="dark"] footer {
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}

[data-bs-theme="light"] footer {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

footer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--primary-color),
    transparent
  );
}

footer h5 {
  color: var(--primary-color);
  font-weight: 600;
}

footer h6 {
  color: var(--bs-body-color);
  font-weight: 500;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
  display: inline-block;
}

footer .system-info {
  background: var(--bs-body-bg);
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid var(--bs-border-color);
  box-shadow: var(--box-shadow);
}

[data-bs-theme="dark"] footer .system-info {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

[data-bs-theme="light"] footer .system-info {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

footer .system-info small {
  font-size: 0.8rem;
}

footer a {
  transition: var(--transition);
  color: var(--bs-body-color) !important;
}

footer a:hover {
  color: var(--primary-color) !important;
  transform: translateY(-1px);
}

footer .list-unstyled li {
  transition: var(--transition);
}

footer .list-unstyled li:hover {
  transform: translateX(5px);
}

footer hr {
  border-color: var(--bs-border-color) !important;
  opacity: 0.5;
}

[data-bs-theme="dark"] footer hr {
  border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="light"] footer hr {
  border-color: rgba(0, 0, 0, 0.1) !important;
}

/* Footer Responsive */
@media (max-width: 768px) {
  footer .col-md-3,
  footer .col-md-6 {
    margin-bottom: 2rem;
  }

  footer .text-md-end {
    text-align: center !important;
  }

  footer .d-flex.gap-3 {
    justify-content: center;
    flex-wrap: wrap;
  }
}

/* Body Layout for Footer */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container-fluid.py-4 {
  flex: 1;
}

/* Sistema de Notificações Centralizado */
.notification-container {
  position: fixed;
  top: 80px; /* Abaixo da navbar */
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050;
  width: 90%;
  max-width: 600px;
  pointer-events: none; /* Permite cliques através do container */
}

.notification {
  background: var(--bs-body-bg);
  border: 1px solid var(--bs-border-color);
  border-radius: var(--border-radius);
  padding: 1rem 1.5rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--box-shadow-hover);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0;
  transform: translateY(-20px);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto; /* Permite cliques na notificação */
  position: relative;
  overflow: hidden;
}

.notification.show {
  opacity: 1;
  transform: translateY(0);
}

.notification.hide {
  opacity: 0;
  transform: translateY(-20px);
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  height: 0;
}

.notification-icon {
  font-size: 1.25rem;
  min-width: 20px;
  text-align: center;
}

.notification-content {
  flex: 1;
}

.notification-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0 0 0.25rem 0;
  line-height: 1.2;
}

.notification-message {
  font-size: 0.875rem;
  margin: 0;
  opacity: 0.9;
  line-height: 1.3;
}

.notification-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: var(--transition);
  opacity: 0.7;
}

.notification-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* Tipos de Notificação */
.notification.success {
  border-left: 4px solid var(--success-color);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--success-color) 5%, var(--bs-body-bg)) 0%,
    var(--bs-body-bg) 100%
  );
}

.notification.success .notification-icon {
  color: var(--success-color);
}

.notification.error {
  border-left: 4px solid var(--danger-color);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--danger-color) 5%, var(--bs-body-bg)) 0%,
    var(--bs-body-bg) 100%
  );
}

.notification.error .notification-icon {
  color: var(--danger-color);
}

.notification.warning {
  border-left: 4px solid var(--warning-color);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--warning-color) 5%, var(--bs-body-bg)) 0%,
    var(--bs-body-bg) 100%
  );
}

.notification.warning .notification-icon {
  color: var(--warning-color);
}

.notification.info {
  border-left: 4px solid var(--info-color);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--info-color) 5%, var(--bs-body-bg)) 0%,
    var(--bs-body-bg) 100%
  );
}

.notification.info .notification-icon {
  color: var(--info-color);
}

/* Barra de Progresso */
.notification-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.3;
  transition: width linear;
  border-radius: 0 0 var(--border-radius) var(--border-radius);
}

/* Responsividade */
@media (max-width: 768px) {
  .notification-container {
    width: 95%;
    top: 70px;
  }

  .notification {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
  }

  .notification-title {
    font-size: 0.875rem;
  }

  .notification-message {
    font-size: 0.8rem;
  }
}

/* Animação de entrada staggered */
.notification:nth-child(1) {
  animation-delay: 0ms;
}
.notification:nth-child(2) {
  animation-delay: 100ms;
}
.notification:nth-child(3) {
  animation-delay: 200ms;
}
.notification:nth-child(4) {
  animation-delay: 300ms;
}

@keyframes slideInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.notification.show {
  animation: slideInDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
