/* ========================================================
   Sistem Informasi Kelompok Tani Karya Makmur
   Styles Modern UI + Dark/Light Theme
   ======================================================== */

:root {
  --primary-color: #198754;
  --primary-dark: #146c43;
  --primary-light: #d1e7dd;
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 78px;
  --topbar-height: 65px;
  --transition-speed: 0.3s;
  
  /* Light Mode Defaults */
  --bg-body: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-sidebar: #1e293b;
  --text-main: #212529;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

/* Dark Mode Theme */
[data-bs-theme="dark"] {
  --bg-body: #0f172a;
  --bg-surface: #1e293b;
  --bg-sidebar: #0f172a;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Layout Wrapper */
#wrapper {
  display: flex;
  width: 100%;
  align-items: stretch;
}

/* Sidebar Styles */
#sidebar {
  min-width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: #fff;
  transition: all var(--transition-speed) ease;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

#sidebar .sidebar-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  background: rgba(0, 0, 0, 0.15);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  color: #fff;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#sidebar .sidebar-brand i {
  font-size: 1.5rem;
  color: #20c997;
  margin-right: 0.75rem;
}

#sidebar .sidebar-menu {
  padding: 1rem 0.5rem;
  flex-grow: 1;
  overflow-y: auto;
}

#sidebar .menu-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748b;
  padding: 0.75rem 1rem 0.25rem;
  font-weight: 600;
}

#sidebar .nav-link {
  color: #cbd5e1;
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.25rem;
  font-weight: 500;
  transition: all 0.2s ease;
  text-decoration: none;
}

#sidebar .nav-link i {
  font-size: 1.2rem;
  margin-right: 0.85rem;
  width: 24px;
  text-align: center;
  color: #94a3b8;
}

#sidebar .nav-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

#sidebar .nav-link:hover i {
  color: #20c997;
}

#sidebar .nav-link.active {
  color: #fff;
  background: var(--primary-color);
}

#sidebar .nav-link.active i {
  color: #fff;
}

/* Sidebar Collapsed State */
#sidebar.collapsed {
  min-width: var(--sidebar-collapsed-width);
  max-width: var(--sidebar-collapsed-width);
}

#sidebar.collapsed .sidebar-brand span,
#sidebar.collapsed .menu-header,
#sidebar.collapsed .nav-link span {
  display: none;
}

#sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0.75rem 0;
}

#sidebar.collapsed .nav-link i {
  margin-right: 0;
}

/* Main Content Area */
#content-wrapper {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-speed) ease;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#sidebar.collapsed + #content-wrapper {
  margin-left: var(--sidebar-collapsed-width);
}

/* Top Navbar */
.top-navbar {
  height: var(--topbar-height);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

/* Card & Content UI */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
  transition: box-shadow 0.2s ease;
}

.card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 1.25rem;
  font-weight: 600;
}

.stat-card {
  border-left: 4px solid var(--primary-color);
  border-radius: 12px;
}

.stat-icon {
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 1.6rem;
}

/* Table Customization */
.table {
  color: var(--text-main);
  vertical-align: middle;
}

.table th {
  font-weight: 600;
  background-color: rgba(0, 0, 0, 0.02);
}

[data-bs-theme="dark"] .table th {
  background-color: rgba(255, 255, 255, 0.03);
}

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 1.25rem 1.5rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Responsive Mobile Layout */
@media (max-width: 991.98px) {
  #sidebar {
    margin-left: calc(-1 * var(--sidebar-width));
  }
  #sidebar.mobile-open {
    margin-left: 0;
  }
  #content-wrapper {
    margin-left: 0 !important;
  }
  .sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0,0,0,0.5);
    z-index: 1030;
  }
}