/* Workspace & Dashboard: High-end UI/UX matching prototype */

:root {
  --sidebar-w: 240px;
}

#dashboard {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
  background-color: var(--background);
}

/* Sidebar (Desktop) */
.workspace-sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  min-width: 0;
  z-index: 20;
}

.workspace-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 10px 24px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-symbol {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--grad-1-start), var(--grad-1-end));
  color: #FFFFFF;
  font-size: 1.25rem;
  box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.workspace-brand small {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0;
  margin-top: 1px;
}

.navigation {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  background: none;
  border: 0;
}

.nav-button {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  text-align: left;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.nav-button i {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
  color: inherit;
}

.nav-button:hover {
  background: var(--background);
  color: var(--text-main);
}

.nav-button.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.nav-button[data-view=notifications] {
  margin-top: 16px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 20px 14px 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: center;
}

/* Workspace Main Container */
.workspace-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 74px;
  padding: 14px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.user-info {
  min-width: 0;
}

.user-info h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.2;
}

.user-info p, #role-title {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-context {
  min-width: 0;
}

.mobile-brand {
  display: none;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  min-height: 42px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 1.05rem;
  transition: all 0.15s ease;
}

.icon-button:hover {
  background: var(--background);
  color: var(--text-main);
  border-color: #CBD5E1;
}

.account-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 6px;
  background: transparent;
  color: var(--text-main);
  border-radius: 50%;
  border: none;
  cursor: pointer;
}

.avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 700;
  border: 2px solid var(--primary-soft);
}

/* Notice Bar */
.notice {
  margin: 16px 28px 0;
  padding: 12px 18px;
  background: #FEF3C7;
  color: #92400E;
  border-radius: 12px;
  border: 1px solid #FDE68A;
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Workspace Area */
.workspace {
  width: 100%;
  max-width: 1100px;
  min-width: 0;
  flex: 1;
  margin: 0 auto;
  padding: 24px 28px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 20px;
}

.section-heading > div:first-child {
  flex: 1 1 240px;
  min-width: 0;
}

#section-title {
  margin: 0;
  color: var(--text-main);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

#section-title:focus {
  outline: none;
}

.intro {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

#section-intro:empty {
  display: none;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Stats Cards Grid */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 20px 18px;
  border-radius: 16px;
  color: #FFFFFF;
  box-shadow: 0 8px 20px -4px rgba(0, 0, 0, 0.12);
  transition: transform 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-card.gradient-1 {
  background: linear-gradient(135deg, var(--grad-1-start), var(--grad-1-end));
  box-shadow: 0 8px 24px -4px rgba(37, 99, 235, 0.35);
}

.stat-card.gradient-2 {
  background: linear-gradient(135deg, var(--grad-2-start), var(--grad-2-end));
  box-shadow: 0 8px 24px -4px rgba(16, 185, 129, 0.35);
}

.stat-card h3 {
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0.9;
  margin: 0 0 6px;
}

.stat-card .stat-value {
  font-size: 1.95rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* Quick Actions Grid */
.actions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.action-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.action-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.08);
}

.action-card:active {
  transform: scale(0.96);
}

.action-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.25rem;
  margin-bottom: 8px;
}

.action-card span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 20px 0 14px;
}

.section-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.section-header a {
  color: var(--primary);
  font-size: 0.88rem;
  font-weight: 600;
}

/* Card Lists & Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.record-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
}

.card {
  min-width: 0;
  margin: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  transition: all 0.15s ease;
}

.card:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.07);
  transform: translateY(-1px);
}

.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.trade-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 190px;
  min-width: 0;
}

.trade-heading > div {
  min-width: 0;
  flex: 1;
}

.trade-heading h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  line-height: 1.3;
}

/* Trade Pictogram in Colored Rounded Box */
.trade-symbol {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 12px;
  background: #3B82F6;
  color: #FFFFFF;
  font-size: 1.4rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.trade-symbol.sand { background: #F59E0B; }
.trade-symbol.gold { background: #EAB308; }
.trade-symbol.blue { background: #3B82F6; }
.trade-symbol.stone { background: #10B981; }
.trade-symbol.slate { background: #64748B; }
.trade-symbol.sage { background: #8B5CF6; }

.trade-symbol svg {
  width: 26px;
  height: 26px;
  display: block;
  fill: currentColor;
}

.record-subtitle {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

/* Card Schedule & Meta */
.job-schedule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 14px 0 10px;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.job-schedule i {
  color: var(--primary);
  font-size: 1rem;
}

.job-schedule small {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.job-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #F1F5F9;
}

.rate-line strong {
  color: var(--text-main);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.rate-line small {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 400;
}

.rate-line > span {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.card-actions button {
  min-height: 42px;
  padding: 8px 14px;
  font-size: 0.88rem;
  border-radius: 8px;
}

/* Record facts (details dl/dt/dd) */
.record-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 16px 0 0;
}

.record-facts dt {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.record-facts dd {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.record-facts dd small {
  display: block;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.record-extra {
  margin-top: 14px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.record-extra > summary {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
}

/* Search Row & Filters */
.search-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  margin-bottom: 20px;
}

.search-field {
  display: block;
  min-width: 0;
}

.search-field > span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.search-row input, .search-row select {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--surface);
  font-size: 0.95rem;
  width: 100%;
}

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.subnav button {
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
}

.subnav button.primary {
  background: var(--primary);
  color: #FFFFFF;
}

/* Mobile Bottom Navigation Bar */
.mobile-navigation {
  display: none;
}

/* Footer */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.8rem;
  background: var(--surface);
}

/* Responsive Breakpoints */
@media (max-width: 900px) {
  #dashboard {
    display: block;
    min-height: 100dvh;
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
  .workspace-sidebar {
    display: none;
  }
  .mobile-brand {
    display: block;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1.2;
  }
  .app-header {
    padding: 12px 18px;
  }
  .workspace {
    padding: 18px 16px;
  }
  .grid, .record-list {
    grid-template-columns: 1fr;
  }
  .record-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .actions-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
  }
  .action-icon {
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }
  .action-card span {
    font-size: 0.72rem;
  }

  /* Fixed bottom navigation bar */
  .mobile-navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -3px 12px rgba(0, 0, 0, 0.05);
  }

  .mobile-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex: 1;
    min-height: 48px;
    padding: 6px 2px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 500;
    background: none;
    border: none;
    transition: all 0.15s ease;
  }

  .mobile-tab i {
    font-size: 1.25rem;
    margin-bottom: 1px;
  }

  .mobile-tab.active {
    color: var(--primary);
    font-weight: 700;
  }

  .mobile-tab:active {
    transform: scale(0.92);
  }

  .toast {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 480px) {
  .actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .stats-grid {
    gap: 10px;
  }
  .stat-card {
    padding: 16px 12px;
  }
  .stat-card .stat-value {
    font-size: 1.6rem;
  }
  .search-row {
    grid-template-columns: 1fr;
  }
}
