@import url("./tokens.css");

/*
  Process Optima product application layer.
  Use this file after tokens.css and styles.css for internal tools,
  dashboards, HRMS-like systems, admin panels, and dense workflow screens.
*/

.po-app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--color-text-body);
  background:
    radial-gradient(circle at top left, rgba(15, 87, 255, 0.08), transparent 30%),
    radial-gradient(circle at top right, rgba(255, 197, 41, 0.12), transparent 30%),
    var(--theme-page-background);
}

.po-app-main {
  flex: 1 0 auto;
  padding-bottom: var(--space-20);
}

.po-app-header {
  position: sticky;
  top: 0;
  z-index: 70;
  background: color-mix(in srgb, var(--theme-page-background) 90%, transparent);
  border-bottom: 1px solid var(--theme-border);
  backdrop-filter: blur(18px);
}

.po-app-header-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: var(--space-6);
  align-items: center;
  min-height: 78px;
}

.po-app-header-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-5);
  align-items: center;
  min-width: 0;
}

.po-app-logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-width: max-content;
}

.po-app-logo img {
  width: 160px;
  height: auto;
  display: block;
}

.po-app-nav {
  display: flex;
  align-items: center;
  gap: clamp(var(--space-3), 1vw + 8px, var(--space-5));
  min-width: 0;
  white-space: nowrap;
}

.po-app-nav a,
.po-app-nav-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  color: var(--color-text-strong);
  font-size: var(--text-sm);
  font-weight: 800;
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
}

.po-app-nav a[aria-current="page"],
.po-app-nav-trigger[aria-expanded="true"] {
  color: var(--theme-link);
}

.po-app-nav a[aria-current="page"]::after,
.po-app-nav-trigger[aria-expanded="true"]::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 2px;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--color-brand-blue-700), var(--color-brand-yellow-400));
  border-radius: var(--radius-full);
}

.po-app-nav-group {
  position: relative;
}

.po-app-nav-menu {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  min-width: 220px;
  display: none;
  gap: var(--space-1);
  padding: var(--space-3);
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
}

.po-app-nav-group:hover .po-app-nav-menu,
.po-app-nav-group:focus-within .po-app-nav-menu,
.po-app-nav-group.is-open .po-app-nav-menu {
  display: grid;
}

.po-app-nav-menu a {
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: 16px;
}

.po-app-nav-menu a:hover {
  background: var(--theme-surface-muted);
}

.po-app-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
  min-width: 0;
}

.po-locale-switch,
.po-user-pill,
.po-theme-toggle {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--theme-border);
  background: var(--theme-surface-muted);
  box-shadow: var(--shadow-sm);
}

.po-locale-switch {
  gap: var(--space-1);
  padding: 4px;
  border-radius: var(--radius-full);
}

.po-locale-link {
  min-width: 40px;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-soft);
  font-weight: 900;
  text-decoration: none;
  border-radius: var(--radius-full);
}

.po-locale-link.is-active {
  color: var(--color-text-inverse);
  background: linear-gradient(135deg, var(--color-brand-blue-700), var(--color-brand-blue-500));
}

.po-theme-toggle {
  width: 46px;
  height: 30px;
  padding: 3px;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.po-theme-toggle::before {
  content: "";
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-brand-blue-700), var(--color-brand-yellow-400));
  box-shadow: 0 8px 18px rgba(15, 87, 255, 0.25);
  transition: transform var(--duration-base) var(--ease-standard);
}

[data-theme="dark"] .po-theme-toggle::before {
  transform: translateX(16px);
}

.po-user-pill {
  gap: var(--space-2);
  max-width: 280px;
  min-height: 46px;
  padding: 6px 14px 6px 6px;
  color: var(--color-text-strong);
  font-size: var(--text-sm);
  font-weight: 800;
  border-radius: var(--radius-full);
}

.po-user-pill span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.po-avatar {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
  color: var(--color-text-inverse);
  font-size: var(--text-sm);
  font-weight: 900;
  background: linear-gradient(135deg, var(--color-brand-blue-700), var(--color-brand-orange-500));
  border-radius: 50%;
}

.po-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.po-app-nav-toggle {
  display: none;
  width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--theme-surface-muted);
  border: 1px solid var(--theme-border);
  border-radius: 18px;
  cursor: pointer;
}

.po-app-nav-toggle span,
.po-app-nav-toggle::before,
.po-app-nav-toggle::after {
  content: "";
  width: 20px;
  height: 2px;
  display: block;
  background: var(--color-text-strong);
  border-radius: var(--radius-full);
  transition: transform var(--duration-base) var(--ease-standard), opacity var(--duration-base) var(--ease-standard);
}

.po-app-nav-toggle {
  gap: 4px;
  flex-direction: column;
}

.po-app-nav-toggle.is-open span {
  opacity: 0;
}

.po-app-nav-toggle.is-open::before {
  transform: translateY(6px) rotate(45deg);
}

.po-app-nav-toggle.is-open::after {
  transform: translateY(-6px) rotate(-45deg);
}

.po-impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 90;
  display: block;
  padding: 10px var(--space-5);
  color: #2b1600;
  font-weight: 900;
  text-align: center;
  text-decoration: none;
  background: linear-gradient(135deg, #ffd35a, #ff8a3d);
  box-shadow: 0 12px 32px rgba(194, 91, 0, 0.2);
}

.po-page {
  padding-top: var(--space-10);
}

.po-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-8);
}

.po-page-title {
  margin: 0;
  color: var(--color-text-heading);
  font-family: var(--font-display);
  font-size: clamp(2.25rem, 5vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.06em;
}

.po-page-subtitle {
  max-width: 760px;
  margin: var(--space-4) 0 0;
  color: var(--color-text-soft);
  font-size: var(--text-lg);
}

.po-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

.po-card,
.po-panel,
.po-table-card,
.po-filter-card {
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-card-border);
  border-radius: 30px;
  box-shadow: var(--shadow-md);
}

.po-card,
.po-panel {
  padding: clamp(var(--space-6), 2vw, var(--space-8));
}

.po-card-soft {
  background:
    linear-gradient(135deg, rgba(15, 87, 255, 0.06), rgba(255, 197, 41, 0.06)),
    var(--theme-card-bg);
}

.po-section-title {
  margin: 0 0 var(--space-4);
  color: var(--color-text-heading);
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 2vw, 2rem);
  letter-spacing: -0.03em;
}

.po-section-copy {
  margin: 0 0 var(--space-6);
  color: var(--color-text-soft);
  font-size: var(--text-md);
}

.po-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.po-metric-card {
  min-height: 132px;
  display: grid;
  gap: var(--space-2);
  align-content: center;
  padding: var(--space-5);
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}

.po-metric-label,
.po-detail-label {
  color: var(--color-text-soft);
  font-size: var(--text-xs);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.po-metric-value {
  color: var(--color-text-heading);
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3.25rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.po-metric-note,
.po-detail-value {
  color: var(--color-text-soft);
  font-size: var(--text-sm);
}

.po-form-grid,
.po-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
}

.po-field {
  display: grid;
  gap: var(--space-2);
}

.po-field label {
  color: var(--color-text-strong);
  font-size: var(--text-sm);
  font-weight: 900;
}

.po-field-control {
  width: 100%;
  min-height: 54px;
  padding: 14px 18px;
  color: var(--color-text-strong);
  font: inherit;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 197, 41, 0.05)),
    var(--theme-canvas);
  border: 1px solid var(--theme-border);
  border-radius: 20px;
  box-shadow: 0 18px 44px rgba(14, 31, 66, 0.05);
}

.po-field-control:focus {
  border-color: rgba(15, 87, 255, 0.42);
  outline: 0;
  box-shadow: 0 0 0 6px rgba(15, 87, 255, 0.16);
}

.po-field-control::placeholder {
  color: var(--color-text-muted);
}

[data-theme="dark"] .po-field-control {
  background:
    linear-gradient(135deg, rgba(76, 138, 255, 0.07), rgba(255, 197, 41, 0.03)),
    var(--theme-card-bg);
}

.po-toggle-card {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--theme-surface-muted);
  border: 1px solid var(--theme-border);
  border-radius: 22px;
}

.po-switch {
  position: relative;
  width: 58px;
  height: 34px;
  flex: 0 0 auto;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-full);
}

.po-switch::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--color-brand-blue-700), var(--color-brand-yellow-400));
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.po-switch.is-on::before {
  transform: translateX(24px);
}

.po-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  min-height: 34px;
  padding: 7px 12px;
  color: var(--color-text-strong);
  font-size: var(--text-xs);
  font-weight: 900;
  line-height: 1;
  background: var(--theme-surface-muted);
  border-radius: var(--radius-full);
}

.po-badge::before {
  content: "";
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: currentColor;
  border-radius: 50%;
}

.po-badge-blue {
  color: var(--color-status-info-text);
  background: var(--color-status-info-bg);
}

.po-badge-green {
  color: var(--color-status-success-text);
  background: var(--color-status-success-bg);
}

.po-badge-amber {
  color: var(--color-status-warning-text);
  background: var(--color-status-warning-bg);
}

.po-badge-red {
  color: var(--color-status-danger-text);
  background: var(--color-status-danger-bg);
}

.po-badge-muted {
  color: var(--color-status-muted-text);
  background: var(--color-status-muted-bg);
}

.po-gauge-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-4);
}

.po-gauge-card {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
  background:
    linear-gradient(135deg, rgba(15, 87, 255, 0.06), rgba(255, 197, 41, 0.06)),
    var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
}

.po-gauge-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  color: var(--color-text-strong);
  font-weight: 900;
}

.po-gauge {
  display: flex;
  min-height: 14px;
  overflow: hidden;
  background: color-mix(in srgb, var(--theme-card-bg) 74%, #d7deea 26%);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-full);
}

.po-gauge-segment {
  flex: 0 0 var(--value, 0%);
  min-width: 0;
}

.po-gauge-used {
  background: linear-gradient(90deg, #2b72ff, #4a8dff);
}

.po-gauge-planned {
  background: linear-gradient(90deg, #f3b13d, #ffd06e);
}

.po-gauge-remaining {
  background: linear-gradient(90deg, #15b07b, #45d29d);
}

.po-gauge-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  color: var(--color-text-soft);
  font-size: var(--text-xs);
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.po-calendar-shell {
  width: min(100%, 1520px);
  margin-inline: auto;
}

.po-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.po-calendar-month {
  margin: 0;
  color: var(--color-text-heading);
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 3vw, 2.6rem);
  letter-spacing: -0.04em;
}

.po-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(130px, 1fr));
  gap: 10px;
}

.po-calendar-weekday {
  padding: 14px;
  color: var(--theme-link);
  font-weight: 900;
  text-align: center;
  background: rgba(15, 87, 255, 0.1);
  border-radius: 18px;
}

.po-calendar-day {
  min-height: 150px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 14px;
  background: var(--theme-card-bg);
  border: 1px solid var(--theme-border);
  border-radius: 18px;
}

.po-calendar-day.is-muted {
  color: var(--color-text-muted);
  background: color-mix(in srgb, var(--theme-card-bg) 82%, var(--theme-page-background) 18%);
}

.po-event-pill {
  display: block;
  overflow: hidden;
  padding: 8px 10px;
  color: #254175;
  font-size: 0.78rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: linear-gradient(135deg, #e7efff, #fff1d2);
  border: 1px solid rgba(15, 87, 255, 0.16);
  border-radius: 12px;
}

[data-theme="dark"] .po-event-pill {
  color: #dbe8ff;
  background: linear-gradient(135deg, rgba(15, 87, 255, 0.22), rgba(255, 197, 41, 0.12));
  border-color: rgba(124, 148, 196, 0.22);
}

.po-table-card {
  overflow: hidden;
}

.po-table {
  width: 100%;
  border-collapse: collapse;
}

.po-table th,
.po-table td {
  padding: 18px;
  text-align: left;
  border-bottom: 1px solid var(--theme-border);
}

.po-table th {
  color: var(--color-text-strong);
  font-size: var(--text-xs);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.po-table tr:last-child td {
  border-bottom: 0;
}

.po-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  padding: var(--space-5);
  color: var(--color-text-soft);
  text-align: center;
  background: color-mix(in srgb, var(--theme-card-bg) 72%, var(--theme-page-background) 28%);
  border: 1px dashed var(--theme-border);
  border-radius: 22px;
}

[data-theme="dark"] .po-empty-state {
  background: rgba(76, 138, 255, 0.08);
  border-color: rgba(124, 148, 196, 0.2);
}

.po-footer-minimal {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 72px;
  color: var(--color-text-soft);
  font-size: var(--text-sm);
  border-top: 1px solid var(--theme-border);
}

@media (max-width: 1180px) {
  .po-app-header-row {
    grid-template-columns: auto auto;
    justify-content: space-between;
  }

  .po-app-nav-toggle {
    display: inline-flex;
  }

  .po-app-header-panel {
    position: fixed;
    inset: 78px 12px auto;
    z-index: 80;
    display: none;
    grid-template-columns: 1fr;
    padding: var(--space-5);
    background: color-mix(in srgb, var(--theme-card-bg) 92%, transparent);
    border: 1px solid var(--theme-border);
    border-radius: 28px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(18px);
  }

  .po-app-header-panel.is-open {
    display: grid;
  }

  .po-app-nav,
  .po-app-actions {
    align-items: stretch;
    justify-content: stretch;
    flex-direction: column;
    white-space: normal;
  }

  .po-app-nav a,
  .po-app-nav-trigger,
  .po-user-pill,
  .po-app-actions .button {
    width: 100%;
    justify-content: center;
  }

  .po-app-nav-menu {
    position: static;
    min-width: 0;
    box-shadow: none;
  }
}

@media (max-width: 860px) {
  .po-page {
    padding-top: var(--space-7);
  }

  .po-page-header,
  .po-calendar-header {
    flex-direction: column;
    align-items: stretch;
  }

  .po-toolbar {
    justify-content: stretch;
  }

  .po-toolbar .button {
    flex: 1 1 160px;
  }

  .po-metric-grid,
  .po-gauge-grid,
  .po-form-grid,
  .po-detail-grid {
    grid-template-columns: 1fr;
  }

  .po-calendar-grid {
    grid-template-columns: repeat(7, minmax(116px, 1fr));
    overflow-x: auto;
    padding-bottom: var(--space-2);
  }

  .po-table,
  .po-table tbody,
  .po-table tr,
  .po-table td {
    display: block;
  }

  .po-table thead {
    display: none;
  }

  .po-table tr {
    padding: var(--space-4);
    border-bottom: 1px solid var(--theme-border);
  }

  .po-table td {
    padding: var(--space-2) 0;
    border-bottom: 0;
  }

  .po-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    color: var(--color-text-soft);
    font-size: var(--text-xs);
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }
}
