/*
 * Main Stylesheet
 * Account Management System
 */

/* ===== CSS Variables ===== */
:root {
  --primary:        #4F46E5;
  --primary-dark:   #4338CA;
  --primary-light:  #EEF2FF;
  --secondary:      #10B981;
  --danger:         #EF4444;
  --warning:        #F59E0B;
  --info:           #3B82F6;
  --dark:           #1E293B;
  --dark-soft:      #334155;
  --muted:          #64748B;
  --border:         #E2E8F0;
  --bg:             #F1F5F9;
  --surface:        #FFFFFF;
  --shadow-xs:      0 1px 2px rgba(0,0,0,0.05);
  --shadow-sm:      0 1px 4px rgba(0,0,0,0.07);
  --shadow:         0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.12);
  --radius-sm:      6px;
  --radius:         8px;
  --radius-lg:      12px;
  --transition:     all 0.2s ease;
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 0.9rem;       /* 13.5px effective */
  line-height: 1.65;
  color: var(--dark);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--dark);
  margin-bottom: 0.6rem;
}

h1 { font-size: 1.85rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.9rem; }

p {
  margin-bottom: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

a:hover { color: var(--primary-dark); }

small, .small { font-size: 0.82rem; }

/* ===== Layout ===== */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.container-sm  { max-width: 540px; }
.container-md  { max-width: 840px; }

.page-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  animation: pageFadeIn 0.25s ease;
}

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

/* ===== Card ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  padding: 1.25rem;
  margin-bottom: 1rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  animation: slideUp 0.3s ease-out;
}

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

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

.card-header {
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0;
}

.card-body  { padding: 0; }

.card-footer {
  border-top: 1px solid var(--border);
  padding-top: 0.85rem;
  margin-top: 0.85rem;
  font-size: 0.8rem;
}

/* ===== Form Styles ===== */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.845rem;
  font-weight: 600;
  color: var(--dark-soft);
  margin-bottom: 0.3rem;
  letter-spacing: 0.01em;
}

.form-label .required {
  color: var(--danger);
  margin-left: 2px;
}

.form-control,
.form-select {
  width: 100%;
  padding: 0.48rem 0.8rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--dark);
  background-color: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
  font-family: inherit;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control:disabled,
.form-select:disabled {
  background-color: #F8FAFC;
  cursor: not-allowed;
  opacity: 0.75;
}

.form-control.is-invalid { border-color: var(--danger); }
.form-control.is-valid   { border-color: var(--secondary); }

textarea.form-control { resize: vertical; min-height: 80px; }

.form-text,
.form-help {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.25rem;
  display: block;
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 0.25rem;
  display: none;
  animation: shake 0.3s ease-in-out;
}

.form-control.is-invalid + .form-error { display: block; }

.invalid-feedback {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 0.2rem;
}

.valid-feedback {
  font-size: 0.78rem;
  color: var(--secondary);
  margin-top: 0.2rem;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-4px); }
  75%       { transform: translateX(4px); }
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.46rem 1.1rem;
  font-size: 0.865rem;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.5;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary */
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79,70,229,0.35);
  transform: translateY(-1px);
}

/* Secondary */
.btn-secondary {
  background: #64748B;
  border-color: #64748B;
  color: #fff;
}
.btn-secondary:hover {
  background: #475569;
  border-color: #475569;
  color: #fff;
  transform: translateY(-1px);
}

/* Success */
.btn-success {
  background: var(--secondary);
  border-color: var(--secondary);
  color: #fff;
}
.btn-success:hover {
  background: #059669;
  border-color: #059669;
  color: #fff;
  transform: translateY(-1px);
}

/* Danger */
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #DC2626;
  border-color: #DC2626;
  color: #fff;
  transform: translateY(-1px);
}

/* Warning */
.btn-warning {
  background: var(--warning);
  border-color: var(--warning);
  color: #fff;
}
.btn-warning:hover {
  background: #D97706;
  border-color: #D97706;
  color: #fff;
  transform: translateY(-1px);
}

/* Info */
.btn-info {
  background: var(--info);
  border-color: var(--info);
  color: #fff;
}
.btn-info:hover {
  background: #2563EB;
  border-color: #2563EB;
  color: #fff;
  transform: translateY(-1px);
}

/* Outline variants */
.btn-outline-primary {
  background: transparent;
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-1px);
}

.btn-outline-secondary {
  background: transparent;
  border-color: #94A3B8;
  color: #64748B;
}
.btn-outline-secondary:hover {
  background: #F1F5F9;
  border-color: #64748B;
  color: var(--dark);
}

.btn-outline-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-outline-danger:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-1px);
}

.btn-outline-info {
  background: transparent;
  border-color: var(--info);
  color: var(--info);
}
.btn-outline-info:hover {
  background: var(--info);
  color: #fff;
  transform: translateY(-1px);
}

.btn-outline-success {
  background: transparent;
  border-color: var(--secondary);
  color: var(--secondary);
}
.btn-outline-success:hover {
  background: var(--secondary);
  color: #fff;
  transform: translateY(-1px);
}

/* Sizes */
.btn-lg {
  padding: 0.65rem 1.5rem;
  font-size: 0.95rem;
  border-radius: var(--radius);
}

.btn-sm {
  padding: 0.32rem 0.75rem;
  font-size: 0.78rem;
  border-radius: 5px;
}

.btn-xs {
  padding: 0.2rem 0.55rem;
  font-size: 0.72rem;
  border-radius: 4px;
}

.btn-block { width: 100%; display: flex; }

/* Loading spinner inside button */
.btn-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}
.btn-loading::after {
  content: '';
  position: absolute;
  width: 0.85rem;
  height: 0.85rem;
  top: 50%; left: 50%;
  margin: -0.425rem 0 0 -0.425rem;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.6rem;
  font-size: 0.73rem;
  font-weight: 600;
  border-radius: 20px;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

.badge-primary  { background: #EEF2FF; color: var(--primary); }
.badge-success  { background: #D1FAE5; color: #059669; }
.badge-danger   { background: #FEE2E2; color: var(--danger); }
.badge-warning  { background: #FEF3C7; color: #92400E; }
.badge-info     { background: #DBEAFE; color: #1D4ED8; }
.badge-secondary{ background: #F1F5F9; color: var(--muted); }
.badge-dark     { background: #1E293B; color: #fff; }

/* Bootstrap badge overrides */
.badge.bg-primary   { background-color: var(--primary)   !important; color: #fff; }
.badge.bg-success   { background-color: var(--secondary) !important; color: #fff; }
.badge.bg-danger    { background-color: var(--danger)    !important; color: #fff; }
.badge.bg-warning   { background-color: var(--warning)   !important; }
.badge.bg-info      { background-color: var(--info)      !important; color: #fff; }
.badge.bg-secondary { background-color: #64748B          !important; color: #fff; }

/* ===== Alerts ===== */
.alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.85rem;
  border: 1px solid transparent;
  border-left-width: 4px;
  font-size: 0.875rem;
  animation: slideDown 0.25s ease-out;
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert-success { background: #F0FDF4; border-color: var(--secondary); color: #166534; }
.alert-danger  { background: #FEF2F2; border-color: var(--danger);    color: #991B1B; }
.alert-warning { background: #FFFBEB; border-color: var(--warning);   color: #92400E; }
.alert-info    { background: #EFF6FF; border-color: var(--info);      color: #1E40AF; }

.alert .btn-close {
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.5;
  font-size: 0.7rem;
  padding: 0.1rem 0.3rem;
}
.alert .btn-close:hover { opacity: 0.85; }

/* ===== Tables ===== */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.865rem;
  background: var(--surface);
}

.table thead th {
  background: #F8FAFC;
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.7rem 0.9rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table tbody td {
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid #F1F5F9;
  color: var(--dark-soft);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: #FAFBFF; }

.table-striped tbody tr:nth-child(even) { background: #F8FAFC; }

.table-hover tbody tr { transition: background 0.12s ease; }

/* DataTables tweaks */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  font-size: 0.84rem;
  padding: 0.38rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(79,70,229,0.1);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  font-size: 0.82rem;
  margin-top: 0.6rem;
}
.dataTables_wrapper .paginate_button {
  font-size: 0.82rem !important;
  padding: 0.28rem 0.65rem !important;
  border-radius: var(--radius-sm) !important;
}

/* ===== Form Check / Switch ===== */
.form-check-label { font-size: 0.875rem; }
.form-check-input { width: 0.9em; height: 0.9em; }
.form-switch .form-check-input { width: 2.1em; height: 1.1em; }

/* ===== Bootstrap component overrides ===== */

/* Nav tabs */
.nav-tabs .nav-link {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
}

/* Dropdowns */
.dropdown-menu {
  font-size: 0.865rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius);
}

.dropdown-item {
  font-size: 0.865rem;
  padding: 0.42rem 1rem;
}

/* Modals */
.modal-title { font-size: 1rem; }
.modal-body  { font-size: 0.875rem; }
.modal-footer { padding: 0.75rem 1rem; }
.modal-header { padding: 0.9rem 1rem; }
.modal-content { border-radius: var(--radius-lg); border: none; box-shadow: var(--shadow-lg); }

/* Breadcrumb */
.breadcrumb { font-size: 0.82rem; margin-bottom: 0; }
.breadcrumb-item + .breadcrumb-item::before { font-size: 0.78rem; }

/* Input group */
.input-group-text { font-size: 0.875rem; }

/* Pagination */
.page-link { font-size: 0.84rem; padding: 0.35rem 0.7rem; }

/* ===== Loader ===== */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loader {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ===== Utility overrides ===== */
.text-muted { color: var(--muted) !important; font-size: 0.84rem; }
.text-sm    { font-size: 0.78rem; }
.text-xs    { font-size: 0.7rem; }
.fw-semibold { font-weight: 600; }

.shadow-sm  { box-shadow: var(--shadow-sm) !important; }
.shadow     { box-shadow: var(--shadow)    !important; }
.shadow-md  { box-shadow: var(--shadow-md) !important; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  html { font-size: 13px; }

  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.2rem; }
  h3 { font-size: 1.05rem; }

  .card { padding: 1rem; }

  .btn {
    padding: 0.38rem 0.85rem;
    font-size: 0.78rem;
  }
}

@media (max-width: 480px) {
  .btn-block-mobile { width: 100%; display: flex; }
}
