/* ==============================
   RESET & GLOBALS
   ============================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  width: 100%;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #333;
  overflow-x: hidden;
  position: relative;
}

/* ==============================
   ANIMATIONS
   ============================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes wobble {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-20px); }
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  10%, 30% { transform: scale(0.9); }
  20%, 40%, 60%, 80% { transform: scale(1.05); }
  50% { transform: scale(1.1); }
}

@keyframes slideInFromLeft {
  from { opacity: 0; transform: translateX(-100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes bubbleFloat {
  0% { transform: translateY(100vh) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-100vh) translateX(100px); opacity: 0; }
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* ==============================
   LOGIN PAGE
   ============================== */
.login-page {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
}

.login-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: white;
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 400px;
  z-index: 10;
  animation: slideUp .6s ease-out;
}

.login-card h1 {
  text-align: center;
  font-size: 2.5em;
  margin-bottom: 10px;
  animation: heartBeat 2s infinite;
}

.login-card .subtitle {
  text-align: center;
  color: #667eea;
  margin-bottom: 30px;
  font-weight: 500;
}

.form-group {
  position: relative;
  margin-bottom: 20px;
}

.form-group input {
  width: 100%;
  padding: 12px 40px 12px 12px;
  border: 2px solid #eee;
  border-radius: 10px;
  font-size: 1em;
  transition: all .3s ease;
}

.form-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group .input-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.2em;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1em;
  font-weight: 600;
  cursor: pointer;
  transition: all .3s ease;
  margin-top: 10px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.error-msg {
  color: #e74c3c;
  text-align: center;
  margin-top: 15px;
  min-height: 20px;
}

.demo-hint {
  margin-top: 20px;
  padding: 15px;
  background: #f8f9ff;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9em;
  color: #666;
}

/* Floating hearts background */
.animated-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.heart {
  position: absolute;
  font-size: 3em;
  opacity: 0.3;
  animation: float 8s infinite;
}

.heart-1 { left: 5%; animation-delay: 0s; }
.heart-2 { left: 25%; animation-delay: 2s; }
.heart-3 { left: 45%; animation-delay: 4s; }
.heart-4 { left: 65%; animation-delay: 1s; }
.heart-5 { left: 85%; animation-delay: 3s; }

/* ==============================
   MAIN APP
   ============================== */
.app-wrapper {
  height: 100vh;
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

.animated-bg-main {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.bubble {
  position: absolute;
  border-radius: 50%;
  opacity: 0.1;
  mix-blend-mode: screen;
}

.bubble-1 {
  width: 150px;
  height: 150px;
  background: #ff6b9d;
  left: 10%;
  animation: bubbleFloat 15s ease-in infinite;
}

.bubble-2 {
  width: 100px;
  height: 100px;
  background: #ffd700;
  left: 50%;
  animation: bubbleFloat 18s ease-in infinite;
  animation-delay: 3s;
}

.bubble-3 {
  width: 120px;
  height: 120px;
  background: #00d4ff;
  right: 10%;
  animation: bubbleFloat 20s ease-in infinite;
  animation-delay: 6s;
}

.bubble-4 {
  width: 80px;
  height: 80px;
  background: #ff6b9d;
  right: 30%;
  animation: bubbleFloat 17s ease-in infinite;
  animation-delay: 9s;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 10;
}

.header-left h1 {
  font-size: 1.8em;
  margin: 0;
  animation: heartBeat 2s infinite;
}

.header-left .subtitle {
  color: #999;
  font-size: 0.9em;
  margin: 5px 0 0;
}

.header-right {
  display: flex;
  gap: 10px;
}

.btn-header {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
  transition: all .3s ease;
  padding: 5px;
}

.btn-header:hover {
  transform: scale(1.2) rotate(10deg);
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  position: relative;
  z-index: 5;
}

/* ==============================
   PET AREA
   ============================== */
.pet-area {
  animation: fadeIn .5s ease-out;
}

.pet-card {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  margin: 0 auto;
  animation: slideUp .6s ease-out;
}

.pet-display {
  font-size: 8em;
  text-align: center;
  margin: 20px 0;
  animation: bounce 2s infinite;
}

.pet-card h2 {
  text-align: center;
  font-size: 2em;
  color: #ff6b9d;
  margin: 10px 0;
}

.pet-status {
  text-align: center;
  font-size: 1.1em;
  color: #666;
  margin-bottom: 20px;
  min-height: 30px;
  animation: fadeIn .5s ease-out;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  margin-bottom: 25px;
}

.stat-item {
  background: linear-gradient(135deg, #f5f7ff, #f0f4ff);
  padding: 15px;
  border-radius: 15px;
  transition: all .3s ease;
}

.stat-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.15);
}

.stat-item label {
  display: block;
  font-weight: 600;
  color: #333;
  margin-bottom: 8px;
  font-size: 0.9em;
}

.bar {
  width: 100%;
  height: 24px;
  background: #eee;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.bar .fill {
  height: 100%;
  background: linear-gradient(90deg, #667eea, #764ba2);
  width: 0%;
  transition: width .4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.bar .fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.bar[data-low="1"] .fill {
  background: linear-gradient(90deg, #e74c3c, #c0392b);
}

.stat-value {
  display: inline-block;
  font-size: 0.85em;
  color: #667eea;
  font-weight: 700;
  margin-top: 5px;
}

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.btn-action {
  padding: 15px;
  border: none;
  border-radius: 12px;
  font-size: 0.95em;
  font-weight: 600;
  cursor: pointer;
  transition: all .3s ease;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  position: relative;
  overflow: hidden;
}

.btn-action::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  transition: width .6s, height .6s;
}

.btn-action:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.btn-action:active {
  transform: translateY(-1px);
}

.btn-action:active::before {
  width: 300px;
  height: 300px;
}

.message-popup {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: white;
  padding: 15px 25px;
  border-radius: 50px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 300px;
  font-weight: 500;
  animation: slideUp .4s ease-out;
  z-index: 100;
}

/* ==============================
   MESSAGES SECTION
   ============================== */
.messages-section {
  animation: fadeIn .5s ease-out;
}

.messages-section.hidden {
  display: none;
}

.messages-container {
  background: white;
  border-radius: 20px;
  padding: 30px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
  max-width: 600px;
  margin: 0 auto;
}

.messages-container h2 {
  margin-bottom: 20px;
  color: #ff6b9d;
  animation: heartBeat 2s infinite;
}

.messages-list {
  max-height: 400px;
  overflow-y: auto;
  margin-bottom: 20px;
  padding: 10px 0;
}

.message-item {
  background: linear-gradient(135deg, #f5f7ff, #f0f4ff);
  padding: 15px;
  border-radius: 12px;
  margin-bottom: 10px;
  animation: slideUp .4s ease-out;
}

.message-item.note {
  background: linear-gradient(135deg, #fff5e1, #ffe8cc);
  border-left: 4px solid #ffc107;
}

.message-item.sent {
  background: linear-gradient(135deg, #e1f5ff, #b3e5fc);
  text-align: right;
}

.message-item .sender {
  font-weight: 600;
  color: #667eea;
  font-size: 0.9em;
  margin-bottom: 5px;
}

.message-item .text {
  color: #333;
  line-height: 1.5;
  word-break: break-word;
}

.message-item .time {
  font-size: 0.8em;
  color: #999;
  margin-top: 8px;
}

.message-input-area {
  border-top: 2px solid #f0f0f0;
  padding-top: 20px;
}

#message-text {
  width: 100%;
  padding: 15px;
  border: 2px solid #eee;
  border-radius: 10px;
  font-family: inherit;
  font-size: 1em;
  resize: vertical;
  min-height: 80px;
  transition: all .3s ease;
}

#message-text:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  cursor: pointer;
  font-size: 0.9em;
  color: #666;
  transition: all .3s ease;
}

.checkbox-label:hover {
  color: #667eea;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
  accent-color: #667eea;
}

#btn-send-message {
  width: 100%;
  margin-top: 15px;
}

/* ==============================
   UTILITIES
   ============================== */
.hidden {
  display: none !important;
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: #667eea;
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: #764ba2;
}

/* Responsive */
@media (max-width: 600px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .actions-grid {
    grid-template-columns: 1fr 1fr;
  }

  .pet-display {
    font-size: 5em;
  }

  .app-header {
    padding: 15px 20px;
  }

  .pet-card,
  .messages-container,
  .login-card {
    border-radius: 15px;
    padding: 20px;
  }
}
