:root {
  --indigo-dark: #a5b4fc;
  --indigo-mid: #6366f1;
  --indigo: #818cf8;
  --indigo-light: #c7d2fe;
  --indigo-pale: rgba(99, 102, 241, 0.1);
  --indigo-bg: rgba(15, 23, 42, 0.4);
  --slate-dark: #f1f5f9;
  --slate-muted: #94a3b8;
  --slate-light: rgba(30, 41, 59, 0.4);
  --white: rgba(30, 41, 59, 0.4);
  --success: #10b981;
  --success-dark: #059669;
  --border: rgba(255, 255, 255, 0.05);
  --shadow: rgba(99, 102, 241, 0.05);
}

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

body {
  font-family: 'Inter', 'Mukta', 'Noto Sans Devanagari', sans-serif;
  background: radial-gradient(circle at top, #1e1b4b 0%, #0f172a 100%);
  min-height: 100vh;
  color: #cbd5e1;
  padding-top: 75px; /* space for topbar */
}

/* Topbar */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
  padding: 10px 20px;
}

.topbar-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 15px;
}

.back-btn {
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.3s;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 16px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(1.03);
  color: #fff;
}

.topbar-logo-group {
  display: flex;
  flex-direction: column;
}

.topbar-logo-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #818cf8;
  display: flex;
  align-items: center;
  line-height: 1;
}

.topbar-logo-subtitle {
  font-size: 7px;
  font-weight: bold;
  color: #64748b;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  line-height: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge, .balance-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #a5b4fc;
}

/* Container */
.container {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px;
}

/* Header Welcome Card */
.welcome-card {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 30px 24px;
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.05);
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

.welcome-info h2 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(to right, #a5b4fc, #818cf8, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.welcome-info p {
  font-size: 0.9rem;
  color: #94a3b8;
  font-weight: 500;
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 5px;
}

.tab-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #cbd5e1;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.tab-btn.active {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border-color: #6366f1;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

/* Tab Contents */
.tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

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

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

/* Common Card Styling */
.tool-card {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.05);
  margin-bottom: 24px;
}

.tool-card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

/* Tab 1: Portal Links Grid */
.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.link-item {
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: #cbd5e1;
  transition: all 0.3s;
}

.link-item:hover {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(15, 23, 42, 0.6);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(99, 102, 241, 0.1);
  color: #fff;
}

.link-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.08);
  color: #818cf8;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.link-info {
  display: flex;
  flex-direction: column;
}

.link-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f1f5f9;
  line-height: 1.3;
}

.link-desc {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 2px;
}

/* Tab 2: Image Resizer */
.resizer-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 768px) {
  .resizer-container {
    grid-template-columns: 1fr 1fr;
  }
}

.upload-box {
  border: 2px dashed rgba(255, 255, 255, 0.15);
  background: rgba(15, 23, 42, 0.2);
  border-radius: 14px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.upload-box:hover {
  border-color: #6366f1;
  background: rgba(15, 23, 42, 0.4);
  color: #fff;
}

.upload-box svg {
  width: 40px;
  height: 40px;
  color: #818cf8;
}

.upload-box p {
  font-size: 0.9rem;
  font-weight: 600;
  color: #cbd5e1;
}

.resizer-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.resizer-presets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.preset-btn.active {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

.preset-btn span.title {
  font-size: 0.9rem;
  font-weight: 800;
  color: #f1f5f9;
}

.preset-btn span.detail {
  font-size: 0.75rem;
  color: #94a3b8;
}

.resizer-actions {
  margin-top: 10px;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
  transform: translateY(-1.5px);
  box-shadow: 0 6px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.preview-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  background: rgba(15, 23, 42, 0.4);
  padding: 20px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.preview-img-container {
  max-width: 100%;
  max-height: 250px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.6);
}

.preview-img-container img {
  display: block;
  max-width: 100%;
  max-height: 250px;
  object-fit: contain;
}

.preview-stats {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--slate-muted);
  text-align: center;
}

.download-link {
  width: 100%;
  background: var(--success);
  color: white;
  text-decoration: none;
  text-align: center;
  border-radius: 10px;
  padding: 12px;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.download-link:hover {
  background: var(--success-dark);
}

/* Tab 3: Age Calculator */
.calc-form {
  max-width: 450px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

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

.form-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--slate-muted);
}

.form-control {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 1rem;
  outline: none;
  background: var(--slate-light);
  transition: all 0.2s;
}

.form-control:focus {
  border-color: var(--indigo-mid);
  background: white;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.calc-result {
  margin-top: 20px;
  background: var(--indigo-bg);
  border: 1px solid var(--indigo-pale);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  animation: fadeIn 0.3s;
}

.calc-result h4 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--indigo-dark);
  margin-bottom: 10px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.result-box {
  background: white;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--indigo-pale);
}

.result-val {
  font-size: 1.4rem;
  font-weight: 955;
  color: var(--indigo-mid);
}

.result-lbl {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--slate-muted);
  margin-top: 2px;
}

/* Tab 4: Family Register Printer */
.family-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 992px) {
  .family-container {
    grid-template-columns: 1.2fr 1fr;
  }
}

.member-form-section {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.members-list-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.members-list-table th, .members-list-table td {
  padding: 10px;
  border: 1px solid var(--border);
  text-align: left;
  font-size: 0.85rem;
}

.members-list-table th {
  background: var(--slate-light);
  font-weight: bold;
}

.action-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s;
}

.action-btn.delete { color: #ef4444; }
.action-btn.delete:hover { background: #fef2f2; }

/* Print Layout Styles (A4 Preview) */
.a4-preview-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.a4-page {
  width: 210mm;
  min-height: 297mm;
  padding: 20mm 15mm;
  background: white;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
  box-sizing: border-box;
  transform-origin: top center;
  font-family: 'Noto Sans Devanagari', sans-serif;
  color: black;
}

.a4-header {
  text-align: center;
  border-bottom: 2px double #000;
  padding-bottom: 15px;
  margin-bottom: 20px;
}

.a4-header h2 { font-size: 20px; font-weight: 800; }
.a4-header h3 { font-size: 16px; font-weight: 700; margin-top: 5px; }

.a4-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 13px;
  font-weight: 600;
}

.a4-meta-item {
  border-bottom: 1px dashed #999;
  padding-bottom: 4px;
}

.a4-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 30px;
}

.a4-table th, .a4-table td {
  border: 1px solid black;
  padding: 8px;
  font-size: 12px;
  text-align: center;
}

.a4-table th {
  background: #f2f2f2;
}

.a4-signatures {
  margin-top: 60px;
  display: flex;
  justify-content: space-between;
}

.a4-sig-box {
  text-align: center;
  width: 180px;
  border-top: 1px dashed #000;
  padding-top: 6px;
  font-size: 12px;
  font-weight: bold;
}

/* Scaling container for fit preview */
.preview-scale-container {
  width: 100%;
  overflow-x: auto;
  display: flex;
  justify-content: center;
}

@media print {
  body {
    background: white;
    padding: 0;
  }
  .topbar, .tabs-nav, .welcome-card, .tool-card-title, .member-form-section, .a4-preview-box h4, .a4-preview-box button, .a4-preview-box p, .preview-scale-container ~ * {
    display: none !important;
  }
  .tab-content:not(.active) {
    display: none !important;
  }
  .container {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }
  .a4-preview-box {
    border: none;
    padding: 0;
  }
  .a4-page {
    box-shadow: none;
    transform: none !important;
    margin: 0;
    width: 100%;
    height: auto;
    page-break-after: avoid;
  }
  @page {
    size: A4 portrait;
    margin: 0;
  }
}
