/* ============================================
   Radharaman Enterprise - Modern Admin Panel
   Premium Design with Sidebar Layout
   ============================================ */

/* ============================================
   CSS Variables - Design Tokens
   ============================================ */
:root {
  /* Primary Colors - Indigo/Slate theme */
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-200: #c7d2fe;
  --primary-300: #a5b4fc;
  --primary-400: #818cf8;
  --primary-500: #6366f1;
  --primary-600: #4f46e5;
  --primary-700: #4338ca;
  --primary-800: #3730a3;
  --primary-900: #312e81;

  /* Sidebar Colors */
  --sidebar-bg: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.08);
  --sidebar-active-bg: rgba(99, 102, 241, 0.2);
  --sidebar-border: rgba(255, 255, 255, 0.08);

  /* Status Colors */
  --success-50: #f0fdf4;
  --success-500: #22c55e;
  --success-600: #16a34a;
  --danger-50: #fef2f2;
  --danger-500: #ef4444;
  --danger-600: #dc2626;
  --warning-50: #fffbeb;
  --warning-500: #f59e0b;
  --warning-600: #d97706;
  --info-50: #eff6ff;
  --info-500: #3b82f6;
  --info-600: #2563eb;

  /* Neutral Colors */
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  /* Border Radius */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;

  /* Mobile */
  --mobile-header-height: 56px;
  --mobile-bottom-nav-height: 64px;
}

/* ============================================
   Base Styles
   ============================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--gray-900);
  background: var(--gray-100);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Admin Layout with Sidebar */
body.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   Sidebar Styles
   ============================================ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-slow);
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--sidebar-text-active);
  text-decoration: none;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.sidebar-brand i {
  font-size: 1.5rem;
  color: var(--primary-400);
}

.sidebar-close {
  display: none;
  color: var(--sidebar-text);
  padding: 0.5rem;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.sidebar-nav .nav {
  padding: 0 0.75rem;
}

.sidebar-nav .nav-item {
  margin-bottom: 0.25rem;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  transition: all var(--transition);
}

.sidebar-nav .nav-link i {
  width: 1.25rem;
  text-align: center;
  font-size: 1rem;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
}

.sidebar-nav .nav-link.active i {
  color: var(--primary-400);
}

.nav-section {
  padding: 1.25rem 1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sidebar-text);
  opacity: 0.6;
}

.sidebar-footer {
  padding: 1rem 1rem;
  border-top: 1px solid var(--sidebar-border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
}

.user-avatar {
  font-size: 2rem;
  color: var(--sidebar-text);
}

.user-details {
  display: flex;
  flex-direction: column;
}

.user-name {
  color: var(--sidebar-text-active);
  font-weight: 600;
  font-size: 0.875rem;
}

.user-role {
  color: var(--sidebar-text);
  font-size: 0.75rem;
  opacity: 0.8;
}

.btn-logout {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-logout:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
}

/* ============================================
   Main Content Area
   ============================================ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  padding: 1.5rem 2rem;
  transition: margin-left var(--transition-slow);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.025em;
}

.page-subtitle {
  color: var(--gray-500);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* ============================================
   Card Styles - Glassmorphism
   ============================================ */
.card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1rem 1.25rem;
  background: transparent;
  border-bottom: 1px solid var(--gray-200);
  font-weight: 600;
  color: var(--gray-900);
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 1rem 1.25rem;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* KPI Cards */
.kpi-card {
  position: relative;
  overflow: hidden;
}

.kpi-card .card-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
}

.kpi-content h3 {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.25rem;
}

.kpi-content p {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin: 0;
}

.kpi-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.kpi-icon.primary {
  background: var(--primary-100);
  color: var(--primary-600);
}

.kpi-icon.success {
  background: var(--success-50);
  color: var(--success-600);
}

.kpi-icon.warning {
  background: var(--warning-50);
  color: var(--warning-600);
}

.kpi-icon.danger {
  background: var(--danger-50);
  color: var(--danger-600);
}

.kpi-icon.info {
  background: var(--info-50);
  color: var(--info-600);
}

/* ============================================
   Button Styles
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn i {
  font-size: 0.875rem;
}

.btn-primary {
  background: var(--primary-600);
  color: white;
  border-color: var(--primary-600);
}

.btn-primary:hover {
  background: var(--primary-700);
  border-color: var(--primary-700);
  color: white;
}

.btn-success {
  background: var(--success-600);
  color: white;
  border-color: var(--success-600);
}

.btn-success:hover {
  background: #15803d;
  border-color: #15803d;
  color: white;
}

.btn-danger {
  background: var(--danger-600);
  color: white;
  border-color: var(--danger-600);
}

.btn-danger:hover {
  background: #b91c1c;
  border-color: #b91c1c;
  color: white;
}

.btn-warning {
  background: var(--warning-600);
  color: white;
  border-color: var(--warning-600);
}

.btn-outline-primary {
  background: transparent;
  color: var(--primary-600);
  border-color: var(--primary-600);
}

.btn-outline-primary:hover {
  background: var(--primary-600);
  color: white;
}

.btn-outline-secondary {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-300);
}

.btn-outline-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--gray-700);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger-600);
  border-color: var(--danger-600);
}

.btn-outline-danger:hover {
  background: var(--danger-600);
  color: white;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

.btn-lg {
  padding: 0.875rem 1.75rem;
  font-size: 1rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
}

.btn-icon.btn-sm {
  width: 32px;
  height: 32px;
}

/* ============================================
   Table Styles
   ============================================ */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.table thead th {
  background: var(--gray-50);
  padding: 0.875rem 1rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-600);
  border-bottom: 2px solid var(--gray-200);
  text-align: left;
}

.table tbody td {
  padding: 1rem;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-700);
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background: var(--gray-50);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-responsive {
  min-height: 50vh;
}

/* ============================================
   Badge Styles
   ============================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
  letter-spacing: 0.025em;
}

.badge-success, .bg-success {
  background: var(--success-50) !important;
  color: var(--success-600) !important;
}

.badge-warning, .bg-warning {
  background: var(--warning-50) !important;
  color: var(--warning-600) !important;
}

.badge-danger, .bg-danger {
  background: var(--danger-50) !important;
  color: var(--danger-600) !important;
}

.badge-info, .bg-info {
  background: var(--info-50) !important;
  color: var(--info-600) !important;
}

.badge-primary, .bg-primary {
  background: var(--primary-100) !important;
  color: var(--primary-700) !important;
}

/* Credit/Debit badges */
.badge-credit {
  background: #fef2f2;
  color: #dc2626;
}

.badge-debit {
  background: #f0fdf4;
  color: #16a34a;
}

/* ============================================
   Form Styles
   ============================================ */
.form-control,
.form-select {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--gray-900);
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  transition: all var(--transition);
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
}

.form-text {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-top: 0.375rem;
}

.input-group {
  display: flex;
  position: relative;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  color: var(--gray-600);
}

.input-group .form-control {
  border-radius: 0;
}

.input-group .form-control:first-child,
.input-group .input-group-text:first-child {
  border-radius: var(--radius) 0 0 var(--radius);
}

.input-group .form-control:last-child,
.input-group .input-group-text:last-child {
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* ============================================
   Modal Styles
   ============================================ */
.modal-content {
  border: none;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-title {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--gray-900);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ============================================
   Alert Styles
   ============================================ */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.alert-success {
  background: var(--success-50);
  border-color: #86efac;
  color: #166534;
}

.alert-danger {
  background: var(--danger-50);
  border-color: #fca5a5;
  color: #991b1b;
}

.alert-warning {
  background: var(--warning-50);
  border-color: #fcd34d;
  color: #92400e;
}

.alert-info {
  background: var(--info-50);
  border-color: #93c5fd;
  color: #1e40af;
}

/* ============================================
   Mobile Header
   ============================================ */
.mobile-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--mobile-header-height);
  background: var(--gray-800);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 999;
}

.mobile-brand {
  color: white;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.mobile-brand i {
  color: var(--primary-400);
}

.mobile-user a {
  color: var(--gray-400);
  padding: 0.5rem;
}

.mobile-user a:hover {
  color: white;
}

/* ============================================
   Mobile Bottom Navigation
   ============================================ */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mobile-bottom-nav-height);
  background: white;
  border-top: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 999;
  box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
}

.mobile-bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.5rem 0.75rem;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 0.625rem;
  font-weight: 500;
  transition: color var(--transition);
}

.mobile-bottom-nav .nav-item i {
  font-size: 1.25rem;
}

.mobile-bottom-nav .nav-item.active {
  color: var(--primary-600);
}

.mobile-bottom-nav .nav-item:hover {
  color: var(--primary-600);
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-slow);
}

.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 1rem;
    padding-top: calc(var(--mobile-header-height) + 1rem);
    padding-bottom: calc(var(--mobile-bottom-nav-height) + 1rem);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header .btn {
    width: 100%;
  }
}

@media (max-width: 575.98px) {
  .main-content {
    padding: 0.75rem;
    padding-top: calc(var(--mobile-header-height) + 0.75rem);
    padding-bottom: calc(var(--mobile-bottom-nav-height) + 0.75rem);
  }

  .card-body {
    padding: 1rem;
  }

  .kpi-card .card-body {
    padding: 1rem;
  }

  .kpi-content h3 {
    font-size: 1.5rem;
  }

  .kpi-icon {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }

  .table {
    font-size: 0.8125rem;
  }

  .table thead th,
  .table tbody td {
    padding: 0.75rem 0.5rem;
  }

  .btn {
    padding: 0.5rem 1rem;
  }

  .page-title {
    font-size: 1.5rem;
  }
}

/* ============================================
   Utility Classes
   ============================================ */
.text-muted {
  color: var(--gray-500) !important;
}

.text-success {
  color: var(--success-600) !important;
}

.text-danger {
  color: var(--danger-600) !important;
}

.text-warning {
  color: var(--warning-600) !important;
}

.text-primary {
  color: var(--primary-600) !important;
}

.fw-semibold {
  font-weight: 600;
}

.fw-bold {
  font-weight: 700;
}

/* ============================================
   Loading Spinner
   ============================================ */
.spinner-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.spinner-overlay.show {
  opacity: 1;
  visibility: visible;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary-600);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
  .sidebar,
  .mobile-header,
  .mobile-bottom-nav,
  .btn,
  .modal {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
    padding: 0;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}

/* ============================================
   Login Page Styles
   ============================================ */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-900) 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  margin: 1rem;
}

.login-card .card {
  border: none;
  box-shadow: var(--shadow-xl);
}

.login-card .card-body {
  padding: 2.5rem;
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo i {
  font-size: 3rem;
  color: var(--primary-500);
  margin-bottom: 1rem;
  display: block;
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 0.5rem;
}

.login-logo p {
  color: var(--gray-500);
  font-size: 0.875rem;
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-500);
}

.empty-state i {
  font-size: 3rem;
  color: var(--gray-300);
  margin-bottom: 1rem;
}

.empty-state h4 {
  font-size: 1.125rem;
  color: var(--gray-700);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.875rem;
  max-width: 300px;
  margin: 0 auto;
}

/* ============================================
   Ledger Specific Styles
   ============================================ */
.ledger-table .credit {
  color: var(--danger-600);
}

.ledger-table .debit {
  color: var(--success-600);
}

.balance-card {
  background: linear-gradient(135deg, var(--primary-600) 0%, var(--primary-700) 100%);
  color: white;
}

.balance-card .balance-label {
  font-size: 0.875rem;
  opacity: 0.9;
}

.balance-card .balance-amount {
  font-size: 2rem;
  font-weight: 700;
}

/* Uppercase input */
.uppercase-input {
  text-transform: uppercase;
}
