
/* General Reset and Base Styles */
* { box-sizing: border-box; }
body {
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  background: linear-gradient(135deg, #f0f4f8, #d9e6f2);
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  color: #2c3e50;
}

/* Containers */
.container, .login-form, .menu, .login-change, .lora-info, .weather-info, form {
  background: #ffffff;
  padding: 30px;
  border-radius: 12px;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  width: 90%;
  max-width: 600px; /* Increased for update page */
  text-align: center;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}
.container:hover, form:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}
.lora-info, .weather-info {
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
}
.weather-info { align-items: flex-start; }

/* Headings */
h2 {
  color: #1a3552;
  font-size: 32px;
  margin-bottom: 24px;
  font-weight: 600;
}
h3 {
  color: #2c3e50;
  font-size: 22px;
  margin: 20px 0 12px;
  font-weight: 500;
}
.login-form h2, .menu h2, .login-change h3 { margin-bottom: 32px; }
.service-box h3 {
  display: flex;
  align-items: center;
  font-size: 24px;
}
.service-box h3 i { margin-right: 12px; color: #4a90e2; }

/* Forms and Inputs */
form { width: 100%; max-width: 520px; }
input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  padding: 12px 14px;
  font-size: 18px;
  border: 2px solid #d1d9e6;
  border-radius: 10px;
  background: #f8fafc;
  color: #2c3e50;
  margin-bottom: 12px;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
}
input[type="file"]:not(#file_input) {
  width: 100%;
  padding: 12px 14px;
  font-size: 18px;
  border: 2px dashed #d1d9e6;
  border-radius: 10px;
  background: #f8fafc;
  color: #2c3e50;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.2s;
}
input[type="file"]:not(#file_input)::file-selector-button {
  background: #4a90e2;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  transition: background 0.3s;
}
input[type="file"]:not(#file_input)::file-selector-button:hover { background: #357abd; }
input[type="number"] {
  -webkit-appearance: textfield;
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
select {
  background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212%22%20height%3D%2212%22%20viewBox%3D%220%200%2012%2012%22%3E%3Cpath%20fill%3D%22%232c3e50%22%20d%3D%22M10.293%203.293L6%207.586%201.707%203.293A1%201%200%2000%20.293%204.707l5%205a1%201%200%20001.414%200l5-5a1%201%200%2010-1.414-1.414z%22/%3E%3C/svg%3E');
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px;
  padding-right: 30px;
}
input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus, input[type="file"]:not(#file_input):focus, select:focus {
  border-color: #4a90e2;
  box-shadow: 0 0 10px rgba(74, 144, 226, 0.3);
  transform: scale(1.02);
  outline: none;
}
input::placeholder { color: #7f8c8d; }
.service-box select, .service-box input[type="number"] {
  width: 100%;
  box-sizing: border-box;
}
.service-box label {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
  text-align: left;
  color: #2c3e50;
}

/* Buttons */
input[type="submit"]:not(#submit_btn), input[type="button"], .save-btn, .btn, button:not(.delete), #update-btn {
  background: linear-gradient(45deg, #4a90e2, #50c878);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  width: 100%;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  margin-top: 12px;
}
input[type="submit"]:not(#submit_btn):hover, input[type="button"]:hover, .save-btn:hover, .btn:hover, button:not(.delete):hover, #update-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(74, 144, 226, 0.3);
}
input[type="submit"]:not(#submit_btn):disabled, button:not(.delete):disabled, #update-btn:disabled {
  background: #b0b7c3;
  cursor: not-allowed;
  box-shadow: none;
}
.login-form input[type="submit"] { background: #50c878; }
.login-form input[type="submit"]:hover { background: #42b068; }
.reset-btn { background: #e74c3c; }
.reset-btn:hover { background: #c0392b; }
.reset-box input[type="button"] { background: #4a90e2; }
.reset-box input[type="button"]:hover { background: #357abd; }

/* File List */
.file-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
  font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
}
.file-item {
  display: grid;
  grid-template-columns: 1fr auto; /* Retained for larger screens */
  align-items: center;
  margin: 8px 0; /* Increased margin for spacing */
  padding: 12px; /* Increased padding for larger box */
  gap: 12px; /* Slightly larger gap */
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  max-height: 60px; /* Increased for larger box, or remove for flexibility */
  overflow: hidden;
}
.file-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}
.download {
  background: linear-gradient(135deg, #4a00e0, #8e2de2);
  color: #ffffff;
  padding: 10px 16px; /* Slightly increased padding */
  text-decoration: none;
  border-radius: 6px;
  font-size: 16px; /* Increased for larger file name */
  font-weight: 500;
  transition: all 0.3s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 90%; /* More flexible width */
}
.download::before {
  content: '\2193';
  font-size: 14px; /* Slightly larger for visibility */
  opacity: 0.8;
}
.download:hover {
  background: linear-gradient(135deg, #8e2de2, #4a00e0);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(142, 45, 226, 0.3);
}
.download:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(142, 45, 226, 0.2);
}
.download::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
  pointer-events: none;
}
.download:active::after {
  width: 200px;
  height: 200px;
  opacity: 0;
}
.file-meta {
  font-size: 14px; /* Increased for larger text */
  color: #2d3748;
  margin-left: 8px;
  opacity: 0.9;
  white-space: nowrap;
  text-overflow: ellipsis;
  max-width: 100px; /* Increased to prevent truncation */
}
.delete {
  background: linear-gradient(45deg, #e74c3c, #c0392b);
  color: #ffffff;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
  min-width: 60px; /* Reduced for smaller screens */
}
.delete::before {
  content: '\1F5D1';
  font-size: 14px;
  transition: transform 0.3s ease;
}
.delete:hover {
  background: linear-gradient(45deg, #c0392b, #e74c3c);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(231, 76, 60, 0.3);
}
.delete:hover::before {
  transform: scale(1.2);
}
.delete:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(231, 76, 60, 0.2);
}
.delete::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
  pointer-events: none;
}
.delete:active::after {
  width: 200px;
  height: 200px;
  opacity: 0;
}
.delete:disabled {
  background: #b0b7c3;
  color: #ffffff;
  cursor: not-allowed;
  box-shadow: none;
}
.delete:disabled::before {
  opacity: 0.5;
}
.file-controls {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr; /* Retained for larger screens */
  gap: 8px; /* Reduced gap for compactness */
  align-items: center;
  margin-bottom: 16px;
  padding: 8px; /* Reduced padding */
  background: #f8fafc;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.file-controls label {
  font-size: 14px;
  font-weight: 500;
  color: #2d3748;
}
.file-controls select {
  padding: 6px 8px; /* Slightly reduced */
  font-size: 14px;
  border: 2px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  color: #2d3748;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.file-controls select:hover {
  border-color: #4a00e0;
  box-shadow: 0 0 0 3px rgba(74, 0, 224, 0.1);
}
.file-controls select:focus {
  outline: none;
  border-color: #4a00e0;
  box-shadow: 0 0 0 3px rgba(74, 0, 224, 0.2);
}
.file-list-message {
  text-align: center;
  color: #e74c3c;
  font-size: 14px;
  margin: 16px 0;
  display: none;
}
.spinner {
  display: none;
  border: 4px solid #f3f3f3;
  border-top: 4px #4a90e2;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 1s linear infinite;
  margin: 16px auto;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Media query for smartphones (≤600px) */
@media (max-width: 600px) {
  .file-item {
    grid-template-columns: 1fr; /* Stack content vertically */
    grid-template-rows: auto auto; /* Two rows for download and delete */
    padding: 10px; /* Reduced padding */
    gap: 8px; /* Smaller gap */
    max-height: none; /* Allow flexible height */
  }
  .download {
    font-size: 14px; /* Slightly smaller for mobile */
    padding: 8px 12px; /* Reduced padding */
    max-width: 100%; /* Full width */
    grid-column: 1; /* First row */
  }
  .file-meta {
    font-size: 12px; /* Slightly smaller */
    max-width: 100%; /* Full width */
  }
  .delete {
    font-size: 12px; /* Smaller for mobile */
    padding: 6px 10px; /* Reduced padding */
    min-width: 0; /* Remove min-width */
    grid-column: 1; /* Second row */
    justify-self: start; /* Align left */
  }
  .file-controls {
    grid-template-columns: 1fr; /* Stack controls vertically */
    grid-template-rows: auto auto auto auto; /* Four rows */
    gap: 6px; /* Smaller gap */
    padding: 6px; /* Reduced padding */
  }
  .file-controls select {
    width: 100%; /* Full width */
    padding: 5px 8px; /* Smaller padding */
  }
}

/* Update Page*/
#upload_form {
  background: #fff;
  padding: 40px;
  border-radius: 15px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 90%;
  max-width: 500px;
  position: relative;
  transition: transform 0.2s ease;
}
#upload_form:hover {
  transform: scale(1.02);
}
#file_input {
  display: block;
  margin-bottom: 20px;
  width: 100%;
  padding: 15px;
  border: 2px dashed #ddd;
  border-radius: 8px;
  font-size: 16px;
  background: #fafafa;
  cursor: pointer;
}
#file_input::file-selector-button {
  background: #6a11cb;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 5px;
  cursor: pointer;
}
#file_input::file-selector-button:hover {
  background: #2575fc;
}
#submit_btn {
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  color: white;
  border: none;
  padding: 15px 25px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  font-size: 18px;
  font-weight: bold;
  transition: background 0.3s, box-shadow 0.3s, transform 0.2s;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
#submit_btn:hover {
  background: linear-gradient(135deg, #2575fc 0%, #6a11cb 100%);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}
#submit_btn:disabled {
  background: #cccccc;
  cursor: not-allowed;
  box-shadow: none;
}
.progress {
  width: 100%;
  background-color: #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  margin-top: 20px;
  position: relative;
  height: 30px;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}
.progress-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
  text-align: center;
  color: white;
  line-height: 30px;
  transition: width 0.4s ease-in-out;
}
.progress-text {
  position: absolute;
  width: 100%;
  text-align: center;
  color: #333;
  font-weight: bold;
  line-height: 30px;
  top: 0;
  left: 0;
  z-index: 1;
}
.back-btn {
  background: #008CBA;
  position: absolute;
  top: 10px;
  right: 10px;
  padding: 12px 18px;
  border-radius: 50px;
  font-size: 16px;
  text-decoration: none;
  color: white;
  display: inline-flex;
  align-items: center;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  transition: background 0.3s, box-shadow 0.3s;
}
.back-btn:hover {
  background: #007B9A;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

/* Override Update Page Body to Match Original */
body.update-page {
  font-family: 'Arial', sans-serif;
  background-color: #f0f0f0;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
}

/* Data Fields and Labels */
.data-field {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 12px;
  margin: 18px 0;
  align-items: center;
  text-align: left;
}
.data-field label {
  color: #2c3e50;
  font-size: 18px;
  font-weight: 500;
  display: flex;
  align-items: center;
}
.data-field label i { margin-right: 10px; color: #4a90e2; }

/* Menu Links */
.menu a {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #4a90e2, #50c878);
  color: white;
  padding: 16px;
  margin: 12px 0;
  text-decoration: none;
  border-radius: 10px;
  font-size: 18px;
  transition: background 0.3s, box-shadow 0.3s;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.menu a:hover {
  background: linear-gradient(135deg, #50c878, #4a90e2);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}
.menu a i { margin-right: 12px; }

/* Service Grid and Boxes */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.service-box {
  padding: 20px;
  border: 1px solid #d1d9e6;
  border-radius: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  margin: 0 auto;
  max-width: 640px;
}

/* Messages */
#message {
  color: #50c878;
  font-size: 18px;
  margin-top: 20px;
  display: none;
  text-align: center;
}
#message.error { color: #e74c3c; }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Reset Box */
.reset-box {
  display: none;
  margin-top: 12px;
}
.reset-box input { margin-bottom: 12px; }

/* Media Queries */
@media (max-width: 600px) {
  body { padding: 12px; }
  .container, .login-form, .menu, .login-change, .lora-info, .weather-info, form, #upload_form {
    width: 100%;
    padding: 20px;
  }
  h2 { font-size: 28px; }
  h3 { font-size: 20px; }
  input[type="text"], input[type="password"], input[type="number"], select, input[type="submit"]:not(#submit_btn), input[type="button"], .save-btn, .btn, .back-btn, button:not(.delete) {
    padding: 10px;
    font-size: 16px;
  }
  #file_input, #submit_btn {
    padding: 12px;
    font-size: 14px;
  }
  .data-field { grid-template-columns: 1fr; font-size: 16px; }
  .menu a, .service-box input, .service-box select { width: 100%; padding: 12px; margin-bottom: 12px; font-size: 16px; }
  .file-item { flex-direction: column; align-items: stretch; }
  .download, .delete { width: 100%; }
  .back-btn { padding: 10px 14px; }
  .weather-info, .lora-info { padding: 20px; }
}
