/* GLOBAL RESET */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
body { background: #f4f7fb; color: #333; overflow-x: hidden; min-height: 100vh; display: flex; flex-direction: column; }

/* HEADER */
header {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(90deg, #1e3c72, #2a5298);
  color: white; padding: 10px 30px; border-bottom: 4px solid #3498db;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2); position: relative; z-index: 10;
}
.header-left img { width: 60px; background: white; border-radius: 8px; padding: 4px; display: block; transition: transform 0.2s; }
.header-left img:hover { transform: scale(1.05); }
.header-center h1 { font-size: 22px; margin: 0; font-weight: 700; letter-spacing: 1px; }
.header-right { display: flex; align-items: center; gap: 15px; }
.nav-link { color: #aed9e0; text-decoration: none; font-size: 14px; font-weight: bold; transition: 0.3s; }
.nav-link:hover { color: white; text-decoration: underline; }
.portal-btn {
  background: #f39c12; color: white; text-decoration: none; padding: 8px 15px;
  border-radius: 20px; font-size: 13px; font-weight: bold; border: 1px solid #e67e22; transition: 0.3s;
}
.portal-btn:hover { background: #d35400; transform: translateY(-2px); }
.icon-btn {
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4);
  color: white; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.icon-btn:hover { background: rgba(255,255,255,0.4); }

/* MAIN LAYOUT */
main { flex: 1; display: flex; justify-content: center; padding: 30px 20px; position: relative; }
.calculator-container { background: #fff; padding: 25px; border-radius: 14px; box-shadow: 0px 6px 15px rgba(0,0,0,0.1); width: 100%; max-width: 850px; text-align: center; }

/* TABS */
.tabs { display: flex; justify-content: center; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 2px solid #ddd; }
.tab-link {
  background: transparent; color: #777; border: none; padding: 15px 20px;
  font-size: 16px; font-weight: bold; cursor: pointer; border-bottom: 3px solid transparent; transition: 0.3s;
}
.tab-link:hover { color: #2a5298; }
.tab-link.active { color: #2a5298; border-bottom: 3px solid #2a5298; }
.tab-content { animation: fadeIn 0.4s; }

/* CONTROLS */
.controls { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 20px; background: #eef4ff; padding: 15px; border-radius: 8px; border: 1px solid #dcebf7; }
.control-group { display: flex; flex-direction: column; text-align: left; flex: 1; min-width: 200px; }
.control-group select { padding: 8px; border-radius: 5px; border: 1px solid #ccc; margin-top: 5px; }

/* CUSTOM SETTINGS */
.custom-settings { width: 100%; display: flex; gap: 15px; background: #fff; padding: 10px; margin-top: 10px; border: 1px dashed #2a5298; border-radius: 5px; }
.custom-settings.hidden { display: none; }
.small-input { display: flex; flex-direction: column; flex: 1; text-align: left; }
.small-input input { padding: 5px; border: 1px solid #bbb; border-radius: 4px; }

/* TABLE */
table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
table th, table td { border: 1px solid #ddd; padding: 10px; text-align: center; }
table th { background: #2a5298; color: white; font-size: 14px; }
table input { width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; text-align: center; }
table input:focus { border-color: #2a5298; outline: none; }

/* BUTTONS */
.buttons { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
button { padding: 10px 18px; border: none; border-radius: 6px; background: #2a5298; color: white; cursor: pointer; font-size: 14px; transition: 0.2s; }
button:hover { transform: scale(1.05); }
.reset-btn { background: #f39c12; } .reset-btn:hover { background: #e67e22; }
.calc-btn { background: #27ae60; } .calc-btn:hover { background: #2ecc71; }
.delete-btn { background: #c0392b; padding: 6px 10px; } .delete-btn:hover { background: #e74c3c; }

/* NEW: SEMESTER GRID (Tab 3) */
.semester-grid {
  display: grid;
  grid-template-columns: 1fr 1fr; /* 2 Columns */
  gap: 15px;
  max-width: 500px;
  margin: 0 auto;
}
.semester-grid .input-group { text-align: left; }

/* CGPA FORM */
.cgpa-container { text-align: center; }
.cgpa-form { display: flex; flex-direction: column; gap: 15px; max-width: 400px; margin: 20px auto; text-align: left; }
.input-group label { font-weight: bold; font-size: 14px; color: #555; }
.input-group input { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px; }
.divider { text-align: center; color: #aaa; font-weight: bold; font-size: 12px; letter-spacing: 1px; }

/* RESULTS */
.result-box { margin-top: 20px; padding: 15px; background: #eef4ff; border-left: 5px solid #2a5298; border-radius: 6px; text-align: left; min-height: 20px; }
.result-box h3 { margin: 0; color: #2a5298; }

/* HISTORY SIDEBAR */
.history-panel {
  position: fixed; right: 0; top: 70px; bottom: 0; width: 300px;
  background: white; border-left: 1px solid #ccc; padding: 20px;
  box-shadow: -5px 0 15px rgba(0,0,0,0.1); transform: translateX(0);
  transition: transform 0.3s ease; z-index: 100; overflow-y: auto;
}
.history-panel.hidden { transform: translateX(100%); }
.history-item { list-style: none; background: #f9f9f9; border: 1px solid #ddd; padding: 10px; margin-bottom: 10px; border-radius: 5px; }
.danger-btn { background: #c0392b; width: 100%; margin-top: 10px; }

/* FOOTER */
footer { background: #1e3c72; color: white; text-align: center; padding: 15px; margin-top: auto; font-size: 13px; }
footer a { color: #f39c12; text-decoration: none; }

/* Responsive */
@media (max-width: 768px) {
  header { flex-direction: column; gap: 10px; padding: 15px; }
  .header-right { width: 100%; justify-content: center; flex-wrap: wrap; }
  .controls { flex-direction: column; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }