@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #232867;
  --primary-light: #3a4285;
  --primary-dark: #1a1f4d;
  --secondary-color: #87ceeb;
  --accent-color: #5dade2;
  --light-blue: #e3f2fd;
  --light-blue-hover: #bbdefb;
  --background: #f8fafc;
  --surface: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, var(--light-blue) 0%, #f0f8ff 50%, var(--background) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

/* Header Styles */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--surface);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.title h1 {
  color: var(--primary-color);
  font-weight: 700;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.title h1 i {
  color: var(--accent-color);
}

/* Menu Styles */
.menu-container {
  position: relative;
}

.menu-icon {
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.menu-icon:hover {
  background: var(--background);
  color: var(--primary-color);
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: 120%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  overflow: hidden;
  animation: slideDown 0.2s ease;
}

.menu-dropdown ul {
  list-style: none;
}

.menu-dropdown li {
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.menu-dropdown li:hover {
  background: var(--background);
  color: var(--primary-color);
}

/* Profile Styles */
.profile-container {
  position: relative;
}

.profile {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  transition: all 0.2s ease;
  color: var(--text-primary);
}

.profile:hover {
  background: var(--light-blue);
  color: var(--primary-color);
}

.profile-avatar {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary-color), var(--accent-color));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.875rem;
}

.dropdown {
  position: absolute;
  right: 0;
  top: 120%;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: none;
  z-index: 100;
  min-width: 180px;
  overflow: hidden;
  animation: slideDown 0.2s ease;
}

.dropdown ul {
  list-style: none;
}

.dropdown li {
  padding: 0.75rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.dropdown li:hover {
  background: var(--light-blue);
  color: var(--primary-color);
}

/* Dashboard Grid - Improved alignment and spacing */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2.5rem; /* Increased gap for better spacing */
  padding: 2.5rem;
  flex: 1;
  max-width: 1400px;
  margin: 0 auto;
  align-items: stretch; /* Changed from 'start' to 'stretch' for equal heights */
  min-height: calc(100vh - 120px); /* Ensure full viewport usage */
}

/* Large screen adjustments */
@media (min-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 3rem; /* Even more spacing on large screens */
    padding: 3rem;
    max-width: 1600px;
  }
}

/* Medium desktop screens */
@media (min-width: 769px) and (max-width: 1199px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 2rem;
    padding: 2rem;
  }
}

/* Box improvements for better alignment */
.box {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%; /* Ensure all boxes have equal height */
  min-height: 350px; /* Consistent minimum height */
   background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Desktop box heights - more consistent */
@media (min-width: 769px) {
  .box {
    min-height: 380px; /* Increased for better proportion */
  }
  
  .user-details {
    min-height: 380px;
  }
  
  .chart-box {
    min-height: 450px; /* Slightly taller for chart visibility */
  }
  
  .form-box {
    min-height: 380px;
  }
  
  .calculator-box {
    min-height: 380px;
  }
}

.box:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Ensure content fills the box properly */
.box-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border-color);
  background: linear-gradient(135deg, var(--light-blue) 0%, #f0f8ff 100%);
  flex-shrink: 0; /* Prevent header from shrinking */
}

.box-header h3 {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 1.125rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.box-header h3 i {
  color: var(--primary-color);
}

/* User Details Box */
.user-details .user-info {
  padding: 1.5rem;
  flex: 1; /* Fill remaining space */
  display: flex;
  flex-direction: column;
}

.info-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f5f9;
  gap: 1rem;
  min-height: 2.5rem;
}

.info-item:last-child {
  border-bottom: none;
}

.label {
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 80px;
  flex-shrink: 0;
}

.value {
  font-weight: 600;
  color: var(--text-primary);
  text-align: right;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.4;
}

/* Chart Box */
.chart-container {
  padding: 1.5rem;
  flex: 1; /* Fill remaining space */
  min-height: 250px;
}

.current-cgpa {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
}

.cgpa-label {
  font-weight: 500;
}

.cgpa-value {
  font-size: 2rem;
  font-weight: 700;
}

/* Form Box */
.form-box .update-form {
  padding: 1.5rem;
  flex: 1; /* Fill remaining space */
  display: flex;
  flex-direction: column;
}

.form-group {
  margin-bottom: 1.5rem; /* Increased spacing */
}

.form-group:last-child {
  margin-top: auto; /* Push last element (button) to bottom */
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

input[type="text"] {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  background: var(--surface);
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(93, 173, 226, 0.15);
}

/* Buttons */
.btn-primary {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  width: 100%;
  justify-content: center;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

/* Calculator Box */
.calculator-content {
  padding: 1.5rem;
  flex: 1; /* Fill remaining space */
  display: flex;
  flex-direction: column;
}

.calculator-description {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
  flex-shrink: 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
  flex-shrink: 0;
}

.stat-item {
  text-align: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--light-blue) 0%, #f0f8ff 100%);
  border-radius: 12px;
  border: 1px solid var(--light-blue-hover);
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-calculate {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  padding: 1rem 2rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  width: 100%;
  justify-content: center;
  margin-top: auto; /* Push button to bottom */
}

.btn-calculate:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Toast Notification */
.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--success-color);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  display: none;
  align-items: center;
  gap: 0.5rem;
  z-index: 1000;
  animation: slideUp 0.3s ease;
}

/* Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Canvas Responsiveness */
canvas {
  max-width: 100%;
  height: auto !important;
}

/* Improved responsive design */
@media (max-width: 768px) {
  .dashboard-grid {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    padding: 1rem;
    gap: 1.5rem; /* Increased mobile spacing */
    min-height: auto;
  }
  
  .header {
    padding: 1rem;
  }
  
  .title h1 {
    font-size: 1.25rem;
  }
  
  .stats-row {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .profile span {
    display: none;
  }
  
  .box {
    min-height: auto;
    border-radius: 12px;
  }
  
  .box-header {
    padding: 1rem;
  }
  
  .box-header h3 {
    font-size: 1rem;
  }
  
  /* Mobile-specific user details */
  .info-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
    padding: 0.5rem 0;
  }
  
  .label {
    min-width: auto;
    font-size: 0.875rem;
  }
  
  .value {
    text-align: left;
    font-size: 1rem;
    width: 100%;
  }
  
  /* Compact current CGPA section */
  .current-cgpa {
    padding: 0.75rem 1rem;
  }
  
  .cgpa-value {
    font-size: 1.5rem;
  }
  
  /* Compact stats */
  .stat-item {
    padding: 0.75rem;
  }
  
  .stat-number {
    font-size: 1.25rem;
  }
  
  /* Compact buttons */
  .btn-calculate, .btn-primary {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 0.75rem;
  }
  
  .title h1 {
    font-size: 1rem;
  }
  
  .box-header {
    padding: 1rem;
  }
  
  .chart-container {
    height: 200px;
    padding: 1rem;
  }
  
  /* Extra small mobile adjustments */
  .dashboard-grid {
    padding: 0.75rem;
    gap: 1.25rem;
  }
  
  .user-details .user-info {
    padding: 1rem;
  }
  
  .info-item {
    padding: 0.5rem 0;
  }
  
  .value {
    font-size: 0.95rem;
    line-height: 1.3;
  }
}
/* Average Display Section */
.average-display {
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  border: 2px solid var(--light-blue-hover);
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideIn 0.5s ease;
}

.average-result {
  text-align: center;
  flex: 1;
}

.average-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
  text-shadow: 0 2px 4px rgba(35, 40, 103, 0.1);
}

.average-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Performance Animation Section */
.performance-animation {
  text-align: center;
  flex: 1;
  padding-left: 1rem;
  border-left: 2px solid var(--light-blue-hover);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.animation-container {
  width: 80px;
  height: 80px;
  position: relative;
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.performance-text {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

/* Outstanding Performance (9.0+) - Fireworks Animation */
.fireworks {
  position: relative;
  width: 60px;
  height: 60px;
}

.firework {
  position: absolute;
  width: 4px;
  height: 4px;
  background: #ffd700;
  border-radius: 50%;
  animation: fireworkExplode 2s infinite;
}

.firework:nth-child(1) { animation-delay: 0s; transform: rotate(0deg); }
.firework:nth-child(2) { animation-delay: 0.2s; transform: rotate(45deg); }
.firework:nth-child(3) { animation-delay: 0.4s; transform: rotate(90deg); }
.firework:nth-child(4) { animation-delay: 0.6s; transform: rotate(135deg); }
.firework:nth-child(5) { animation-delay: 0.8s; transform: rotate(180deg); }
.firework:nth-child(6) { animation-delay: 1s; transform: rotate(225deg); }
.firework:nth-child(7) { animation-delay: 1.2s; transform: rotate(270deg); }
.firework:nth-child(8) { animation-delay: 1.4s; transform: rotate(315deg); }

@keyframes fireworkExplode {
  0% {
    transform: translateX(0) scale(0);
    opacity: 1;
    background: #ffd700;
  }
  50% {
    transform: translateX(25px) scale(1);
    opacity: 1;
    background: #ff6b6b;
  }
  100% {
    transform: translateX(35px) scale(0);
    opacity: 0;
    background: #4ecdc4;
  }
}

/* Excellent Performance (8.0-8.9) - Trophy Animation */
.trophy {
  font-size: 3rem;
  color: #ffd700;
  animation: trophyBounce 1.5s ease-in-out infinite;
  text-shadow: 0 4px 8px rgba(255, 215, 0, 0.3);
}

@keyframes trophyBounce {
  0%, 100% {
    transform: translateY(0) scale(1);
    filter: brightness(1);
  }
  25% {
    transform: translateY(-8px) scale(1.1);
    filter: brightness(1.2);
  }
  50% {
    transform: translateY(-12px) scale(1.15);
    filter: brightness(1.3);
  }
  75% {
    transform: translateY(-8px) scale(1.1);
    filter: brightness(1.2);
  }
}

/* Good Performance (7.0-7.9) - Thumbs Up Animation */
.thumbs-up {
  font-size: 3rem;
  color: #4ecdc4;
  animation: thumbsUpPulse 1.2s ease-in-out infinite;
}

@keyframes thumbsUpPulse {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    color: #4ecdc4;
  }
  50% {
    transform: scale(1.2) rotate(5deg);
    color: #45b7aa;
  }
}

/* Satisfactory Performance (6.0-6.9) - Clock Animation */
.clock {
  font-size: 3rem;
  color: #f39c12;
  animation: clockTick 2s linear infinite;
}

@keyframes clockTick {
  0% { transform: rotate(0deg); }
  25% { transform: rotate(90deg); }
  50% { transform: rotate(180deg); }
  75% { transform: rotate(270deg); }
  100% { transform: rotate(360deg); }
}

/* Average Performance (5.0-5.9) - Progress Bar Animation */
.progress-circle {
  width: 60px;
  height: 60px;
  border: 4px solid #ecf0f1;
  border-top: 4px solid #f39c12;
  border-radius: 50%;
  animation: progressSpin 1.5s linear infinite;
}

@keyframes progressSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Poor Performance (Below 5.0) - Warning Animation */
.warning {
  font-size: 3rem;
  color: #e74c3c;
  animation: warningShake 0.8s ease-in-out infinite;
}

@keyframes warningShake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

/* Pulse Animation for Average Value */
.average-value.animate {
  animation: valuePulse 0.6s ease-out;
}

@keyframes valuePulse {
  0% {
    transform: scale(1);
    color: var(--primary-color);
  }
  50% {
    transform: scale(1.1);
    color: #4ecdc4;
  }
  100% {
    transform: scale(1);
    color: var(--primary-color);
  }
}

/* Remove old grade styles */
.grade-info {
  display: none;
}

.grade.excellent, .grade.very-good, .grade.good, .grade.satisfactory, .grade.poor {
  display: none;
}

/* Buttons Container */
.buttons-container {
  display: flex;
  gap: 1rem;
  margin-top: auto;
}

.btn-calculate-avg {
  background: linear-gradient(135deg, var(--accent-color), #87ceeb);
  color: white;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  flex: 1;
  justify-content: center;
}

.btn-calculate-avg:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  background: linear-gradient(135deg, #4a9eff, var(--accent-color));
}

.btn-calculate {
  background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
  color: white;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  flex: 1;
  justify-content: center;
}

.btn-calculate:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Animation for average display */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
    max-height: 0;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 200px;
  }
}

/* Grade-specific colors */
.grade.excellent { color: #10b981; }
.grade.very-good { color: #059669; }
.grade.good { color: #3b82f6; }
.grade.satisfactory { color: #f59e0b; }
.grade.poor { color: #ef4444; }

/* Mobile responsive adjustments */
@media (max-width: 768px) {
  .buttons-container {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .average-display {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
  }
  
  .performance-animation {
    padding-left: 0;
    border-left: none;
    border-top: 2px solid var(--light-blue-hover);
    padding-top: 1rem;
  }
  
  .average-value {
    font-size: 2rem;
  }
  
  .animation-container {
    width: 70px;
    height: 70px;
  }
  
  .trophy, .thumbs-up, .clock, .warning {
    font-size: 2.5rem;
  }
  
  .btn-calculate-avg, .btn-calculate {
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .average-display {
    padding: 1rem;
    margin-bottom: 1rem;
  }
  
  .average-value {
    font-size: 1.75rem;
  }
  
  .animation-container {
    width: 60px;
    height: 60px;
  }
  
  .trophy, .thumbs-up, .clock, .warning {
    font-size: 2rem;
  }
}