/* ============================
   ROOT VARIABLES
============================ */
:root {
  --form-width: 400px;
  --form-padding: 45px 35px;

  --modal-max-width: 900px;
  --modal-padding: 25px;

  --blur-strength: 12px;
  --glass-bg: rgba(255, 255, 255, 0.13);
}

/* ============================
   GLOBAL RESET
============================ */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ============================
   BODY
============================ */
body {
  min-height: 100vh;
  background: #080710;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Poppins", sans-serif;
  color: #fff;
  overflow-x: hidden;
}

body.admin-page {
  align-items: flex-start;
  justify-content: center;
  padding: 18px 0;
  overflow-y: auto;
}

/* ============================
   BACKGROUND SHAPES
============================ */
.background {
  width: 430px;
  height: 520px;
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
}

.background .shape {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
}

.shape:first-child {
  background: linear-gradient(#1845ad, #23a2f6);
  left: -80px;
  top: -80px;
}

.shape:last-child {
  background: linear-gradient(to right, #ff512f, #f09819);
  right: -30px;
  bottom: -80px;
}

/* ============================
   GLASS FORM (DESKTOP)
============================ */
form {
  width: var(--form-width);
  padding: var(--form-padding);
  background: var(--glass-bg);
  border-radius: 14px;
  backdrop-filter: blur(var(--blur-strength));
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 40px rgba(8, 7, 16, 0.6);
  z-index: 2;
}

form h3 {
  text-align: center;
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 30px;
}

/* ============================
   LOGOS
============================ */
.form-logo {
  display: block;
  margin: 0 auto 15px;
  max-height: 60px;
}

.modal-logo {
  display: block;
  margin-bottom: 12px;
  max-height: 45px;
}

/* ============================
   LABELS & INPUTS
============================ */
label {
  font-size: 14px;
  font-weight: 500;
  margin-top: 18px;
  display: block;
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
}

input {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  border: none;
}

#adminForm {
  width: min(1200px, 96vw);
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.admin-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-toolbar .field {
  flex: 1 1 220px;
  min-width: 220px;
}

.update-only.hidden {
  display: none;
}

.admin-card {
  padding: 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
}

.admin-card h4 {
  margin-bottom: 8px;
}

.field-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
}

.field {
  flex: 1 1 calc(50% - 12px);
  min-width: 220px;
}

.field.full {
  flex: 1 1 100%;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.btn-row button {
  margin-top: 0;
  width: auto;
  flex: 1 1 0;
}

.fee-sections {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.fee-card {
  flex: 1 1 320px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px;
}

.fee-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.fee-title-row h5 {
  margin: 0;
}

.fee-title-row button {
  margin-top: 0;
  width: auto;
  padding: 8px 12px;
  font-size: 13px;
}

.fee-rows {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fee-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr auto;
  gap: 8px;
  align-items: center;
}

.fee-row input,
.fee-row select {
  margin-top: 0;
  height: 40px;
}

.fee-row .remove-row-btn {
  margin-top: 0;
  width: auto;
  padding: 8px 10px;
  font-size: 13px;
}

.password-wrap {
  position: relative;
  margin-top: 8px;
}

.password-wrap input {
  margin-top: 0;
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  margin-top: 0;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

.password-toggle.active {
  background: rgba(255, 179, 71, 0.35);
}

select {
  width: 100%;
  height: 48px;
  margin-top: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  color: #fff;
  font-size: 14px;
  border: none;
}

input::placeholder {
  color: #e5e5e5;
}

input:focus {
  outline: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

select:focus {
  outline: none;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

select option {
  color: #111;
}

/* ============================
   BUTTONS
============================ */
button {
  width: 100%;
  margin-top: 32px;
  padding: 14px 0;
  font-size: 16px;
  font-weight: 600;
  color: #4a2a00;
  background: linear-gradient(135deg, #ffd194, #ffb347);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.25s ease;
  border: none;
}

button:hover {
  transform: translateY(-1px);
  opacity: 0.95;
}

/* ============================
   RESULT SUMMARY
============================ */
#result {
  margin-top: 20px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  font-size: 14px;
}

/* ============================
   MODAL (DESKTOP)
============================ */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow-y: auto;
}

/* Helper class for showing modal as flex so centering works */
.modal.is-open {
  display: flex;
}

.modal-content {
  background: rgba(255, 255, 255, 0.15);
  padding: var(--modal-padding);
  width: 100%;
  max-width: var(--modal-max-width);
  border-radius: 18px;
  color: #fff;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.close {
  float: right;
  font-size: 22px;
  cursor: pointer;
}

#exportActions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

#exportActions button {
  width: 100%;
}

/* ============================
   TABLE
============================ */
table {
  width: 100%;
  margin-top: 15px;
  border-collapse: collapse;
  font-size: 13px;
}

table th,
table td {
  padding: 8px;
  text-align: right;
}

table th:first-child,
table td:first-child {
  text-align: center;
}

table tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.05);
}

#installBtn {
  display: none;
}

.install-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.install-link {
  padding: 0;
  width: auto;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
}

.install-link:hover {
  color: #ffb347;
}

#installBtn {
  display: none;
}

/* ============================
   MOBILE APP MODE
============================ */
@media (max-width: 768px) {
  body {
    align-items: stretch;
    justify-content: flex-start;
    padding: 0;
  }

  /* FULLSCREEN FORMS */
  #loginForm,
  #calcForm,
  #adminForm {
    width: 100vw;
    max-width: 100vw;
    min-height: 100vh;
    padding: 26px 18px;
    border-radius: 0;
    box-shadow: none;
  }

  body.admin-page {
    padding: 0;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .field {
    flex: 1 1 100%;
    min-width: 0;
  }

  .fee-row {
    grid-template-columns: 1fr;
  }

  form h3 {
    font-size: 22px;
  }

  .background {
    width: 100%;
    height: 100%;
    left: 0;
    top: 0;
    transform: none;
  }

  .shape:first-child {
    left: -60px;
    top: 30%;
  }

  .shape:last-child {
    right: -50px;
    bottom: 18%;
  }

  /* FULLSCREEN MODAL */
  .modal {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
  }

  .modal-content {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    padding: 22px 18px;
  }

  #exportActions {
    flex-direction: column;
  }

  table {
    font-size: 12px;
  }
}
