/* OnePHP.PSA - Modern Styles (Matches OnePHP.CRM) */

:root {
  --font-main: "Inter", sans-serif;
  --sidebar-width: 280px;
  --bs-primary: #4f46e5; /* Indigo for PSA */
  --bs-primary-rgb: 79, 70, 229;

  /* BRAND COLORS */
  --brand-primary: #4f46e5;
  --brand-primary-dark: #4338ca;
  --brand-primary-light: #e0e7ff;
  --brand-secondary: #fecf5b;

  /* Light Mode Variables */
  --bg-body-light: linear-gradient(135deg, #f8f9fa 0%, #eef2ff 100%);
  --glass-bg-light: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(255, 255, 255, 0.6) 100%
  );
  --glass-border-light: rgba(79, 70, 229, 0.15);
  --text-main-light: #1a1a1a;
  --text-muted: #6c757d;

  /* Dark Mode Variables */
  --bg-body-dark: radial-gradient(
      circle at 0% 0%,
      rgba(79, 70, 229, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 100% 0%,
      rgba(79, 70, 229, 0.1) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 100% 100%,
      rgba(79, 70, 229, 0.15) 0%,
      transparent 50%
    ),
    radial-gradient(
      circle at 0% 100%,
      rgba(79, 70, 229, 0.1) 0%,
      transparent 50%
    ),
    #050505;
  --glass-bg-dark: linear-gradient(
      145deg,
      rgba(30, 30, 30, 0.8) 0%,
      rgba(10, 10, 10, 0.8) 100%
    ),
    linear-gradient(135deg, rgba(79, 70, 229, 0.08) 0%, transparent 100%);
  --glass-border-dark: rgba(255, 255, 255, 0.08);
  --text-main-dark: #e5e5e5;
  --card-glow: 0 8px 32px rgba(0, 0, 0, 0.4);

  /* Dynamic Theme Variables */
  --bg-body-current: var(
    --bg-body-light
  ); /* Default to Light for PSA initially */
  --glass-bg-current: var(--glass-bg-light);
  --text-main-current: var(--text-main-light);
}

[data-bs-theme="dark"] {
  --bg-body-current: var(--bg-body-dark);
  --glass-bg-current: var(--glass-bg-dark);
  --text-main-current: var(--text-main-dark);
}

body {
  font-family: var(--font-main);
  background: var(--bg-body-current);
  background-attachment: fixed;
  color: var(--text-main-current);
  transition: color 0.3s ease;
  overflow-x: hidden;
  min-height: 100vh;
}

/* Glassmorphism Classes */
.glass-panel,
.card {
  background: var(--glass-bg-current);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border-light);
  border-top: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 1rem;
  box-shadow: 0 20px 40px rgba(79, 70, 229, 0.15),
    0 5px 15px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

[data-bs-theme="dark"] .glass-panel,
[data-bs-theme="dark"] .card {
  border-color: var(--glass-border-dark);
  border-top-color: rgba(255, 255, 255, 0.15);
  box-shadow: var(--card-glow);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 25px 50px rgba(79, 70, 229, 0.25),
    0 10px 20px rgba(0, 0, 0, 0.1);
}

/* Card header with brand color */
.card-header {
  background: rgba(79, 70, 229, 0.05) !important;
  color: inherit !important;
  padding: 0.75rem 1rem !important;
  font-weight: 600;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  border-radius: 0;
}

.card-body {
  padding: 1rem;
}

/* Sidebar with Visual Flair */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1030;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  background: linear-gradient(180deg, #ffffff 0%, #f8f9fa 100%);
  border-right: 1px solid rgba(79, 70, 229, 0.1);
  box-shadow: 4px 0 20px rgba(79, 70, 229, 0.08);
  overflow-y: auto;
}

[data-bs-theme="dark"] .sidebar {
  background: linear-gradient(
      180deg,
      rgba(79, 70, 229, 0.05) 0%,
      transparent 100%
    ),
    var(--glass-bg-current);
  border-right: 1px solid rgba(79, 70, 229, 0.2);
  box-shadow: 4px 0 24px rgba(79, 70, 229, 0.1);
}

.sidebar-header {
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(79, 70, 229, 0.1);
}

.brand-logo {
  font-size: 1.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

[data-bs-theme="dark"] .brand-logo {
    background: linear-gradient(135deg, #ffffff 0%, #e0e7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 20px rgba(79, 70, 229, 0.5);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(
    135deg,
    var(--brand-primary) 0%,
    var(--brand-primary-dark) 100%
  );
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  margin-left: -0.6rem;
}

.sidebar .nav-link {
  color: #4b5563;
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  white-space: nowrap;
}

[data-bs-theme="dark"] .sidebar .nav-link {
    color: #b0b0b0;
    font-weight: 300;
}

.sidebar .nav-link i {
  width: 30px;
  margin-right: 0.75rem;
  font-size: 1rem;
  text-align: center;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-shrink: 0;
}

.sidebar .nav-link:hover {
  background: rgba(79, 70, 229, 0.08);
  color: var(--brand-primary);
  transform: translateX(4px);
}

[data-bs-theme="dark"] .sidebar .nav-link:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-link.active {
  background: linear-gradient(
    135deg,
    var(--brand-primary) 0%,
    var(--brand-primary-dark) 100%
  );
  color: white !important;
  box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 1.5rem 2rem;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* When sidebar is collapsed */
body.sidebar-collapsed .main-content {
    margin-left: 80px;
}

/* Collapsed Sidebar Styles */
body.sidebar-collapsed .sidebar {
    width: 80px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide text elements when collapsed */
body.sidebar-collapsed .sidebar .brand-logo,
body.sidebar-collapsed .sidebar .nav-link span,
body.sidebar-collapsed .sidebar .nav-link .fa-chevron-down,
body.sidebar-collapsed .sidebar-header .d-flex.justify-content-between > div:last-child {
    display: none !important;
}

/* Hide section headers when collapsed */
body.sidebar-collapsed .sidebar .section-header {
    display: none !important;
}

/* Show section headers on hover */
body.sidebar-collapsed .sidebar:hover .section-header {
    display: block !important;
}

/* Center sidebar header when collapsed */
body.sidebar-collapsed .sidebar .sidebar-header {
    padding: 1rem 0;
    display: flex;
    justify-content: center;
}

body.sidebar-collapsed .sidebar .brand-icon {
    margin: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Center nav links when collapsed */
body.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: 0.8rem 0;
}

body.sidebar-collapsed .sidebar .nav-link i {
    margin-right: 0 !important;
    font-size: 1.4rem;
    width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    opacity: 0.7;
    transition: all 0.2s;
}

/* Hide submenus in collapsed mode */
body.sidebar-collapsed .sidebar .collapse.show {
    display: none;
}

/* Expand on Hover */
body.sidebar-collapsed .sidebar:hover {
    width: var(--sidebar-width);
}

/* Show elements on hover */
body.sidebar-collapsed .sidebar:hover .brand-logo,
body.sidebar-collapsed .sidebar:hover .nav-link span,
body.sidebar-collapsed .sidebar:hover .nav-link .fa-chevron-down,
body.sidebar-collapsed .sidebar:hover .sidebar-header .d-flex.justify-content-between > div:last-child {
    display: block !important;
}

/* Show submenus when sidebar is hovered */
body.sidebar-collapsed .sidebar:hover .collapse.show {
    display: block !important;
}

/* Adjust header layout on hover */
body.sidebar-collapsed .sidebar:hover .sidebar-header {
    justify-content: space-between;
    padding-bottom: 1.5rem;
}

body.sidebar-collapsed .sidebar:hover .brand-icon {
    margin: 0;
    margin-left: -0.6rem;
}

/* Restore nav link layout on hover */
body.sidebar-collapsed .sidebar:hover .nav-link {
    justify-content: flex-start;
    padding: 0.8rem 1rem;
}

body.sidebar-collapsed .sidebar:hover .nav-link i {
    margin-right: 0.75rem !important;
    font-size: 1rem;
    width: 30px;
}

/* Active State in Collapsed Mode (Only Icon Highlighted usually, but here we simplify) */
body.sidebar-collapsed .sidebar .nav-link.active {
    background: transparent;
    box-shadow: none;
    border: none;
    color: var(--brand-primary) !important;
}

body.sidebar-collapsed .sidebar:hover .nav-link.active {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-primary-dark) 100%);
    color: white !important;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.4);
}

body.sidebar-collapsed .sidebar .nav-link:hover i,
body.sidebar-collapsed .sidebar .nav-link.active i {
    opacity: 1;
    transform: scale(1.1);
}


/* Sticky Header */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 1020;
  background: linear-gradient(
    145deg,
    rgba(79, 70, 229, 0.08) 0%,
    rgba(255, 255, 255, 0.9) 100%
  );
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(79, 70, 229, 0.15);
  padding: 1rem 2rem;
  margin: -1.5rem -2rem 1.5rem -2rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.05);
}

[data-bs-theme="dark"] .sticky-header {
    background: linear-gradient(145deg, rgba(79, 70, 229, 0.15) 0%, rgba(79, 70, 229, 0.05) 100%);
    border-bottom: 1px solid rgba(79, 70, 229, 0.2);
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.1);
}

/* Footer Styling & Sticky Footer Logic */
.content-footer {
  padding: 1rem 0;
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(0, 0, 0, 0.05);
}

[data-bs-theme="dark"] .content-footer {
    border-top-color: rgba(255, 255, 255, 0.05);
}

/* This makes the footer sticky */
.content-wrapper {
    flex: 1; 
}


/* Buttons */
.btn-primary {
  background: linear-gradient(
    135deg,
    var(--brand-primary) 0%,
    var(--brand-primary-dark) 100%
  );
  border: none;
  color: white;
  font-weight: 600;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* Theme Toggle */
.theme-toggle {
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border-dark);
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(15deg);
}

[data-bs-theme="light"] .theme-toggle {
    background: white;
    border-color: #e5e5e5;
}

[data-bs-theme="light"] .theme-toggle:hover {
    background: #f8f9fa;
}

/* Dropdown Styles */
.dropdown-menu {
    background: linear-gradient(145deg, #1e2229 0%, #0a0a0a 100%);
    border: 1px solid var(--glass-border-dark);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border-radius: 1rem;
    padding: 0.5rem;
    margin-top: 0.5rem !important;
}

[data-bs-theme="light"] .dropdown-menu {
    background: linear-gradient(145deg, #f0f7ff 0%, #ffffff 100%);
    border-color: var(--glass-border-light);
    box-shadow: 0 10px 30px rgba(79, 70, 229, 0.15);
}

.dropdown-item {
    color: var(--text-main-current);
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.dropdown-item:hover, .dropdown-item:focus {
    background: rgba(255, 255, 255, 0.1);
    color: var(--brand-primary);
    transform: translateX(4px);
}

[data-bs-theme="light"] .dropdown-item:hover, 
[data-bs-theme="light"] .dropdown-item:focus {
    background: rgba(79, 70, 229, 0.08);
}

.dropdown-divider {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 0.5rem 0;
}

[data-bs-theme="light"] .dropdown-divider {
    border-top-color: rgba(0, 0, 0, 0.05);
}

/* Mobile Responsive */
@media (max-width: 991px) {
    .sidebar,
    body.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 5px 0 25px rgba(0, 0, 0, 0.5);
    }

    .main-content,
    body.sidebar-collapsed .main-content {
        margin-left: 0 !important;
        padding: 1rem;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 1029;
        display: none;
    }

    .sidebar-overlay.show {
        display: block;
    }
}
