/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: #1A0F0A;
  background: linear-gradient(135deg, #FF6B35 0%, #F7931E 25%, #FFD23F 50%, #FF6B9D 75%, #C44569 100%);
  min-height: 100vh;
}

/* Main Container - CSS Grid Layout */
.container {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto 1fr auto;
  grid-template-areas: 
    "header"
    "form"
    "content"
    "footer";
  min-height: 100vh;
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem;
  gap: 1.5rem;
  width: 100%;
  box-sizing: border-box;
}

/* Header */
h1 {
  grid-area: header;
  text-align: center;
  color: #FFFFFF;
  font-size: 2.5rem;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
  margin-bottom: 1rem;
}

/* Form Area */
#input-area {
  grid-area: form;
  background: rgba(255, 255, 255, 0.15);
  padding: 1.5rem;
  border-radius: 15px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  align-items: end;
}

#input-area input {
  padding: 0.75rem;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: rgba(255, 255, 255, 0.95);
  color: #1A0F0A;
}

#input-area input:focus {
  outline: none;
  border-color: #FF6B35;
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.3);
}

#input-area input::placeholder {
  color: #4A2C17;
}

/* Buttons */
button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#addButton {
  background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 107, 53, 0.4);
}

#addButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 107, 53, 0.6);
}

#deleteButton {
  background: linear-gradient(135deg, #C44569 0%, #8B1538 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(196, 69, 105, 0.4);
}

#deleteButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(196, 69, 105, 0.6);
}

#deleteButton:disabled {
  background: #6c757d;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#exportButton {
  background: linear-gradient(135deg, #FFD23F 0%, #FFA500 100%);
  color: #1A0F0A;
  box-shadow: 0 4px 15px rgba(255, 210, 63, 0.4);
  font-weight: 700;
}

#exportButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 210, 63, 0.6);
}

/* Content Area - Grid Layout */
.content-grid {
  grid-area: content;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  width: 100%;
  overflow: hidden;
}

/* History Section */
.history-section {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.history-section h2 {
  color: #FFFFFF;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Table Styles */
table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  table-layout: fixed;
  min-width: 0;
}

/* Table wrapper for horizontal scroll on small screens */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

th, td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #e1e5e9;
  word-wrap: break-word;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1A0F0A;
}

/* Specific column widths */
th:nth-child(1), td:nth-child(1) { width: 25%; } /* Date */
th:nth-child(2), td:nth-child(2) { width: 20%; } /* Name */
th:nth-child(3), td:nth-child(3) { width: 25%; } /* Weight */
th:nth-child(4), td:nth-child(4) { width: 30%; } /* Change */

th {
  background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
  color: white;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 0.9rem;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

tr:hover {
  background: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
}

/* Chart Section */
.chart-section {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 15px;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.chart-section h2 {
  color: #FFFFFF;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

#weightChart {
  width: 100%;
  height: 400px;
  border-radius: 8px;
}

/* Footer */
footer {
  grid-area: footer;
  text-align: center;
  color: #FFFFFF;
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 2rem;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 0.5rem;
    gap: 1rem;
  }
  
  h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
  }
  
  #input-area {
    padding: 1rem;
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  
  #input-area input {
    padding: 0.875rem;
    font-size: 16px; /* Prevents zoom on iOS */
  }
  
  button {
    padding: 0.875rem 1rem;
    font-size: 0.9rem;
  }
  
  .history-section,
  .chart-section {
    padding: 1rem;
  }
  
  table {
    font-size: 0.9rem;
  }
  
  th, td {
    padding: 0.75rem 0.5rem;
  }
  
  #weightChart {
    height: 300px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.75rem;
  }
  
  #input-area {
    padding: 0.75rem;
  }
  
  .history-section,
  .chart-section {
    padding: 0.75rem;
  }
  
  table {
    font-size: 0.8rem;
  }
  
  th, td {
    padding: 0.5rem 0.25rem;
  }
  
  #weightChart {
    height: 250px;
  }
  
  button {
    padding: 0.75rem;
    font-size: 0.8rem;
  }
}

/* Tablet Landscape */
@media (min-width: 769px) and (max-width: 1024px) {
  .content-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 
      "history chart";
  }
  
  .history-section {
    grid-area: history;
  }
  
  .chart-section {
    grid-area: chart;
  }
}

/* Desktop Large */
@media (min-width: 1025px) {
  .content-grid {
    grid-template-columns: 1fr 1fr;
    grid-template-areas: 
      "history chart";
  }
  
  .history-section {
    grid-area: history;
  }
  
  .chart-section {
    grid-area: chart;
  }
  
  #weightChart {
    height: 500px;
  }
}

/* Ultra-wide screens (1440px+) */
@media (min-width: 1440px) {
  .container {
    max-width: 1600px;
    padding: 2rem;
  }
  
  .content-grid {
    gap: 2rem;
  }
  
  .history-section,
  .chart-section {
    padding: 2rem;
  }
  
  #weightChart {
    height: 600px;
  }
  
  table {
    font-size: 1.1rem;
  }
  
  th, td {
    padding: 1.25rem;
  }
}

/* 4K and ultra-wide displays (2560px+) */
@media (min-width: 2560px) {
  .container {
    max-width: 2000px;
    padding: 3rem;
  }
  
  h1 {
    font-size: 3.5rem;
  }
  
  #input-area {
    padding: 2.5rem;
  }
  
  #input-area input {
    padding: 1rem;
    font-size: 1.2rem;
  }
  
  button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
  }
  
  .history-section,
  .chart-section {
    padding: 2.5rem;
  }
  
  #weightChart {
    height: 700px;
  }
  
  table {
    font-size: 1.2rem;
  }
  
  th, td {
    padding: 1.5rem;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
  }
  
  .container {
    grid-template-areas: 
      "header"
      "form"
      "content";
    gap: 0;
  }
  
  #input-area {
    display: none;
  }
  
  .history-section,
  .chart-section {
    background: white;
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
