/* Global Variables & Reset */
:root {
  --primary: #e67e22;
  --primary-light: #f39c12;
  --primary-rgb: 230, 126, 34;
  --secondary: #2c3e50;
  --secondary-light: #34495e;
  --background: #f5f6fa;
  --card-bg: rgba(255, 255, 255, 0.9);
  --text-main: #2d3436;
  --text-muted: #636e72;
  --border: rgba(224, 224, 224, 0.6);
  --success: #2ecc71;
  --danger: #e74c3c;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 15px 35px rgba(0, 0, 0, 0.12);
  --radius: 14px;
  --radius-sm: 14px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Outfit', 'Anek Gujarati', sans-serif;
  background-color: var(--background);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* App Container Layout */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1400px;
  min-height: 100vh;
}

/* Header Styling */
.app-header {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--secondary-light) 100%);
  color: white;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 4px solid var(--primary);
  box-shadow: var(--shadow);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 15px;
}

.logo-icon {
  font-size: 2.2rem;
  color: var(--primary-light);
  background: rgba(255, 255, 255, 0.1);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.logo-area h1 {
  font-family: 'Anek Gujarati', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.2;
}

.logo-area p {
  font-size: 0.85rem;
  opacity: 0.7;
  letter-spacing: 1px;
}

.nav-tabs {
  display: flex;
  gap: 12px;
}

.nav-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
  padding: 10px 20px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

.nav-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 4px 15px rgba(230, 126, 34, 0.4);
}

.pwa-install-btn {
  background: linear-gradient(45deg, #12cbc4, #1289a7);
  border: none;
  color: white;
  padding: 10px 18px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  box-shadow: 0 4px 12px rgba(18, 137, 167, 0.3);
}

.pwa-install-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(18, 137, 167, 0.4);
}

/* Main Content Area */
.main-content {
  flex: 1;
  padding: 30px;
  position: relative;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Common Card Styles */
.card {
  background-color: var(--card-bg);
  backdrop-filter: blur(15px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: var(--shadow-hover);
}

/* Create ID Card Grid */
.pane-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 30px;
  align-items: start;
}

/* Form Styles */
.form-card h2,
.records-header-card h2 {
  font-size: 1.3rem;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--secondary);
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: span 2;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--secondary-light);
  display: flex;
  align-items: center;
  gap: 6px;
}

.required {
  color: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid rgba(189, 195, 199, 0.6);
  font-family: inherit;
  font-size: 0.95rem;
  background-color: white;
  color: var(--text-main);
  transition: all 0.3s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(230, 126, 34, 0.15);
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Photo Upload Area */
.photo-upload-zone {
  border: 2px dashed rgba(var(--primary-rgb), 0.4);
  border-radius: var(--radius-sm);
  padding: 24px;
  text-align: center;
  background-color: rgba(var(--primary-rgb), 0.02);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  overflow: hidden;
}

.photo-upload-zone:hover {
  background-color: rgba(var(--primary-rgb), 0.05);
  border-color: var(--primary);
}

.upload-prompt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--primary);
}

.upload-prompt i {
  font-size: 2.2rem;
}

.upload-prompt p {
  font-weight: 600;
  font-size: 0.95rem;
}

.upload-prompt span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

#upload-preview-img {
  max-height: 120px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  object-fit: cover;
  aspect-ratio: 3/4;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border-radius: 14px;
  border: none;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 15px rgba(230, 126, 34, 0.3);
}

.btn-primary:hover {
  background: #d35400;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(230, 126, 34, 0.4);
}

.btn-secondary {
  background-color: #e2e8f0;
  color: #475569;
}

.btn-secondary:hover {
  background-color: #cbd5e1;
}

.btn-pdf {
  background: linear-gradient(135deg, #ff7675, #d63031);
  color: white;
  box-shadow: 0 4px 12px rgba(214, 48, 49, 0.3);
}

.btn-pdf:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(214, 48, 49, 0.45);
}

.btn-icon {
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
}

.text-red {
  color: var(--danger);
}

/* Live Card Preview Column */
.preview-column {
  position: relative;
}

.preview-sticky-container {
  position: sticky;
  top: 30px;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title-row h2 {
  font-size: 1.25rem;
  color: var(--secondary);
}

/* The actual Card Preview Sheet */
.card-render-wrapper {
  background-color: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1px solid var(--border);
  width: 100%;
  overflow: hidden;
}

.scaled-card-container {
  position: relative;
  width: 100%;
  max-width: 727.56px;
  aspect-ratio: 727.56 / 558.36;
  overflow: hidden;
}

/* ID Card Sheet Container matches proportions of original page render (727.56px x 558.36px) */
.id-card-sheet {
  position: absolute;
  left: 50%;
  top: 0;
  width: 727.56px;
  height: 558.36px;
  min-width: 727.56px;
  background-image: url('/assets/template_bg_clean.png?v=11');
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: flex;
  overflow: hidden;
  transform-origin: top center;
}

.id-card-front,
.id-card-back {
  position: relative;
  width: 50%;
  flex: 0 0 50%;
  max-width: 50%;
  height: 100%;
  box-sizing: border-box;
}

.photo-overlay-box {
  position: absolute;
  left: 37.3%;
  top: 24.3%;
  width: 35.3%;
  height: 28.8%;
  border-radius: 10px;
  /* matches strict 14px border radius request */
  border: none;
  /* no border, fits inside predefined template border */
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.photo-overlay-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.card-value {
  position: absolute;
  font-family: 'Anek Gujarati', sans-serif;
  color: #1a1a1a;
  left: 39.2%;
  white-space: nowrap;
  font-weight: 700;
}

.name-value {
  top: 56.4%;
  font-size: 16px;
  letter-spacing: -0.1px;
}

.id-value {
  top: 60.1%;
  font-size: 13.5px;
  color: inherit;
}

.dob-value {
  top: 64.0%;
  font-size: 13px;
}

.role-value {
  top: 68.2%;
  font-size: 13px;
}

.mobile-value {
  top: 72.3%;
  font-size: 13px;
}

.blood-value {
  top: 76.4%;
  font-size: 13px;
}

.address-value {
  top: 80.5%;
  font-size: 12px;
  width: 53%;
  line-height: 1.55;
  white-space: normal;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 5px;
}

/* Records List Tab */
.records-header-card {
  margin-bottom: 24px;
}

.records-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.records-header-row h2 {
  border: none;
  padding: 0;
  margin: 0;
}

.stats-badge {
  background: rgba(var(--primary-rgb), 0.1);
  color: var(--primary);
  padding: 8px 16px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.9rem;
}

.search-bar-row {
  display: flex;
  gap: 12px;
  margin-top: 15px;
}

.search-box {
  flex: 1;
  position: relative;
}

.search-box i {
  position: absolute;
  left: 15px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.search-box input {
  padding-left: 45px;
}

/* Members Grid */
.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.member-record-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}

.member-record-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.member-card-header {
  background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.05) 0%, rgba(var(--primary-rgb), 0.02) 100%);
  padding: 18px;
  display: flex;
  gap: 15px;
  border-bottom: 1px solid var(--border);
}

.member-card-avatar {
  width: 75px;
  height: 100px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  background-color: #f1f2f6;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.member-card-title-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.member-card-title-info h3 {
  font-family: 'Anek Gujarati', sans-serif;
  font-size: 1.15rem;
  color: var(--secondary);
  margin-bottom: 4px;
}

.member-id-badge {
  display: inline-block;
  font-size: 0.8rem;
  background-color: var(--secondary);
  color: white;
  padding: 3px 8px;
  border-radius: 4px;
  width: max-content;
  font-weight: 700;
  margin-bottom: 4px;
}

.member-role-badge {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 700;
}

.member-card-body {
  padding: 18px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.85rem;
}

.info-item {
  display: flex;
  justify-content: space-between;
}

.info-label {
  color: var(--text-muted);
  font-weight: 500;
}

.info-val {
  font-weight: 600;
  color: var(--text-main);
  text-align: right;
  max-width: 60%;
}

.member-card-footer {
  padding: 12px 18px;
  background-color: #fafbfc;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.member-card-footer button {
  flex: 1;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.85rem;
}

.no-records-view {
  text-align: center;
  padding: 60px 20px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.no-records-view i {
  font-size: 4rem;
  color: rgba(var(--primary-rgb), 0.15);
  margin-bottom: 15px;
}

.no-records-view h3 {
  font-size: 1.3rem;
  color: var(--secondary);
  margin-bottom: 8px;
}

.no-records-view p {
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Image Cropper Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  align-items: center;
  justify-content: center;
}

.modal.open {
  display: flex;
}

.modal-content {
  background-color: white;
  border-radius: var(--radius);
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
  from {
    transform: translateY(30px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-header {
  padding: 16px 20px;
  background: var(--secondary);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.close-modal-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.8rem;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.cropper-wrapper {
  max-height: 350px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background-color: #f1f2f6;
  display: flex;
  justify-content: center;
}

.cropper-wrapper img {
  max-width: 100%;
  display: block;
}

.cropper-controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 15px;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: #fafbfc;
}

/* Responsive Scaling details for Card Preview */
@media(max-width: 1200px) {
  .pane-grid {
    grid-template-columns: 1fr;
  }

  .preview-sticky-container {
    position: static;
  }
}

@media(max-width: 768px) {
  .app-header {
    flex-direction: column;
    gap: 15px;
    padding: 15px;
    align-items: stretch;
  }

  .nav-tabs {
    justify-content: center;
  }

  .main-content {
    padding: 15px;
  }

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

  .form-group.full-width {
    grid-column: span 1;
  }

  /* Scale down the large fixed card preview so it fits on mobile */
  .card-render-wrapper {
    padding: 5px;
    justify-content: center;
  }

  /* Apply transform scaling on small viewports so card doesn't overflow */
  .id-card-sheet {
    transform-origin: top center;
  }
}

/* PWA Banner Styles */
.pwa-banner {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  padding: 12px 20px;
  border-radius: 14px;
  /* matches 14px radius constraint */
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow);
  animation: slideDown 0.4s ease;
  flex-wrap: wrap;
  gap: 12px;
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.95rem;
}

.pwa-banner-content i {
  font-size: 1.4rem;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-pwa-install {
  background: white;
  color: var(--primary);
  border: none;
  padding: 8px 16px;
  border-radius: 14px;
  /* matches strict 14px border radius request */
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-pwa-install:hover {
  background: #fdfdfd;
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.btn-pwa-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0 5px;
  line-height: 1;
}

.btn-pwa-close:hover {
  opacity: 0.8;
}

/* Mobile sub-tabs controls */
.mobile-sub-tabs {
  display: none;
  gap: 10px;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.8);
  padding: 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.sub-tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 10px;
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.sub-tab-btn.active {
  background: var(--secondary);
  color: white;
  box-shadow: 0 4px 10px rgba(44, 62, 80, 0.2);
}

.mobile-only-btn {
  display: none;
}

@media(max-width: 1200px) {
  .mobile-sub-tabs {
    display: flex;
  }

  .pane-grid.show-form .preview-column {
    display: none !important;
  }

  .pane-grid.show-preview .form-card {
    display: none !important;
  }

  .pane-grid.show-preview .preview-column {
    display: block !important;
  }

  .pane-grid.show-form .form-card {
    display: block !important;
  }

  .mobile-only-btn {
    display: inline-flex;
  }
}

/* Secure Admin Login Screen */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top right, rgba(230, 126, 34, 0.15) 0%, rgba(44, 62, 80, 0.95) 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  padding: 35px 30px;
  text-align: center;
  animation: modalSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.login-logo {
  width: 70px;
  height: 70px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 8px 20px rgba(230, 126, 34, 0.3);
}

.login-logo i {
  font-size: 2.2rem;
  color: white;
}

.login-card h2 {
  font-family: 'Anek Gujarati', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--secondary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.login-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 25px;
  font-weight: 500;
}

.login-card label {
  font-size: 0.85rem;
  color: var(--secondary-light);
  margin-bottom: 6px;
  text-align: left;
  display: block;
}

.login-card input {
  background: white;
  border: 1.5px solid rgba(189, 195, 199, 0.4);
}

.login-card input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(230, 126, 34, 0.15);
}

.login-error {
  background: rgba(231, 76, 60, 0.1);
  border: 1px solid rgba(231, 76, 60, 0.2);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.85rem;
  margin-top: 15px;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.login-submit-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border: none;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 1.05rem;
  padding: 14px;
  box-shadow: 0 6px 20px rgba(230, 126, 34, 0.3);
}

.login-submit-btn:hover {
  transform: translateY(-1.5px);
  box-shadow: 0 8px 25px rgba(230, 126, 34, 0.4);
}

.logout-btn {
  background-color: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
  transition: all 0.3s ease;
}

.logout-btn:hover {
  background-color: var(--danger);
  border-color: var(--danger);
  color: white;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}