/* ============================================================
   ISP Billing System — Global Stylesheet
   ============================================================ */

:root {
  --primary:       #00d4aa;
  --primary-dark:  #00b894;
  --primary-light: #e0faf5;
  --secondary:     #2d3748;
  --accent:        #6c63ff;
  --danger:        #e53e3e;
  --warning:       #dd6b20;
  --success:       #38a169;
  --info:          #3182ce;
  --bg:            #f0f4f8;
  --sidebar-bg:    #1a202c;
  --sidebar-text:  #a0aec0;
  --sidebar-hover: #2d3748;
  --card-bg:       #ffffff;
  --border:        #e2e8f0;
  --text:          #2d3748;
  --text-muted:    #718096;
  --shadow:        0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius:        8px;
  --radius-lg:     12px;
  --transition:    .2s ease;
  --sidebar-w:     260px;
  --header-h:      64px;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ─────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; color: var(--secondary); }
h1 { font-size: 1.8rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
h4 { font-size: 1rem; }
p  { color: var(--text-muted); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1.1rem; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary   { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #fff; }
.btn-secondary:hover { background: #1a202c; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c53030; }
.btn-warning   { background: var(--warning); color: #fff; }
.btn-success   { background: var(--success); color: #fff; }
.btn-info      { background: var(--info); color: #fff; }
.btn-outline   { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-outline-primary { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-light); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: .45rem; border-radius: var(--radius); }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg);
}
.card-header h3, .card-header h4 { margin: 0; }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem; border-top: 1px solid var(--border);
  background: #fafbfc;
}

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-card {
  background: var(--card-bg); border-radius: var(--radius-lg);
  padding: 1.25rem; box-shadow: var(--shadow); border: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 1rem;
  transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.green  { background: #e6fffa; color: var(--primary-dark); }
.stat-icon.blue   { background: #ebf8ff; color: var(--info); }
.stat-icon.orange { background: #fffaf0; color: var(--warning); }
.stat-icon.red    { background: #fff5f5; color: var(--danger); }
.stat-icon.purple { background: #f0ebff; color: var(--accent); }
.stat-info { flex: 1; }
.stat-label { font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.6rem; font-weight: 700; color: var(--secondary); line-height: 1.2; }
.stat-change { font-size: .78rem; margin-top: .2rem; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: .35rem; color: var(--secondary); }
.form-control {
  width: 100%; padding: .55rem .85rem; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: .875rem; color: var(--text);
  background: #fff; transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,212,170,.15); }
.form-control::placeholder { color: #b0bec5; }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: grid; gap: 1rem; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: .25rem; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: .25rem; }
.input-group { position: relative; display: flex; }
.input-group .form-control { flex: 1; }
.input-group-icon {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); pointer-events: none;
}
.input-group .form-control.has-icon { padding-left: 2.5rem; }
.input-group-append {
  display: flex; align-items: center; padding: 0 .75rem;
  background: var(--bg); border: 1px solid var(--border);
  border-left: none; border-radius: 0 var(--radius) var(--radius) 0;
  cursor: pointer; color: var(--text-muted);
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}
.table th {
  background: #f7fafc; color: var(--text-muted); font-weight: 600;
  font-size: .78rem; text-transform: uppercase; letter-spacing: .05em;
  padding: .65rem 1rem; border-bottom: 2px solid var(--border);
  text-align: left; white-space: nowrap;
}
.table td {
  padding: .75rem 1rem; border-bottom: 1px solid var(--border);
  vertical-align: middle; color: var(--text);
}
.table tbody tr:hover { background: #f7fafc; }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem; border-radius: 20px;
  font-size: .72rem; font-weight: 600; letter-spacing: .03em;
}
.badge-success  { background: #e6fffa; color: #00695c; }
.badge-danger   { background: #fff5f5; color: #c53030; }
.badge-warning  { background: #fffaf0; color: #c05621; }
.badge-info     { background: #ebf8ff; color: #2b6cb0; }
.badge-secondary{ background: #edf2f7; color: #4a5568; }
.badge-primary  { background: var(--primary-light); color: var(--primary-dark); }
.badge-purple   { background: #f0ebff; color: #553c9a; }
.badge::before  { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Sidebar Layout ──────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 100; transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-brand {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-brand .brand-logo {
  width: 36px; height: 36px; border-radius: var(--radius);
  background: var(--primary); display: flex; align-items: center;
  justify-content: center; font-size: 1.1rem; color: #fff; font-weight: 700;
}
.sidebar-brand .brand-name { font-size: 1rem; font-weight: 700; color: #fff; }
.sidebar-brand .brand-sub  { font-size: .7rem; color: var(--sidebar-text); }

.sidebar-section { padding: 1rem 0; }
.sidebar-section-title {
  padding: .4rem 1.5rem; font-size: .68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em; color: #4a5568;
}
.sidebar-nav { list-style: none; }
.sidebar-nav a {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1.5rem; color: var(--sidebar-text);
  font-size: .875rem; font-weight: 500; transition: all var(--transition);
  text-decoration: none; border-left: 3px solid transparent;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: var(--sidebar-hover); color: #fff;
  border-left-color: var(--primary);
}
.sidebar-nav a .nav-icon { width: 18px; text-align: center; }
.sidebar-nav a .nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: .65rem; padding: .1rem .4rem; border-radius: 10px;
}

.sidebar-footer {
  margin-top: auto; padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user { display: flex; align-items: center; gap: .75rem; }
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .875rem; flex-shrink: 0;
}
.sidebar-user .user-info .user-name { font-size: .875rem; font-weight: 600; color: #fff; }
.sidebar-user .user-info .user-role { font-size: .72rem; color: var(--sidebar-text); }

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w); flex: 1; display: flex;
  flex-direction: column; min-height: 100vh;
}

.topbar {
  height: var(--header-h); background: var(--card-bg);
  border-bottom: 1px solid var(--border); padding: 0 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1.1rem; font-weight: 600; color: var(--secondary); }
.topbar-breadcrumb { font-size: .8rem; color: var(--text-muted); }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.topbar-btn {
  width: 36px; height: 36px; border-radius: var(--radius);
  border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text-muted); transition: all var(--transition);
  position: relative;
}
.topbar-btn:hover { background: var(--bg); color: var(--text); }
.topbar-btn .notif-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 2px solid #fff;
}
.topbar-user {
  display: flex; align-items: center; gap: .5rem; cursor: pointer;
  padding: .3rem .6rem; border-radius: var(--radius);
  transition: background var(--transition);
}
.topbar-user:hover { background: var(--bg); }
.topbar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .8rem;
}
.topbar-user .user-name { font-size: .875rem; font-weight: 500; }

.page-content { padding: 1.5rem; flex: 1; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h2 { margin: 0; }

/* ── Grid Layouts ─────────────────────────────────────────── */
.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ── Modals ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 1rem; opacity: 0; pointer-events: none; transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  transform: scale(.95); transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }
.modal-header {
  padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { margin: 0; }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--radius);
  border: none; background: var(--bg); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; color: var(--text-muted); transition: all var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: .75rem;
}

/* ── Alerts / Toasts ─────────────────────────────────────── */
.alert {
  padding: .75rem 1rem; border-radius: var(--radius);
  display: flex; align-items: flex-start; gap: .75rem;
  font-size: .875rem; margin-bottom: 1rem;
}
.alert-success { background: #e6fffa; border: 1px solid #b2f5ea; color: #00695c; }
.alert-danger   { background: #fff5f5; border: 1px solid #fed7d7; color: #c53030; }
.alert-warning  { background: #fffaf0; border: 1px solid #feebc8; color: #c05621; }
.alert-info     { background: #ebf8ff; border: 1px solid #bee3f8; color: #2b6cb0; }

.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
  display: flex; flex-direction: column; gap: .5rem;
}
.toast {
  background: var(--secondary); color: #fff; padding: .75rem 1.25rem;
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  font-size: .875rem; display: flex; align-items: center; gap: .75rem;
  min-width: 260px; animation: slideIn .3s ease;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); gap: 0; margin-bottom: 1.25rem; }
.tab-btn {
  padding: .65rem 1.25rem; font-size: .875rem; font-weight: 500;
  color: var(--text-muted); cursor: pointer; border: none; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: .3rem;
  justify-content: flex-end; padding-top: 1rem;
}
.page-btn {
  width: 32px; height: 32px; border-radius: var(--radius);
  border: 1px solid var(--border); background: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: .8rem; color: var(--text-muted);
  transition: all var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn.disabled { opacity: .4; pointer-events: none; }

/* ── Search & Filter Bar ─────────────────────────────────── */
.filter-bar {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.search-box {
  position: relative; flex: 1; min-width: 200px;
}
.search-box input {
  width: 100%; padding: .5rem .85rem .5rem 2.5rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .875rem; outline: none; transition: border-color var(--transition);
}
.search-box input:focus { border-color: var(--primary); }
.search-box .search-icon {
  position: absolute; left: .75rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .9rem;
}

/* ── Dropdown ────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; top: calc(100% + .5rem); right: 0;
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  min-width: 180px; z-index: 200; overflow: hidden;
  opacity: 0; pointer-events: none; transform: translateY(-8px);
  transition: all var(--transition);
}
.dropdown-menu.open { opacity: 1; pointer-events: all; transform: translateY(0); }
.dropdown-item {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem 1rem; font-size: .875rem; color: var(--text);
  cursor: pointer; transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { border-top: 1px solid var(--border); margin: .25rem 0; }

/* ── Progress Bars ───────────────────────────────────────── */
.progress { background: var(--bg); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar {
  height: 100%; border-radius: 20px; background: var(--primary);
  transition: width .5s ease;
}
.progress-bar.danger  { background: var(--danger); }
.progress-bar.warning { background: var(--warning); }
.progress-bar.success { background: var(--success); }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .4; }
.empty-state h4 { color: var(--text-muted); font-weight: 500; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }

/* ── Utilities ───────────────────────────────────────────── */
.text-primary  { color: var(--primary-dark) !important; }
.text-success  { color: var(--success) !important; }
.text-danger   { color: var(--danger) !important; }
.text-warning  { color: var(--warning) !important; }
.text-info     { color: var(--info) !important; }
.text-muted    { color: var(--text-muted) !important; }
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.text-bold     { font-weight: 600; }
.text-sm       { font-size: .8rem; }
.text-xs       { font-size: .72rem; }
.d-flex        { display: flex; }
.align-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-0  { padding: 0 !important; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.flex-1 { flex: 1; }
.rounded { border-radius: var(--radius); }
.rounded-full { border-radius: 50%; }
.shadow { box-shadow: var(--shadow); }
.border { border: 1px solid var(--border); }
.bg-white { background: #fff; }
.cursor-pointer { cursor: pointer; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-260px); width: 260px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .filter-bar { flex-direction: column; }
  .search-box { width: 100%; }
}

/* ── Additional Utilities ────────────────────────────────── */
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 768px) {
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
}
.text-info { color: var(--info) !important; }
.badge-purple { background: #f0ebff; color: #553c9a; }
.badge-purple::before { background: #553c9a; }

/* Sidebar collapsed state */
.sidebar.collapsed { transform: translateX(-260px); }
@media (max-width: 768px) {
  .sidebar { transform: translateX(-260px); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* Form control small */
.form-control-sm { padding: .3rem .6rem; font-size: .8rem; }

/* Responsive table */
@media (max-width: 600px) {
  .table th, .table td { padding: .5rem .65rem; font-size: .8rem; }
}

/* Print styles */
@media print {
  .sidebar, .topbar, .btn, .filter-bar { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
