/* Common utility classes */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  align-items: center;
}

.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.gap-10 {
  gap: 10px;
}

.gap-20 {
  gap: 20px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) var(--space-5);
  padding: var(--space-3) var(--space-5);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.header h1,
.page-title {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

/* Desktop header: logo left, page title centered, account data right */
.header-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 16px;
  width: 100%;
  min-width: 0;
}

.header-start {
  justify-self: start;
  min-width: 0;
}

.header-end {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.logo-container {
  width: auto;
  margin: 0;
}

.header-logo-link {
  display: inline-flex;
  align-items: center;
  line-height: 0;
  text-decoration: none;
  color: inherit;
}

.pulse-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  line-height: 1;
  color: var(--text-primary);
}

.pulse-logo__word {
  font-family: var(--font-sans);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  white-space: nowrap;
}

.pulse-logo__word--accent {
  color: var(--accent-color);
}

.pulse-logo__mark {
  width: 36px;
  height: 32px;
  flex: 0 0 auto;
  display: block;
  overflow: hidden;
}

.header-logo {
  height: 32px;
}

.page-title {
  grid-column: 2;
  margin: 0;
  text-align: center;
  white-space: nowrap;
}

/* User info icon and dropdown */
.user-info-container {
  width: 50px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.user-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-color);
  color: var(--text-on-inverted);
  font-weight: 600;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.user-icon:hover {
  background: var(--accent-color-hover);
}

.user-icon:active {
  transform: scale(0.98);
}

/* Common dropdown styles */
.dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 12px 15px;
  z-index: var(--z-dropdown);
}

.dropdown::before,
.dropdown::after {
  content: "";
  position: absolute;
}

.dropdown::before {
  top: -6px;
  right: 15px;
  width: 12px;
  height: 12px;
  background: var(--bg-secondary);
  transform: rotate(45deg);
  border-left: 1px solid var(--border-color);
  border-top: 1px solid var(--border-color);
}

.dropdown::after {
  top: -15px;
  left: 0;
  width: 100%;
  height: 15px;
}

/* User info specific styles */
.user-info.dropdown {
  min-width: 220px;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  font-size: 0.9rem;
}

.user-info-container:hover .user-info {
  display: flex;
}

.user-info div {
  font-size: 0.9rem;
  white-space: nowrap;
  padding: 3px 0;
}

.user-info div + div {
  border-top: 1px solid var(--border-color-light);
}

/* Common control styles */
.control-group {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Button styles live in components.css (.button-primary / secondary / danger) */

.danger-button {
  background-color: transparent;
  color: var(--danger-color);
  border: 1px solid var(--danger-color);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  width: 100%;
}

.danger-button:hover {
  background-color: var(--danger-color);
  color: var(--text-on-inverted);
}

.logout-form {
  margin: 0;
}

.logout-btn {
  background-color: transparent;
  color: var(--danger-color);
  border: 1px solid var(--danger-color);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  width: 100%;
}

.logout-btn:hover {
  background-color: var(--danger-color);
  color: var(--text-on-inverted);
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Filters */
.filters {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 10px;
}

.filters form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  flex-direction: row;
}

.filters input[type="text"] {
  width: 200px;
}

/* Login page */
body.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background-color: var(--bg-primary);
  background-image: url("../img/login-bg.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

[data-theme="dark"] body.login-page {
  background-image: url("../img/login-bg-dark.jpg");
}

.login-page .theme-toggle-container {
  margin-top: 25px;
  justify-content: center;
}

.login-brand {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin: 0 0 var(--space-5);
}

.login-logo {
  height: 34px;
}

.login-container {
  background: var(--bg-secondary);
  padding: var(--space-8);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  width: 100%;
  max-width: 400px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.login-form .remember-me {
  display: flex;
  align-items: center;
  margin: 15px 0;
}

/* Dashboard Layout */
.dashboard-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 30px;
  margin-bottom: 40px;
}

@media (max-width: 1024px) {
  .header {
    min-width: 0;
  }

  .header-layout {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "logo title end";
    align-items: center;
    column-gap: 10px;
    width: 100%;
  }

  .header-start {
    grid-area: logo;
    justify-self: start;
    min-width: 0;
  }

  .page-title {
    grid-area: title;
    grid-column: auto;
    margin: 0;
    text-align: left;
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-end {
    grid-area: end;
    display: flex;
    justify-self: end;
    gap: 10px;
  }

  .header-logo {
    height: 32px;
  }

  .gmt-clock-simple,
  .header-dfs-balance {
    font-size: 12px;
  }

  .user-info {
    right: 0;
    text-align: left;
  }
}

/* Responsive styles */
@media (max-width: 768px) {
  body {
    padding: 12px 16px;
    overflow-x: auto;
  }
  .content-wrapper {
    padding: 0;
    margin: 0;
  }
  .header {
    margin: -12px -16px 12px -16px;
    padding: 10px 16px;
  }
  .header-layout {
    grid-template-areas:
      "logo title user"
      "meta meta meta";
    row-gap: 8px;
  }
  .header-end {
    display: contents;
  }
  .header-layout .header-clock-dfs {
    grid-area: meta;
    justify-content: flex-start;
    justify-self: stretch;
    gap: 8px 12px;
  }
  .user-info-container {
    grid-area: user;
    justify-self: end;
    align-self: center;
  }
  .page-title {
    font-size: 1.05rem;
  }
  .filters {
    width: 100%;
  }
  .filters form {
    flex-wrap: wrap;
  }
  .filters input[type="text"] {
    width: 100%;
    flex: 1 1 100%;
  }
  .filters select {
    flex: 1 1 calc(50% - 5px);
  }
  .header-controls {
    width: 100%;
    justify-content: space-between;
  }
  .table-container {
    margin: 0;
    border-radius: 4px;
  }
  table th:nth-child(5),
  table td:nth-child(5),
  table th:nth-child(6),
  table td:nth-child(6),
  table th:nth-child(7),
  table td:nth-child(7) {
    display: none;
  }
  .pagination-buttons {
    gap: 6px;
  }
  .pagination-buttons .btn {
    min-width: 36px;
  }
  .pagination-buttons
    .btn:not(.active):not(:first-child):not(:last-child):not(
      .active + .btn
    ):not(.btn + .active) {
    display: none;
  }
  .login-container {
    margin: 20px;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 10px 12px;
  }
  .header {
    margin: -10px -12px 10px -12px;
    padding: 8px 12px;
  }
  .page-title {
    font-size: 1rem;
  }
  .header-logo {
    height: 28px;
  }
  .pagination-buttons {
    gap: 4px;
  }
  .pagination-buttons .btn {
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    font-size: 12px;
  }
  .pagination-buttons .btn:not(.active):not(:first-child):not(:last-child) {
    display: none;
  }
  .pagination-buttons .btn.active {
    display: flex;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .filters {
    width: 100%;
  }
  .header-controls {
    width: auto;
  }
  .pagination-buttons {
    gap: 6px;
  }
}

.user-info form {
  margin-left: 10px;
  display: inline-flex;
}

/* Simple GMT Clock Styles */
.header-clock-dfs {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px 14px;
  min-width: 0;
}

.gmt-clock-simple {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
}

.header-dfs-balance {
  font-family: var(--font-mono);
  font-size: var(--text-md);
  font-weight: 600;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.header-dfs-balance--ok {
  color: var(--success-color);
}

.header-dfs-balance--warn {
  color: var(--warning-color);
}

.header-dfs-balance--low {
  color: var(--danger-color);
}

.header-dfs-balance--error {
  color: var(--text-secondary);
  font-weight: normal;
}

/*
 * Toolbar + filters islands row (JS: toolbar-filters-layout.js).
 * Wrapper is layout-only — no shared chrome. Children keep their own island styles.
 */
.toolbar-filters-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-3, 12px);
  width: 100%;
  box-sizing: border-box;
  margin-bottom: var(--space-4, 16px);
}

.toolbar-filters-row > .stats-actions-block,
.toolbar-filters-row > .filters,
.toolbar-filters-row > .ml-row-1 {
  margin-bottom: 0;
}

.toolbar-filters-row.is-single-row {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
}

.toolbar-filters-row.is-single-row > .stats-actions-block {
  flex: 0 1 auto;
  min-width: 0;
}

.toolbar-filters-row.is-single-row > .filters,
.toolbar-filters-row.is-single-row > .ml-row-1 {
  flex: 1 1 auto;
  min-width: 0;
}

.toolbar-filters-row.is-stacked {
  flex-direction: column;
}
