/* CSS Custom Properties for Theme Support */
:root {
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  
  /* Light Mode Variables */
  --bg-primary: #f4f6f9;
  --bg-secondary: #ffffff;
  --bg-sidebar: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --sidebar-active-bg: #334155;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --border-color: #e2e8f0;
  --accent-color: #0ea5e9;
  --accent-hover: #0284c7;
  --card-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.05), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --success-color: #10b981;
  --info-color: #3b82f6;
  
  --card-bg: #ffffff;
  --table-hover: #f8fafc;
  --modal-bg: #ffffff;
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
}

[data-theme="dark"] {
  /* Dark Mode Variables */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-sidebar: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active: #38bdf8;
  --sidebar-active-bg: #1e293b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --border-color: #334155;
  --accent-color: #38bdf8;
  --accent-hover: #0ea5e9;
  --card-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
  
  --card-bg: #1e293b;
  --table-hover: #334155;
  --modal-bg: #1e293b;
  --input-bg: #0f172a;
  --input-border: #475569;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  transition: background-color 0.3s, color 0.3s;
  overflow-x: hidden;
}

/* Sidebar Styling */
.sidebar {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: 260px;
  background-color: var(--bg-sidebar);
  color: var(--sidebar-text);
  z-index: 1000;
  transition: all 0.3s;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 700;
  font-size: 1.25rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-menu {
  list-style: none;
  padding: 1rem 0;
  margin: 0;
  flex-grow: 1;
  overflow-y: auto;
}

.sidebar-item a {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 0.95rem;
  gap: 12px;
}

.sidebar-item a:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-item.active a {
  color: var(--sidebar-active);
  background-color: var(--sidebar-active-bg);
  border-left: 4px solid var(--accent-color);
}

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
  text-align: center;
  color: #64748b;
}

/* Main Content Wrapper */
.main-wrapper {
  margin-left: 260px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s;
}

/* Top Navbar */
.top-navbar {
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 999;
}

.content-area {
  padding: 2rem;
  flex-grow: 1;
}

/* Cards & Layout */
.card-stat {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  padding: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card-stat:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px -5px rgb(0 0 0 / 0.1);
}

.custom-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  margin-bottom: 1.5rem;
}

.custom-card .card-header {
  background-color: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custom-card .card-body {
  padding: 1.5rem;
}

/* Tables styling */
.table-responsive {
  border-radius: 8px;
  overflow: hidden;
}

.table-custom {
  margin-bottom: 0;
  background-color: var(--bg-secondary);
}

.table-custom th {
  background-color: rgba(0, 0, 0, 0.02);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 2px solid var(--border-color);
  padding: 1rem;
}

[data-theme="dark"] .table-custom th {
  background-color: rgba(255, 255, 255, 0.02);
}

.table-custom td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

.table-custom tbody tr:hover {
  background-color: var(--table-hover);
}

/* Form Styling */
.form-control, .form-select {
  background-color: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
  background-color: var(--input-bg);
  color: var(--text-primary);
  border-color: var(--accent-color);
  box-shadow: 0 0 0 0.25rem rgba(14, 165, 233, 0.15);
}

/* Badge Styling */
.badge-custom {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35em 0.65em;
  border-radius: 4px;
}

/* Theme Switcher */
.theme-switch {
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.theme-switch:hover {
  background-color: var(--border-color);
}

/* Organogram CSS Tree Layout */
.organogram-container {
  overflow-x: auto;
  padding: 2rem 1rem;
  display: flex;
  justify-content: center;
}

.tree, .tree ul, .tree li {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
}

.tree {
  display: flex;
  justify-content: center;
}

.tree ul {
  display: flex;
  padding-top: 20px;
  position: relative;
  transition: all 0.5s;
}

.tree li {
  text-align: center;
  position: relative;
  padding: 20px 5px 0 5px;
  transition: all 0.5s;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* Connector Lines */
.tree li::before, .tree li::after {
  content: '';
  position: absolute;
  top: 0;
  right: 50%;
  border-top: 2px solid var(--border-color);
  width: 50%;
  height: 20px;
}

.tree li::after {
  right: auto;
  left: 50%;
  border-left: 2px solid var(--border-color);
}

/* Remove connectors for single child / boundary nodes */
.tree li:only-child::after, .tree li:only-child::before {
  display: none;
}

.tree li:only-child {
  padding-top: 0;
}

.tree li:first-child::before, .tree li:last-child::after {
  border: 0 none;
}

.tree li:last-child::before {
  border-right: 2px solid var(--border-color);
  border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
  border-radius: 5px 0 0 0;
}

/* Downward connectors from parent */
.tree ul::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  border-left: 2px solid var(--border-color);
  width: 0;
  height: 20px;
}

/* Card representation of Node */
.organogram-node {
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 8px;
  display: inline-block;
  box-shadow: var(--card-shadow);
  position: relative;
  z-index: 10;
  transition: all 0.3s;
  min-width: 160px;
}

.organogram-node:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px rgb(0 0 0 / 0.15);
  border-color: var(--accent-color);
}

.organogram-node .node-avatar {
  width: 45px;
  height: 45px;
  background-color: var(--border-color);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px auto;
  color: var(--accent-color);
  font-size: 1.25rem;
}

.organogram-node .node-name {
  font-weight: 700;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.organogram-node .node-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.organogram-node .node-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

/* Search panel and filter panel enhancements */
.filter-panel {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--card-shadow);
}

/* Modals background matching theme */
.modal-content {
  background-color: var(--modal-bg);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
}

.modal-header, .modal-footer {
  border-color: var(--border-color);
}

.modal-header .btn-close {
  filter: var(--close-btn-filter, none);
}

[data-theme="dark"] .modal-header .btn-close {
  --close-btn-filter: invert(1) grayscale(1) brightness(2);
}

/* Document Cards (Circulars, SOPs) */
.doc-card {
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  border-radius: 8px;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  transition: transform 0.2s;
  box-shadow: var(--card-shadow);
}

.doc-card:hover {
  transform: translateX(4px);
}

.doc-info {
  display: flex;
  align-items: center;
  gap: 15px;
}

.doc-icon {
  font-size: 2rem;
  color: var(--accent-color);
}

.doc-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.doc-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Responsiveness */
@media (max-width: 992px) {
  .sidebar {
    width: 70px;
  }
  
  .sidebar .sidebar-logo span {
    display: none;
  }
  
  .sidebar-logo {
    justify-content: center;
    padding: 1.5rem 0.5rem;
  }
  
  .sidebar-item a {
    justify-content: center;
    padding: 0.75rem;
  }
  
  .sidebar-item a span {
    display: none;
  }
  
  .sidebar-footer {
    display: none;
  }
  
  .main-wrapper {
    margin-left: 70px;
  }
}

@media (max-width: 576px) {
  .sidebar {
    left: -70px;
  }
  .sidebar.active {
    left: 0;
  }
  .main-wrapper {
    margin-left: 0;
  }
  .content-area {
    padding: 1rem;
  }
}

/* Login Page Premium Styles */
#login-container {
  background: radial-gradient(circle at 10% 20%, rgba(14, 165, 233, 0.08) 0%, rgba(15, 23, 42, 0.02) 50%, rgba(244, 246, 249, 1) 100%);
  transition: background 0.3s;
}

[data-theme="dark"] #login-container {
  background: radial-gradient(circle at 10% 20%, rgba(56, 189, 248, 0.12) 0%, rgba(15, 23, 42, 0.4) 60%, rgba(15, 23, 42, 1) 100%);
}

.login-card {
  width: 90%;
  max-width: 440px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  animation: loginCardFadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.login-logo {
  animation: pulseLogo 3s infinite ease-in-out;
}

@keyframes pulseLogo {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.demo-login-box {
  background-color: var(--bg-primary);
  border: 1px dashed var(--border-color);
  transition: background-color 0.3s;
}

.user-avatar-badge {
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  background: linear-gradient(135deg, #0ea5e9 0%, #2563eb 100%);
  transition: transform 0.2s;
}

.user-avatar-badge:hover {
  transform: scale(1.05);
}

#btn-logout {
  transition: all 0.2s;
}

#btn-logout:hover {
  background-color: var(--danger-color);
  color: #fff;
  border-color: var(--danger-color);
}

.cursor-pointer {
  cursor: pointer;
}

