/* National Broadband ISP Portal CSS - With Nastaleeq Typography */
:root {
  --primary: #01652f;
  --primary-hover: #004d23;
  --primary-light: #e6f4ea;
  --accent: #10b981;
  --accent-light: #d1fae5;
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-700: #334155;
  --slate-600: #475569;
  --slate-500: #64748b;
  --slate-400: #94a3b8;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --sidebar-w: 260px;
  --header-h: 68px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  background-color: var(--slate-100);
  color: var(--slate-800);
  line-height: 1.5;
  font-size: 14px;
  display: flex;
  min-height: 100vh;
}

/* AUTHENTIC URDU NASTALEEQ APPLIED TO ENTIRE WEBSITE WHEN RTL */
body[dir="rtl"],
body[dir="rtl"] input,
body[dir="rtl"] select,
body[dir="rtl"] textarea,
body[dir="rtl"] button,
body[dir="rtl"] table,
body[dir="rtl"] th,
body[dir="rtl"] td,
body[dir="rtl"] h1,
body[dir="rtl"] h2,
body[dir="rtl"] h3,
body[dir="rtl"] h4,
body[dir="rtl"] h5,
body[dir="rtl"] h6,
body[dir="rtl"] .nav-link,
body[dir="rtl"] .form-label,
body[dir="rtl"] .page-title,
body[dir="rtl"] .metric-label,
body[dir="rtl"] .badge,
.urdu-text,
.urdu-input {
  font-family: 'Noto Nastaliq Urdu', 'Gulzar', serif !important;
  line-height: 1.85 !important;
  letter-spacing: 0 !important;
  text-align: right;
}

body[dir="rtl"] .data-table th,
body[dir="rtl"] .data-table td {
  text-align: right;
  line-height: 2 !important;
}

body[dir="rtl"] .brand-text h2,
body[dir="rtl"] .brand-text p {
  line-height: 1.7 !important;
}

/* Layout */
.app-container {
  display: flex;
  width: 100%;
}

.app-sidebar {
  width: var(--sidebar-w);
  background-color: #ffffff;
  border-inline-end: 1px solid var(--slate-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  z-index: 40;
  transition: transform 0.25s ease;
}

.app-main {
  flex: 1;
  margin-inline-start: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

/* Top Header */
.app-header {
  height: var(--header-h);
  background: #ffffff;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.brand-wrapper {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--slate-200);
  height: 68px;
}

.brand-logo-img {
  height: 42px;
  width: auto;
  object-fit: contain;
}

/* Nav Menu */
.sidebar-menu {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--slate-600);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 4px;
  transition: all 0.15s ease;
}

.nav-link:hover {
  background-color: var(--slate-100);
  color: var(--primary);
}

.nav-link.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Page Content */
.page-content {
  padding: 24px;
  flex: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 14px;
}

.page-title {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--slate-900);
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--slate-500);
  margin-top: 2px;
}

/* Metric Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.metric-card {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
}

.metric-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-500);
  margin-bottom: 6px;
}

.metric-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--slate-900);
  line-height: 1.1;
}

.metric-icon-box {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.icon-green { background: var(--primary-light); color: var(--primary); }
.icon-blue { background: #e0f2fe; color: #0284c7; }
.icon-amber { background: var(--warning-light); color: var(--warning); }
.icon-red { background: var(--danger-light); color: var(--danger); }

/* Table Container & Filter */
.card-table-wrap {
  background: #ffffff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.card-header-bar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.filter-bar {
  padding: 16px 20px;
  background: var(--slate-50);
  border-bottom: 1px solid var(--slate-200);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input-wrap {
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-input-wrap input {
  width: 100%;
  padding: 9px 14px;
  padding-inline-start: 36px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  background: #ffffff;
}

.search-icon-pos {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-start: 12px;
  color: var(--slate-400);
  pointer-events: none;
}

.filter-select {
  padding: 9px 14px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  background: #ffffff;
  color: var(--slate-700);
}

/* Real-Time AJAX Loading pulse */
.ajax-loading {
  opacity: 0.55;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* Tables */
.data-table-scroll {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background-color: var(--slate-50);
  padding: 12px 16px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--slate-500);
  border-bottom: 1px solid var(--slate-200);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--slate-200);
  vertical-align: middle;
  font-size: 0.9rem;
}

.data-table tr:hover td {
  background-color: #fafbfc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-active { background: var(--accent-light); color: #065f46; }
.badge-suspended { background: var(--warning-light); color: #92400e; }
.badge-inactive { background: var(--slate-200); color: var(--slate-600); }
.badge-paid { background: #dcfce7; color: #15803d; }
.badge-unpaid { background: #fee2e2; color: #b91c1c; }
.badge-overdue { background: #ffe4e6; color: #9f1239; border: 1px solid #fecdd3; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: all 0.15s ease;
  min-height: 40px;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: #ffffff;
  border-color: var(--slate-200);
  color: var(--slate-700);
}

.btn-secondary:hover {
  background-color: var(--slate-100);
  border-color: var(--slate-400);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  min-height: 32px;
  border-radius: var(--radius-sm);
}

.btn-accent {
  background-color: var(--accent);
  color: #ffffff;
}

.btn-accent:hover {
  background-color: #059669;
}

/* Forms */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--slate-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  color: var(--slate-800);
  background-color: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1, 101, 47, 0.15);
}

.input-with-action {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-with-action .form-control {
  flex: 1;
}

.btn-kb-toggle {
  background: var(--slate-100);
  border: 1px solid var(--slate-200);
  color: var(--primary);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 42px;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-kb-toggle:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

/* Urdu Keyboard Floating Modal */
.urdu-keyboard-modal {
  display: none;
  position: fixed;
  bottom: 16px;
  inset-inline: 16px;
  max-width: 760px;
  margin: 0 auto;
  background: #ffffff;
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  padding: 14px;
}

.urdu-keyboard-modal.active {
  display: block;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.ukb-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--slate-200);
}

.ukb-keys-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 6px;
  direction: rtl;
}

.ukb-key {
  height: 38px;
  border: 1px solid var(--slate-200);
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  font-family: 'Noto Nastaliq Urdu', 'Gulzar', serif !important;
  font-size: 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s ease;
  user-select: none;
}

.ukb-key:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.ukb-key:active {
  background: var(--primary);
  color: #ffffff;
}

.ukb-key-action {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
}

/* Mobile responsive */
@media (max-width: 900px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  body[dir="rtl"] .app-sidebar {
    transform: translateX(100%);
  }
  .app-sidebar.show {
    transform: translateX(0) !important;
  }
  .app-main {
    margin-inline-start: 0;
  }
}
