/* ==========================================================================
   Hisab - Design System & CSS Stylesheet
   Features: Glassmorphic Minimalist Design, Mobile-first, RTL/Urdu Nastaliq
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  
  --primary: #0f766e;        /* Deep Emerald Teal */
  --primary-hover: #115e59;
  --primary-light: #ccfbf1;
  --primary-text: #134e4a;
  
  --received-color: #059669; /* Emerald Green */
  --received-bg: #ecfdf5;
  --received-border: #a7f3d0;
  
  --given-color: #d97706;    /* Warm Amber */
  --given-bg: #fffbeb;
  --given-border: #fde68a;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;

  --border-color: #e2e8f0;
  --border-focus: #0f766e;
  
  /* Typography */
  --font-en: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-ur: 'Noto Nastaliq Urdu', 'Noto Sans Arabic', 'Segoe UI', Arial, sans-serif;
  --font-family: var(--font-en);
  
  /* Layout Spacing */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.07), 0 4px 6px -2px rgba(0,0,0,0.03);
  
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* RTL Specific Overrides */
html[dir="rtl"] {
  --font-family: var(--font-ur);
}

/* Reset & Core Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  font-size: 15px;
}

/* Nastaliq line-height adjustment for Urdu readability */
html[dir="rtl"] body {
  line-height: 1.9;
}

/* Header & Navigation */
.app-header {
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary), #14b8a6);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(15, 118, 110, 0.25);
}

.brand-text h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

html[dir="rtl"] .brand-text h1 {
  font-size: 1.45rem;
}

.brand-tagline {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Language Toggle Button */
.lang-btn {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--primary-text);
  padding: 0.55rem 1rem;
  border-radius: 30px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.lang-btn:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.lang-btn:active {
  transform: translateY(0);
}

/* Main Container */
.main-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem 1.25rem;
}

/* Welcome Banner */
.welcome-banner {
  background: linear-gradient(135deg, #0f766e, #115e59);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  flex-wrap: wrap;
  gap: 1rem;
}

.welcome-content h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
}

.welcome-content p {
  font-size: 0.92rem;
  opacity: 0.9;
  max-width: 650px;
}

.quick-stats-badge {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(4px);
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge-dot {
  width: 8px;
  height: 8px;
  background-color: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 8px #34d399;
}

/* Card Components */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-normal), box-shadow var(--transition-normal);
}

/* 1. Summary Section Cards */
.summary-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.summary-card {
  position: relative;
  overflow: hidden;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.card-icon {
  font-size: 1.25rem;
}

.card-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

html[dir="rtl"] .card-title {
  letter-spacing: 0;
  font-size: 0.95rem;
}

.card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

.card-subtext {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.card-received {
  border-top: 4px solid var(--received-color);
}
.card-received .card-value { color: var(--received-color); }

.card-given {
  border-top: 4px solid var(--given-color);
}
.card-given .card-value { color: var(--given-color); }

.card-net {
  border-top: 4px solid var(--primary);
}
.net-positive { color: var(--primary); }
.net-negative { color: #e11d48; }

/* Dashboard Grid (Form + Table) */
.dashboard-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 992px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Card Header Title Bar */
.card-title-bar {
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.card-title-bar h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: block;
}

/* 2. Quick Transaction Form Styles */
.form-group {
  margin-bottom: 1.1rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

@media (max-width: 480px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="number"],
select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.92rem;
  font-family: inherit;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background-color: var(--bg-main);
  color: var(--text-main);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
  background-color: #ffffff;
}

/* Segmented Control Radio Buttons */
.radio-segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background-color: var(--bg-card-subtle);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.radio-option {
  position: relative;
  margin-bottom: 0;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-btn {
  display: block;
  text-align: center;
  padding: 0.45rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  color: var(--text-muted);
  transition: all var(--transition-fast);
  user-select: none;
}

.radio-option input[type="radio"]:checked + .radio-received {
  background-color: var(--received-bg);
  color: var(--received-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--received-border);
}

.radio-option input[type="radio"]:checked + .radio-given {
  background-color: var(--given-bg);
  color: var(--given-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--given-border);
}

/* Form Submit Button */
.btn-submit {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), #115e59);
  color: #ffffff;
  border: none;
  padding: 0.8rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  font-family: inherit;
  margin-top: 0.5rem;
}

.btn-submit:hover {
  opacity: 0.95;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-submit:active {
  transform: translateY(0);
}

html[dir="rtl"] .btn-arrow {
  transform: rotate(180deg);
}

/* 3. Recent Activity Section */
.table-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.filter-pills {
  display: flex;
  gap: 0.35rem;
  background-color: var(--bg-card-subtle);
  padding: 3px;
  border-radius: 20px;
}

.pill-btn {
  border: none;
  background: transparent;
  padding: 0.3rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  border-radius: 15px;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.pill-btn.active {
  background-color: #ffffff;
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Activity Table Layout */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

html[dir="rtl"] .activity-table {
  text-align: right;
}

.activity-table th {
  padding: 0.75rem 0.85rem;
  background-color: var(--bg-card-subtle);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-color);
}

html[dir="rtl"] .activity-table th {
  letter-spacing: 0;
  font-size: 0.88rem;
}

.activity-table td {
  padding: 0.85rem 0.85rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.activity-table tbody tr {
  transition: background-color var(--transition-fast);
}

.activity-table tbody tr:hover {
  background-color: rgba(241, 245, 249, 0.6);
}

.text-end {
  text-align: right;
}

html[dir="rtl"] .text-end {
  text-align: left;
}

/* Type Badges */
.badge-type {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-received {
  background-color: var(--received-bg);
  color: var(--received-color);
  border: 1px solid var(--received-border);
}

.badge-given {
  background-color: var(--given-bg);
  color: var(--given-color);
  border: 1px solid var(--given-border);
}

.amount-received {
  color: var(--received-color);
  font-weight: 700;
}

.amount-given {
  color: var(--given-color);
  font-weight: 700;
}

/* Mobile Card View (Low Spec Optimization) */
.activity-mobile-list {
  display: none;
  flex-direction: column;
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .table-responsive {
    display: none;
  }
  .activity-mobile-list {
    display: flex;
  }
}

.mobile-item-card {
  background-color: var(--bg-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.mobile-item-info h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.mobile-item-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.mobile-item-val {
  text-align: right;
}

html[dir="rtl"] .mobile-item-val {
  text-align: left;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--border-color);
  background-color: #ffffff;
  padding: 1.25rem;
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: auto;
}
