/* ===============================================
   YCR Group HRM - Premium Frontend UI 2025
   =============================================== */

:root {
  --ycg-primary: #eb7838;
  --ycg-primary-dark: #b75e2c;
  --ycg-primary-light: #fcebe1;
  --ycg-bg: #FFFFFF;
  --ycg-bg-secondary: #F8F9FA;
  --ycg-text-primary: #1A1A1A;
  --ycg-text-secondary: #6B7280;
  --ycg-text-muted: #9CA3AF;
  --ycg-border: #E5E7EB;
  --ycg-success: #10B981;
  --ycg-success-light: #D1FAE5;
  --ycg-warning: #F59E0B;
  --ycg-warning-light: #FEF3C7;
  --ycg-danger: #EF4444;
  --ycg-danger-light: #FEE2E2;
  --ycg-radius: 12px;
  --ycg-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08);
  --ycg-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.10);
  --ycg-transition: all 0.3s ease;
}

/*
 * Icon utility classes for the frontend
 */
.ycg-icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  line-height: 1;
  vertical-align: text-bottom;
  margin-right: 0.25em;
  fill: currentColor;
}

.ycg-icon:last-child {
  margin-right: 0;
}

/* Dark mode overrides */
body.ycg-dark-mode {
  --ycg-bg: #1F2937;
  --ycg-bg-secondary: #111827;
  --ycg-text-primary: #F9FAFB;
  --ycg-text-secondary: #9CA3AF;
  --ycg-border: #374151;
  --ycg-primary: #eb7838;
  --ycg-primary-dark: #b75e2c;
  --ycg-primary-light: rgba(235, 120, 56, 0.25);
  --ycg-success: #34D399;
  --ycg-success-light: #065F46;
  --ycg-warning: #FBBF24;
  --ycg-warning-light: #92400E;
  --ycg-danger: #F87171;
  --ycg-danger-light: #7F1D1D;
}

/* Safer sizing (prevents mobile overflow from padding/long content) */
.ycg-hrm,
.ycg-hrm * {
  box-sizing: border-box;
}

/* Site brand (logo/title) */
.ycg-site-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  position: relative;
  z-index: 1;
}

.ycg-site-logo {
  display: block;
  height: 40px;
  width: auto;
  max-width: 100%;
}

.ycg-site-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1.2;
}

/* Dashboard Container */
.ycg-dashboard-wrapper {
  max-width: 1200px;
  margin: 40px auto;
  padding: 0 20px;
}

.ycg-dashboard-header {
  background: linear-gradient(135deg, var(--ycg-primary) 0%, var(--ycg-primary-dark) 100%);
  border-radius: var(--ycg-radius);
  padding: 40px;
  margin-bottom: 32px;
  color: white;
  box-shadow: var(--ycg-shadow-lg);
  position: relative;
  overflow: hidden;
}

.ycg-dashboard-header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 400px;
  height: 400px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  filter: blur(60px);
}

.ycg-dashboard-header h2 {
  margin: 0 0 8px 0;
  font-size: 32px;
  font-weight: 700;
  position: relative;
  z-index: 1;
}

.ycg-dashboard-header p {
  margin: 0;
  opacity: 0.9;
  font-size: 16px;
  position: relative;
  z-index: 1;
}

/* Form Styles */
.ycg-form {
  max-width: 600px;
  margin: 0 auto;
  background: var(--ycg-bg);
  padding: 32px;
  border-radius: var(--ycg-radius);
  box-shadow: var(--ycg-shadow);
  border: 1px solid var(--ycg-border);
}

.ycg-form h3 {
  margin: 0 0 24px 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--ycg-text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ycg-form h3::before {
  content: '';
  width: 4px;
  height: 28px;
  background: var(--ycg-primary);
  border-radius: 2px;
}

.ycg-field {
  margin-bottom: 20px;
}

.ycg-field label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--ycg-text-primary);
  font-size: 14px;
}

.ycg-field input,
.ycg-field textarea,
.ycg-field select {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--ycg-border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  transition: var(--ycg-transition);
  background: var(--ycg-bg);
}

.ycg-field input:focus,
.ycg-field textarea:focus,
.ycg-field select:focus {
  outline: none;
  border-color: var(--ycg-primary);
  box-shadow: 0 0 0 3px var(--ycg-primary-light);
}

.ycg-field textarea {
  resize: vertical;
  min-height: 100px;
}

/* Buttons */
.ycg-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: var(--ycg-transition);
  padding: 12px 20px;
}

.ycg-btn-primary {
  background: linear-gradient(135deg, var(--ycg-primary) 0%, var(--ycg-primary-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 78, 98, 0.3);
  width: 100%;
}

.ycg-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 78, 98, 0.4);
}

.ycg-btn[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

/* Messages */
.ycg-msg {
  padding: 12px 16px;
  border-radius: 8px;
  margin-top: 16px;
  font-weight: 500;
  animation: slideDown 0.25s ease;
  min-height: 0;
}

.ycg-msg[data-visible="0"] {
  padding: 0;
  margin-top: 0;
  border: 0;
  min-height: 0;
}

.ycg-msg.success {
  background: var(--ycg-success-light);
  color: var(--ycg-success);
  border-left: 4px solid var(--ycg-success);
}

.ycg-msg.error {
  background: var(--ycg-danger-light);
  color: var(--ycg-danger);
  border-left: 4px solid var(--ycg-danger);
}

/* Leave Summary Bars */
.ycg-leave-bar {
  margin-bottom: 12px;
}

.ycg-leave-bar .ycg-progress {
  width: 100%;
  height: 12px;
  background: #F3F4F6;
  border-radius: 8px;
  overflow: hidden;
}

.ycg-leave-bar .ycg-progress-fill {
  height: 100%;
  background: var(--ycg-primary);
  transition: width 0.4s ease;
}

/* Quick stats row */
.ycg-quick-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 20px 0;
}

.ycg-quick-stats span {
  display: block;
  background: var(--ycg-bg-secondary);
  border: 1px solid var(--ycg-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  color: var(--ycg-text-secondary);
  text-align: center;
}

/* Small inputs used in manager actions */
.ycg-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.ycg-input {
  border: 2px solid var(--ycg-border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: var(--ycg-bg);
  min-width: 120px;
}

.ycg-input:focus {
  outline: none;
  border-color: var(--ycg-primary);
  box-shadow: 0 0 0 3px var(--ycg-primary-light);
}

/* Table Styles */
.ycg-table-wrapper {
  background: var(--ycg-bg);
  border-radius: var(--ycg-radius);
  padding: 24px;
  box-shadow: var(--ycg-shadow);
  margin-top: 32px;
  border: 1px solid var(--ycg-border);
}

.ycg-table-wrapper h3 {
  margin: 0 0 20px 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--ycg-text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ycg-table-wrapper h3::before {
  content: '';
  width: 3px;
  height: 22px;
  background: var(--ycg-primary);
  border-radius: 2px;
}

.ycg-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--ycg-radius);
  overflow: hidden;
}

.ycg-table thead {
  background: var(--ycg-bg-secondary);
}

.ycg-table th {
  padding: 16px;
  text-align: left;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--ycg-text-secondary);
  border-bottom: 2px solid var(--ycg-border);
}

.ycg-table td {
  padding: 16px;
  border-bottom: 1px solid var(--ycg-border);
  color: var(--ycg-text-primary);
  font-size: 14px;
}

.ycg-table tbody tr {
  transition: var(--ycg-transition);
}

.ycg-table tbody tr:hover {
  background: var(--ycg-bg-secondary);
}

.ycg-table tbody tr:last-child td {
  border-bottom: none;
}

/* Status Badges */
.ycg-badge {
  padding: 6px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.ycg-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.ycg-badge.ycg-approve {
  background: var(--ycg-success-light);
  color: var(--ycg-success);
}

.ycg-badge.ycg-approve::before {
  background: var(--ycg-success);
}

.ycg-badge.ycg-reject {
  background: var(--ycg-danger-light);
  color: var(--ycg-danger);
}

.ycg-badge.ycg-reject::before {
  background: var(--ycg-danger);
}

.ycg-badge.ycg-pending {
  background: var(--ycg-warning-light);
  color: var(--ycg-warning);
}

.ycg-badge.ycg-pending::before {
  background: var(--ycg-warning);
}

/* Empty State */
.ycg-empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ycg-text-secondary);
}

.ycg-empty-state svg {
  width: 120px;
  height: 120px;
  margin-bottom: 20px;
  opacity: 0.5;
}

/* Animations */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .ycg-dashboard-header {
    padding: 24px;
  }

  .ycg-dashboard-header h2 {
    font-size: 24px;
  }

  .ycg-form {
    padding: 24px;
  }

  /* Reduce expensive blur paint on mobile */
  .ycg-dashboard-header::before {
    filter: none;
    opacity: 0.18;
  }

  .ycg-quick-stats {
    grid-template-columns: 1fr;
  }
}

/* Mobile stacked-table layout (no horizontal scroll, no cropped content)
   Enabled only for tables marked with data-stack="1".
*/
@media (max-width: 768px) {
  .ycg-table-wrapper {
    padding: 16px;
  }

  .ycg-table[data-stack="1"] {
    border: 0;
  }

  .ycg-table[data-stack="1"] thead {
    display: none;
  }

  .ycg-table[data-stack="1"],
  .ycg-table[data-stack="1"] tbody,
  .ycg-table[data-stack="1"] tr,
  .ycg-table[data-stack="1"] td {
    display: block;
    width: 100%;
  }

  .ycg-table[data-stack="1"] tbody tr {
    background: var(--ycg-bg);
    border: 1px solid var(--ycg-border);
    border-radius: 14px;
    margin-bottom: 12px;
    overflow: hidden;
  }

  .ycg-table[data-stack="1"] tbody tr:hover {
    background: var(--ycg-bg);
  }

  /* Label above, value below (prevents cramped/cropped right-side values) */
  .ycg-table[data-stack="1"] td {
    border-bottom: 1px solid var(--ycg-border);
    padding: 12px 14px;
    overflow-wrap: anywhere;
    word-break: normal;
  }

  .ycg-table[data-stack="1"] td::before {
    content: attr(data-label);
    display: block;
    font-weight: 800;
    color: var(--ycg-text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 0 0 6px 0;
  }

  .ycg-table[data-stack="1"] td:last-child {
    border-bottom: none;
  }

  /* Actions row (manager dashboard) */
  .ycg-table[data-stack="1"] .ycg-action-row {
    gap: 10px;
  }

  .ycg-table[data-stack="1"] .ycg-action-row .ycg-input {
    width: 100%;
    min-width: 0;
  }

  .ycg-table[data-stack="1"] .ycg-action-row .ycg-btn-primary {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/*
 * HRM Icon Styles
 * Provide base and size-specific classes for inline SVG icons used via ycg_hrm_icon(). Icons scale
 * using the defined size classes and align with surrounding text.
 */
.hrm-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  vertical-align: middle;
}

.hrm-icon svg {
  width: 100%;
  height: 100%;
}

.hrm-icon-sm {
  width: 16px;
  height: 16px;
}

.hrm-icon-md {
  width: 24px;
  height: 24px;
}

.hrm-icon-lg {
  width: 36px;
  height: 36px;
}

.hrm-icon-xl {
  width: 48px;
  height: 48px;
}

.hrm-icon-2xl {
  width: 64px;
  height: 64px;
}