:root {
  --primary-color: #2563eb;
  --primary-light: #dbeafe;
  --secondary-color: #3b82f6;
  --dark: #1e293b;
  --gray: #64748b;
  --light-gray: #e2e8f0;
  --lighter-gray: #f1f5f9;
  --white: #ffffff;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

/* ===== CONTAINER ===== */
.ocm-frontend-wrapper {
  max-width: 100%;
  margin: 0 auto;
  padding: 20px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.ocm-org-chart-container {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 30px;
  box-shadow: var(--shadow);
  position: relative;
}

.ocm-chart-actions {
  position: relative;
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.ocm-chart-actions-left {
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.98);
  padding: 8px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.btn-fullscreen,
.btn-zoom-in,
.btn-zoom-out {
  background: #5b21b6;
  color: var(--white);
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(91, 33, 182, 0.3);
  white-space: nowrap;
  min-height: 38px;
}

.btn-fullscreen:hover,
.btn-zoom-in:hover,
.btn-zoom-out:hover {
  background: #6d28d9;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(91, 33, 182, 0.4);
}

.btn-fullscreen:disabled,
.btn-zoom-in:disabled,
.btn-zoom-out:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-zoom-in,
.btn-zoom-out {
  padding: 10px;
  min-width: 38px;
}

.btn-fullscreen svg,
.btn-zoom-in svg,
.btn-zoom-out svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Spinning animation for loading state */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Error message animations */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Fullscreen mode */
.ocm-fullscreen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.95);
  z-index: 999999;
  display: none;
  overflow: auto;
}

.ocm-fullscreen-overlay.active {
  display: block;
}

.ocm-fullscreen-content {
  background: var(--white);
  margin: 20px auto;
  padding: 40px;
  max-width: 95%;
  border-radius: var(--border-radius);
  position: relative;
}

.ocm-fullscreen-controls {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000000;
  display: flex;
  gap: 8px;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
}

.btn-close-fullscreen {
  background: #ef4444;
  color: var(--white);
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
  transition: var(--transition);
}

.btn-close-fullscreen:hover {
  background: #dc2626;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

#ocm-org-chart {
  min-height: 200px;
  transition: transform 0.3s ease;
  transform-origin: top center;
  overflow-x: auto;
  overflow-y: visible;
  padding-bottom: 20px;
}

/* ===== CHART SECTIONS ===== */
.org-chart-section {
  margin-bottom: 60px;
  max-width: 100%;
  overflow-x: auto;
}

/* Custom scrollbar styling */
#ocm-org-chart::-webkit-scrollbar,
.org-children-wrapper::-webkit-scrollbar {
  height: 8px;
}

#ocm-org-chart::-webkit-scrollbar-track,
.org-children-wrapper::-webkit-scrollbar-track {
  background: var(--lighter-gray);
  border-radius: 4px;
}

#ocm-org-chart::-webkit-scrollbar-thumb,
.org-children-wrapper::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

#ocm-org-chart::-webkit-scrollbar-thumb:hover,
.org-children-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-color);
}

.org-chart-section:last-child {
  margin-bottom: 0;
}

.chart-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--dark);
  margin: 0 0 10px 0;
  text-align: center;
}

.chart-description {
  font-size: 16px;
  color: var(--gray);
  text-align: center;
  margin: 0 0 40px 0;
  line-height: 1.6;
}

.chart-wrapper {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 30px;
  max-width: 100%;
  overflow-x: visible;
  min-width: min-content;
}

/* ===== ORGANIZATION TREE ===== */
.org-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  max-width: 100%;
  flex-shrink: 0;
  flex-grow: 0;
}

.employee-card {
  background: linear-gradient(135deg, var(--white) 0%, var(--lighter-gray) 100%);
  border: 2px solid var(--light-gray);
  border-radius: var(--border-radius);
  padding: 25px;
  text-align: center;
  width: auto;
  max-width: 280px;
  min-width: 250px;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  flex-grow: 0;
}

.employee-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-color);
}

.employee-info-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  background: var(--primary-color);
  color: var(--white);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
  z-index: 10;
}

.employee-info-badge:hover {
  background: var(--secondary-color);
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.5);
}

.employee-info-badge svg {
  width: 18px;
  height: 18px;
}

.employee-photo {
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--primary-color);
  box-shadow: var(--shadow);
}

.employee-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--transition);
}

.employee-card:hover .employee-photo img {
  transform: scale(1.1);
}

.employee-info {
  padding-top: 15px;
  border-top: 2px solid var(--light-gray);
  position: relative;
  z-index: 2;
}

.employee-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--dark);
  margin: 0 0 8px 0;
  line-height: 1.3;
  display: block;
  visibility: visible;
}

.employee-position {
  font-size: 14px;
  color: var(--gray);
  margin: 0 0 15px 0;
  line-height: 1.5;
  display: block;
  visibility: visible;
}

.btn-details {
  background: var(--primary-color);
  color: var(--white);
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
  width: 100%;
}

.btn-details:hover {
  background: var(--secondary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.3);
}

/* ===== CHILDREN NODES ===== */
.org-children {
  margin-top: 40px;
  position: relative;
}

.org-children::before {
  content: '';
  position: absolute;
  top: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 40px;
  background: var(--primary-color);
}

.org-children-wrapper {
  display: flex !important;
  flex-direction: row !important;
  justify-content: center;
  gap: 30px;
  flex-wrap: nowrap !important;
  position: relative;
  padding-top: 20px;
  overflow-x: auto;
  overflow-y: visible;
  min-width: 100%;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.org-children-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-color);
}

/* Hide horizontal line when there's only one child */
.org-children-wrapper:has(> .org-node:only-child)::before,
.org-children-wrapper.single-child::before {
  display: none;
}

.org-children-wrapper .org-node {
  position: relative;
}

.org-children-wrapper .org-node::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 20px;
  background: var(--primary-color);
  top: -20px;
}

/* ===== MODAL ===== */
.ocm-modal {
  display: none;
  position: fixed;
  z-index: 100000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.3s ease;
  overflow-y: auto;
}

.ocm-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ocm-modal-content {
  background: var(--white);
  padding: 0;
  border-radius: var(--border-radius);
  width: 100%;
  max-width: 600px;
  position: relative;
  animation: slideUp 0.3s ease;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

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

.ocm-close {
  position: absolute;
  right: 20px;
  top: 20px;
  color: var(--gray);
  font-size: 32px;
  font-weight: bold;
  cursor: pointer;
  transition: var(--transition);
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--white);
}

.ocm-close:hover {
  color: var(--dark);
  background: var(--lighter-gray);
}

/* ===== EMPLOYEE DETAILS ===== */
.employee-details {
  padding: 40px;
}

.employee-detail-header {
  display: flex;
  align-items: center;
  gap: 30px;
  margin-bottom: 30px;
  padding-bottom: 30px;
  border-bottom: 2px solid var(--light-gray);
}

.employee-detail-photo {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--primary-color);
  box-shadow: var(--shadow-lg);
  flex-shrink: 0;
}

.employee-detail-info h2 {
  font-size: 28px;
  color: var(--dark);
  margin: 0 0 10px 0;
  line-height: 1.2;
}

.detail-position {
  font-size: 18px;
  color: var(--primary-color);
  font-weight: 600;
  margin: 0;
}

.employee-detail-body {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.detail-item {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.detail-item.bio {
  flex-direction: column;
}

.detail-icon {
  width: 24px;
  height: 24px;
  color: var(--primary-color);
  flex-shrink: 0;
  margin-top: 2px;
}

.detail-item div {
  flex: 1;
}

.detail-item strong {
  display: block;
  color: var(--dark);
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-item a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 16px;
  transition: var(--transition);
}

.detail-item a:hover {
  color: var(--secondary-color);
  text-decoration: underline;
}

.detail-item p {
  margin: 0;
  color: var(--gray);
  line-height: 1.7;
  font-size: 15px;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray);
  font-size: 18px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  /* Keep horizontal layout on tablets, just make cards slightly smaller */
  .org-children-wrapper {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    padding-left: 10px;
    padding-right: 10px;
    gap: 25px;
  }

  .employee-card {
    max-width: 240px;
    min-width: 220px;
    flex-shrink: 0 !important;
  }
}

@media (max-width: 768px) {
  .ocm-frontend-wrapper {
    padding: 10px;
  }

  .ocm-org-chart-container {
    padding: 20px 15px;
  }

  .ocm-chart-actions {
    justify-content: center;
    margin-bottom: 15px;
  }

  .ocm-chart-actions-left {
    width: auto;
  }

  .btn-fullscreen {
    font-size: 12px;
    padding: 8px 12px;
    min-height: 36px;
  }

  .btn-zoom-in,
  .btn-zoom-out {
    padding: 8px;
    min-width: 36px;
  }

  .btn-fullscreen svg,
  .btn-zoom-in svg,
  .btn-zoom-out svg {
    width: 16px;
    height: 16px;
  }

  .ocm-fullscreen-controls {
    top: 10px;
    right: 10px;
    padding: 8px;
    gap: 6px;
  }

  .btn-close-fullscreen {
    padding: 8px 12px;
    font-size: 13px;
  }

  .chart-title {
    font-size: 24px;
  }

  .chart-description {
    font-size: 14px;
  }

  /* Keep cards horizontal - don't let them take full width */
  .employee-card {
    width: auto;
    max-width: 260px;
    min-width: 220px;
    padding: 20px;
    flex-shrink: 0 !important;
  }

  /* Ensure horizontal layout is maintained */
  .org-children-wrapper {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    gap: 20px;
  }

  .employee-photo {
    width: 100px;
    height: 100px;
  }

  .employee-name {
    font-size: 18px;
  }

  .employee-detail-header {
    flex-direction: column;
    text-align: center;
  }

  .employee-detail-photo {
    width: 120px;
    height: 120px;
  }

  .employee-detail-info h2 {
    font-size: 24px;
  }

  .detail-position {
    font-size: 16px;
  }

  .employee-details {
    padding: 30px 20px;
  }

  .org-children {
    margin-top: 30px;
  }

  .org-children::before {
    height: 30px;
    top: -30px;
  }

  #ocm-org-chart {
    padding: 10px;
    gap: 30px;
  }
}

@media (max-width: 480px) {
  .chart-title {
    font-size: 20px;
  }

  .employee-card {
    padding: 20px 15px;
    max-width: 220px;
    min-width: 200px;
    flex-shrink: 0 !important;
  }

  .org-children-wrapper {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: flex-start;
    gap: 20px;
  }

  .employee-photo {
    width: 80px;
    height: 80px;
  }

  .employee-name {
    font-size: 16px;
  }

  .employee-position {
    font-size: 13px;
  }

  .btn-details {
    font-size: 12px;
    padding: 8px 16px;
  }

  .ocm-modal-content {
    margin: 10px;
  }

  .employee-detail-photo {
    width: 100px;
    height: 100px;
  }

  .employee-detail-info h2 {
    font-size: 20px;
  }

  .detail-item {
    font-size: 14px;
  }

  #ocm-org-chart {
    padding: 5px;
    gap: 20px;
  }
}

/* Print Styles for PDF Generation */
@media print {
    body * {
        visibility: hidden;
    }
    
    .ocm-org-chart-container,
    .ocm-org-chart-container * {
        visibility: visible;
    }
    
    .ocm-org-chart-container {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    
    .ocm-chart-actions {
        display: none !important;
    }
    
    .btn-details,
    .employee-info-badge,
    .modal-overlay,
    .employee-modal {
        display: none !important;
    }
    
    .employee-card {
        page-break-inside: avoid;
        break-inside: avoid;
    }
    
    .org-node {
        page-break-inside: avoid;
    }
    
    .org-chart {
        zoom: 0.75;
        padding: 20px;
    }
    
    @page {
        size: landscape;
        margin: 10mm;
    }
}

/* Animation for loading state */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}
