/* Base Styles */
body {
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #121212;
  color: #e0e0e0;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
}

/* Main Container */
.calculator {
  width: 100%;
  max-width: 450px;
  background: #1a1a1a;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  margin: 20px;
}

/* Header */
.header {
  background: #FFA500;
  padding: 18px;
  text-align: center;
  border-bottom: 2px solid #ffb733;
  position: relative;
}

.header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #FFA500, #FFA500, #FFA500);
}

.header h1 {
  color: #fff;
  font-weight: 600;
  font-size: 1.6rem;
  margin: 0;
}

/* Content Area */
.content {
  padding: 24px;
  position: relative;
}

/* Input Fields */
.input-group {
  margin-bottom: 20px;
}

.input-field {
  width: 100%;
  padding: 12px 16px;
  margin: 8px 0;
  border: 1px solid #444;
  border-radius: 8px;
  font-size: 0.95rem;
  color: #ffffff;
  background-color: #2b2b2b;
  box-sizing: border-box;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.input-field:focus {
  outline: none;
  border-color: #FFA500;
  box-shadow: 0 0 0 2px rgba(255, 165, 0, 0.4);
}

.input-field::placeholder {
  color: #aaaaaa;
}

/* Course Items */
.course-item {
  background: #222;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  position: relative;
}

/* Buttons */
.btn {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-primary {
  background: #FFA500;
  color: #1a1a1a;
  font-weight: 700;
}

.btn-primary:hover {
  background: #ff8c00;
}

.btn-secondary {
  background: #333;
  color: #e0e0e0;
}

.btn-secondary:hover {
  background: #444;
}

.btn-danger {
  background: #b91c1c;
  color: white;
  padding: 6px 12px;
  font-size: 0.8rem;
  width: auto;
}

.btn-danger:hover {
  background: #991b1b;
}

.btn-refresh,
.btn-back {
  color: #e0e0e0;
  background: none;
}

.btn-refresh:hover,
.btn-back:hover {
  color: #FFA500;
}

.btn-refresh {
  position: absolute;
  bottom: 32.5px;
  left: 350px;
  padding: 4px 8px;
  font-size: 0.9rem;
  width: auto;
  height: 20px;
  border-radius: 6px;
}

.btn-back {
  width: auto;
  bottom: 60px;
  padding: 4px 8px;
  margin-top: 6px;
  font-size: 1.0rem;
  gap: 4px;
}

.btn-back-arrow {
  font-size: 1.1rem;
}

/* Result Styles */
.result,
.cgpa-value,
.success {
  color: #39FF14;
}

.error {
  color: #ef4444;
}

/* Course Grid */
.course-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.1fr 1.1fr auto;
  gap: 8px;
  align-items: center;
}

/* Delete Button */
.delete-btn {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 1.4rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Previous Grade Field */
.prev-grade-container {
  grid-column: 3 / 4;
  margin-top: 0;
}

.prev-grade-container .input-field {
  font-size: 1.1rem;
  padding: 8px 10px;
  width: 95%;
}

/* Checkbox Styles */
.checkbox-container,
.retake-container {
  display: flex;
  align-items: center;
  margin: 8px 0;
}

.checkbox-container input[type="checkbox"],
.retake-container input[type="checkbox"] {
  accent-color: #FFA500;
  size: 1.3rem;
  margin-right: 8px;
  cursor: pointer;
  transform: scale(1.2);
}

.retake-container input[type="checkbox"]:checked {
  color: #FFA500;
}

/* Installments */
.installment-item {
  border-bottom: 1px dashed #333;
  margin: 4px 0;
  padding: 6px 0;
}

.installment-total {
  /*border-top: 1px solid #333;*/
  font-weight: 600;
  margin-top: 8px;
  padding-top: 8px;
}

/* Toggle & Hidden */
.section-toggle {
  cursor: pointer;
  user-select: none;
  margin-bottom: 16px;
}

.hidden {
  display: none;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 100;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.modal-content {
  background-color: #1e1e1e;
  margin: 10% auto;
  padding: 20px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  position: relative;
}

.close-modal {
  position: absolute;
  right: 20px;
  top: 10px;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  color: #999;
}

.close-modal:hover {
  color: #fff;
}

/* Select styling */
select.input-field {
  -webkit-appearance: none;
  appearance: none;
  background-color: #2b2b2b;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' stroke='currentColor' fill='none' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' viewBox='0 0 24 24'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px;
  padding-right: 30px;
  color: #ffffff;
}

/* Responsive Mobile Adjustments */
@media (max-width: 480px) {
  .calculator {
    margin: 10px;
  }

  .course-grid {
    grid-template-columns: 1.2fr 1fr 1fr auto;
    gap: 6px;
  }

  .course-grid .input-field {
    font-size: 0.85rem;
    padding: 8px 10px;
  }

  .course-grid button.delete-btn {
    font-size: 1.1rem;
    padding: 0;
  }

  .prev-grade-container {
    grid-column: 3 / 4;
  }

  .btn-refresh {
    left: auto;
    right: 24px;
  }
}

/* Tuition Fee Calculator row */
#cgpaSection .section-toggle {
  display: flex;
  align-items: center;
  font-size: 1.05rem;
  font-weight: 450;
  cursor: pointer;
  color: #ffffff;
}

/* Checkbox size */
#cgpaSection .section-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin-right: 10px;
  accent-color: #FFA500;
  cursor: pointer;
  transform: scale(1.2);
}
/* Mobile adjustments for Android / small screens */
@media (max-width: 480px) {
  /* Course grid tweaks */
  .course-grid button.delete-btn {
    font-size: 1.3rem;   /* slightly bigger than before */
    padding: 2px 4px;    /* better touch target */
  }

  /* Tuition Fee Calculator checkbox */
  #cgpaSection .section-toggle input[type="checkbox"] {
    width: 18px;         /* slightly smaller than before */
    height: 18px;
    transform: scale(1); /* reset scaling for better look */
    margin-right: 8px;
  }

  /* Checkbox label font */
  #cgpaSection .section-toggle label {
    font-size: 1rem;    /* readable, not too big */
  }
}
