/* Import modern Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #0b0c16;
  --bg-secondary: #121425;
  --bg-card: rgba(26, 29, 54, 0.7);
  --bg-card-hover: rgba(36, 40, 74, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  
  --accent-gold: #ffc107;
  --accent-gold-gradient: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
  --accent-purple: #7952b3;
  
  --color-text-primary: #ffffff;
  --color-text-secondary: #9aa0c4;
  --color-text-muted: #676d93;
  
  --color-success: #10b981;
  --color-success-bg: rgba(16, 185, 129, 0.15);
  --color-danger: #ef4444;
  --color-danger-bg: rgba(239, 68, 68, 0.15);
  --color-warning: #f59e0b;
  --color-warning-bg: rgba(245, 158, 11, 0.15);
  --color-info: #3b82f6;
  --color-info-bg: rgba(59, 130, 246, 0.15);

  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-glow: 0 0 15px rgba(255, 193, 7, 0.2);
  --border-radius: 16px;
  --transition-speed: 0.25s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: #05060b;
  color: var(--color-text-primary);
  font-family: var(--font-body);
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  overflow-x: hidden;
}

/* App container - Mocking a mobile device on desktop, full screen on mobile */
.app-container {
  width: 100%;
  max-width: 480px;
  height: 100vh;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
}

@media (min-width: 480px) {
  .app-container {
    height: 850px;
    border-radius: 36px;
    border: 6px solid #222538;
  }
}

/* Header */
.app-header {
  background-color: rgba(18, 20, 37, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  position: sticky;
  top: 0;
}

.brand-section {
  display: flex;
  flex-direction: column;
}

.mandal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #ffffff, #ffe082);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.mandal-subtitle {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.lang-switch {
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  display: flex;
  padding: 2px;
  cursor: pointer;
}

.lang-btn {
  padding: 4px 10px;
  border-radius: 18px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  transition: all var(--transition-speed);
}

.lang-btn.active {
  background: var(--accent-gold-gradient);
  color: #000000;
  box-shadow: 0 2px 6px rgba(255, 193, 7, 0.4);
}

/* Content Area */
.app-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-bottom: 90px; /* Space for navbar */
  scrollbar-width: none; /* Hide scrollbar for Firefox */
}

.app-content::-webkit-scrollbar {
  display: none; /* Hide scrollbar for Chrome/Safari */
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: rgba(18, 20, 37, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: space-around;
  padding: 10px 5px 12px 5px;
  border-top: 1px solid var(--border-color);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.65rem;
  font-weight: 500;
  gap: 4px;
  width: 20%;
  transition: color var(--transition-speed);
  cursor: pointer;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: transform var(--transition-speed), fill var(--transition-speed);
}

.nav-item.active {
  color: var(--accent-gold);
}

.nav-item.active svg {
  transform: translateY(-2px);
  filter: drop-shadow(0 0 5px rgba(255, 193, 7, 0.3));
}

/* Cards & Layout Grid */
.page {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.page.active {
  display: block;
}

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

.section-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition-speed);
}

.summary-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.summary-card.wide {
  grid-column: span 2;
  background: linear-gradient(135deg, rgba(26, 29, 54, 0.9) 0%, rgba(18, 20, 37, 0.9) 100%);
  border-left: 4px solid var(--accent-gold);
}

.card-label {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  font-weight: 500;
}

.card-value {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
}

.summary-card.savings .card-value {
  color: var(--color-success);
}

.summary-card.loans .card-value {
  color: var(--color-danger);
}

.summary-card.wide .card-value {
  color: var(--accent-gold);
}

/* Quick Actions */
.quick-actions-row {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.action-btn {
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--color-text-primary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.action-btn:hover {
  background: rgba(255, 193, 7, 0.08);
  border-color: rgba(255, 193, 7, 0.3);
  transform: translateY(-1px);
}

.action-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--accent-gold);
}

/* Progress bar container */
.progress-container {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-card);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.progress-bar-outer {
  height: 10px;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  overflow: hidden;
  display: flex;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent-gold-gradient);
  border-radius: 5px;
  transition: width 0.5s ease-out;
}

.progress-details {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.75rem;
}

/* Members tab styling */
.search-wrapper {
  position: relative;
  margin-bottom: 16px;
}

.search-input {
  width: 100%;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px 12px 40px;
  color: var(--color-text-primary);
  font-size: 0.85rem;
  outline: none;
  transition: all var(--transition-speed);
}

.search-input:focus {
  border-color: var(--accent-gold);
  box-shadow: var(--shadow-glow);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  fill: var(--color-text-muted);
  width: 16px;
  height: 16px;
}

.members-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.member-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.member-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 193, 7, 0.2);
}

.member-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.member-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.member-id {
  background-color: rgba(255, 255, 255, 0.08);
  color: var(--color-text-secondary);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.member-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.member-savings-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.member-outstanding {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.outstanding-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.outstanding-value {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
}

.outstanding-value.has-loan {
  color: var(--color-danger);
}

.outstanding-value.no-loan {
  color: var(--color-text-muted);
}

/* Detail Views / Modals */
.sheet-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.sheet-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 85%;
  background-color: var(--bg-secondary);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  border-top: 1px solid var(--border-color);
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.1, 0.76, 0.55, 0.94);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bottom-sheet.active {
  transform: translateY(0);
}

.sheet-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.sheet-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--color-text-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  font-weight: bold;
}

.sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Forms styling */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px;
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  outline: none;
  transition: border var(--transition-speed);
}

.form-control:focus {
  border-color: var(--accent-gold);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%239aa0c4'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 20px;
  padding-right: 36px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  cursor: pointer;
}

.form-check-input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-gold);
  cursor: pointer;
}

.form-check-label {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.btn-primary {
  width: 100%;
  background: var(--accent-gold-gradient);
  border: none;
  border-radius: 12px;
  padding: 14px;
  color: #000000;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all var(--transition-speed);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(255, 193, 7, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px rgba(255, 193, 7, 0.4);
}

.btn-primary:disabled {
  background: var(--color-text-muted);
  color: var(--bg-primary);
  box-shadow: none;
  cursor: not-allowed;
}

/* Calculation summary section in forms */
.calc-summary {
  background-color: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border-color);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 20px;
}

.calc-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.calc-row:last-child {
  margin-bottom: 0;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.calc-highlight {
  color: var(--accent-gold);
}

.calc-penalty {
  color: var(--color-danger);
}

/* Member profile view layout */
.profile-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 16px;
}

.profile-header-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.profile-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.profile-stats-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.profile-stat-box {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.profile-stat-label {
  font-size: 0.7rem;
  color: var(--color-text-secondary);
}

.profile-stat-val {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  background-color: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.history-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-date {
  font-weight: 600;
}

.history-desc {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

.history-amount {
  font-weight: 700;
  font-family: var(--font-display);
}

.history-amount.credit {
  color: var(--color-success);
}

.history-amount.debit {
  color: var(--color-danger);
}

/* Info notices */
.alert-box {
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.78rem;
  line-height: 1.4;
  margin-bottom: 16px;
  display: flex;
  gap: 8px;
}

.alert-box.info {
  background-color: var(--color-info-bg);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.alert-box.warning {
  background-color: var(--color-warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fde047;
}

.alert-box.danger {
  background-color: var(--color-danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

/* Tabs inside profile or rules */
.profile-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 14px;
}

.profile-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-speed);
}

.profile-tab.active {
  color: var(--accent-gold);
  border-bottom-color: var(--accent-gold);
}

.profile-tab-content {
  display: none;
}

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

/* Rules screen resolutions */
.resolution-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.resolution-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-card);
}

.res-header {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-gold);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.res-text {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--color-text-primary);
}

.res-subrules {
  margin-top: 8px;
  padding-left: 16px;
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

.res-subrules li {
  margin-bottom: 4px;
}

/* Settings Buttons */
.settings-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-btn {
  width: 100%;
  background-color: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--color-text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition-speed);
}

.settings-btn:hover {
  background-color: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.settings-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--color-text-secondary);
}

.settings-btn.danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.2);
}

.settings-btn.danger:hover {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.4);
}

.settings-btn.danger svg {
  fill: #fca5a5;
}

/* App badge styling */
.badge {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.badge-success {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.badge-danger {
  background-color: var(--color-danger-bg);
  color: #ef4444;
}

.badge-warning {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
}

/* Toast Notification */
.toast-msg {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #ffc107;
  color: #000000;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  z-index: 300;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28), opacity 0.25s, visibility 0.25s;
  pointer-events: none;
  white-space: nowrap;
}

.toast-msg.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  visibility: visible;
}
