/* ============================================================================
   Vector Portal - Universal Styles Template
   ============================================================================ */

:root {
  --vector-primary: #0f8995;
  --vector-danger: #dc3545;
  --vector-success: #28a745;
  --vector-warning: #ffc107;
  --vector-info: #17a2b8;

  --vector-bg: #f3f5f9;
  --vector-surface: #ffffff;
  --vector-panel: #ffffff;
  --vector-border: rgba(15, 23, 42, 0.08);

  --vector-text: #1f2937;
  --vector-text-muted: #6b7280;
  --vector-text-disabled: #9ca3af;

  --vector-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --vector-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --vector-shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  background: var(--vector-bg);
  color: var(--vector-text);
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

body {
  padding: 0;
}

/* ============================================================================
   Typography
   ============================================================================ */

h1 { font-size: 28px; font-weight: 600; line-height: 1.2; margin: 0 0 16px; color: #0f172a; }
h2 { font-size: 20px; font-weight: 600; line-height: 1.3; margin: 0 0 12px; color: #0f172a; }
h3 { font-size: 16px; font-weight: 600; line-height: 1.4; margin: 0 0 8px; color: #1f2937; }
h4 { font-size: 14px; font-weight: 600; line-height: 1.5; margin: 0 0 8px; color: #1f2937; }

p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }

strong { font-weight: 600; }
em { font-style: italic; }

/* ============================================================================
   Form Elements
   ============================================================================ */

button, input, select, textarea, [role="button"] {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  background: var(--vector-surface);
  border: 1px solid var(--vector-border);
  color: var(--vector-text);
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  transition: all 150ms ease;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: #f0f4f8;
  border-color: var(--vector-primary);
  color: var(--vector-primary);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 2px solid var(--vector-primary);
  outline-offset: 2px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary, button[data-variant="primary"] {
  background: var(--vector-primary);
  color: #ffffff;
  border-color: var(--vector-primary);
}

button.primary:hover:not(:disabled), button[data-variant="primary"]:hover:not(:disabled) {
  background: #0a5f6f;
  border-color: #0a5f6f;
}

button.danger, button[data-variant="danger"] {
  background: var(--vector-danger);
  color: #ffffff;
  border-color: var(--vector-danger);
}

button.danger:hover:not(:disabled), button[data-variant="danger"]:hover:not(:disabled) {
  background: #bd2130;
  border-color: #bd2130;
}

button.success, button[data-variant="success"] {
  background: var(--vector-success);
  color: #ffffff;
  border-color: var(--vector-success);
}

button.success:hover:not(:disabled), button[data-variant="success"]:hover:not(:disabled) {
  background: #218838;
  border-color: #218838;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="search"],
textarea,
select {
  min-height: 36px;
  padding: 6px 10px;
  background: var(--vector-surface);
  border: 1px solid var(--vector-border);
  color: var(--vector-text);
  border-radius: 6px;
  transition: all 150ms ease;
  font-size: 14px;
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="number"]::placeholder,
input[type="date"]::placeholder,
input[type="time"]::placeholder,
input[type="search"]::placeholder,
textarea::placeholder {
  color: var(--vector-text-muted);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--vector-primary);
  box-shadow: 0 0 0 3px rgba(15, 137, 149, 0.1);
}

input:disabled,
textarea:disabled,
select:disabled {
  background: #f3f4f6;
  color: var(--vector-text-disabled);
  cursor: not-allowed;
  opacity: 0.6;
}

textarea {
  min-height: 100px;
  resize: vertical;
  font-family: 'Courier New', monospace;
}

select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%231f2937' d='M4.5 6L8 10l3.5-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 18px;
  cursor: pointer;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--vector-primary);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--vector-primary);
  outline-offset: 2px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--vector-text);
}

/* ============================================================================
   Panels & Containers
   ============================================================================ */

main, .app-shell, .screen-root, #app {
  background: transparent;
  min-height: 100vh;
  padding: 20px;
}

section, aside, nav.toolbar, .panel, .box, .card {
  background: var(--vector-panel);
  border: 1px solid var(--vector-border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

section:last-child, aside:last-child, .panel:last-child, .box:last-child, .card:last-child {
  margin-bottom: 0;
}

.panel-header, .box-header, .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--vector-border);
}

.panel-content, .box-content, .card-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-result, .form-result, .status-message {
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.panel-result.success, .form-result.success, .status-message.success {
  background: rgba(40, 167, 69, 0.1);
  color: #155724;
  border: 1px solid rgba(40, 167, 69, 0.2);
}

.panel-result.error, .form-result.error, .status-message.error {
  background: rgba(220, 53, 69, 0.1);
  color: #721c24;
  border: 1px solid rgba(220, 53, 69, 0.2);
}

.panel-result.warning, .form-result.warning, .status-message.warning {
  background: rgba(255, 193, 7, 0.1);
  color: #856404;
  border: 1px solid rgba(255, 193, 7, 0.2);
}

.panel-result.info, .form-result.info, .status-message.info {
  background: rgba(23, 162, 184, 0.1);
  color: #0c5460;
  border: 1px solid rgba(23, 162, 184, 0.2);
}

/* ============================================================================
   Toolbar & Navigation
   ============================================================================ */

nav.toolbar, #toolbar, [role="toolbar"] {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px 0;
  align-items: center;
}

nav.toolbar button, #toolbar button, [role="toolbar"] button {
  min-width: 100px;
}

/* ============================================================================
   Layout Utilities
   ============================================================================ */

.grid-tools, .list-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 8px 0;
}

.list-tools {
  justify-content: flex-end;
  padding: 8px;
  border-top: 1px solid var(--vector-border);
}

#search, #filter, [type="search"] {
  min-width: 200px;
  flex: 0 1 auto;
}

/* ============================================================================
   Tables & Data Lists
   ============================================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--vector-bg);
  color: var(--vector-text);
  font-weight: 600;
  text-align: left;
  padding: 10px;
  border: 1px solid var(--vector-border);
  white-space: nowrap;
}

td {
  padding: 10px;
  border: 1px solid var(--vector-border);
  word-wrap: break-word;
}

tr:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

tr:hover {
  background: rgba(15, 137, 149, 0.05);
}

tr.selected, tr[aria-selected="true"] {
  background: rgba(15, 137, 149, 0.1);
}

.data-row, [role="row"] {
  cursor: pointer;
  transition: background 150ms ease;
}

.data-row:hover:not([disabled]), [role="row"]:hover:not([disabled]) {
  background: rgba(15, 137, 149, 0.05);
}

.data-row.selected, [role="row"][aria-selected="true"] {
  background: rgba(15, 137, 149, 0.1);
  outline: 2px solid var(--vector-primary);
  outline-offset: -2px;
}

/* ============================================================================
   Forms
   ============================================================================ */

form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group, .form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.form-row.full {
  grid-template-columns: 1fr;
}

.form-actions, .dialog-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--vector-border);
}

.form-actions button:first-child {
  min-width: 100px;
}

fieldset {
  border: 1px solid var(--vector-border);
  border-radius: 6px;
  padding: 12px;
  margin: 12px 0;
}

legend {
  font-weight: 600;
  padding: 0 8px;
}

/* ============================================================================
   Modals & Dialogs
   ============================================================================ */

dialog, .modal-overlay, [role="dialog"] {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

dialog {
  border: 1px solid var(--vector-border);
  border-radius: 8px;
  background: var(--vector-surface);
  padding: 24px;
  max-width: 500px;
  box-shadow: var(--vector-shadow-lg);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.modal-box, .modal-content {
  background: var(--vector-surface);
  border: 1px solid var(--vector-border);
  border-radius: 8px;
  padding: 20px;
  max-width: 500px;
  width: 90%;
  box-shadow: var(--vector-shadow-lg);
}

.modal-overlay {
  background: rgba(0, 0, 0, 0.5);
}

/* ============================================================================
   Grid & Transfer Lists
   ============================================================================ */

.transfer {
  display: grid;
  grid-template-columns: 1fr 80px 1fr;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}

.transfer-list, .transfer-pane {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.transfer-list strong, .transfer-pane strong {
  font-weight: 600;
  font-size: 13px;
  color: var(--vector-text);
}

.transfer-list select, .check-list {
  width: 100%;
  min-height: 150px;
  padding: 6px;
  border: 1px solid var(--vector-border);
  border-radius: 6px;
  background: var(--vector-surface);
  font-size: 13px;
}

.transfer-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.transfer-controls button {
  font-size: 20px;
  padding: 4px 0;
}

.check-list {
  height: 150px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
}

.check-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px;
  margin-bottom: 0;
  cursor: pointer;
  border-radius: 4px;
  transition: background 150ms ease;
}

.check-list label:hover {
  background: rgba(15, 137, 149, 0.08);
}

.check-list input {
  margin: 0;
  width: 16px;
  height: 16px;
}

/* ============================================================================
   Utilities
   ============================================================================ */

[hidden] {
  display: none !important;
}

.sr-only, .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nowrap {
  white-space: nowrap;
}

.inline-error, .error-message {
  color: var(--vector-danger);
  font-size: 12px;
  margin-top: 4px;
}

.inline-error:empty {
  display: none;
}

.text-muted {
  color: var(--vector-text-muted);
}

.text-success {
  color: var(--vector-success);
}

.text-danger {
  color: var(--vector-danger);
}

.text-warning {
  color: var(--vector-warning);
}

.text-info {
  color: var(--vector-info);
}

/* ============================================================================
   Responsive Design
   ============================================================================ */

@media (max-width: 1024px) {
  main, .app-shell, .screen-root, #app {
    padding: 16px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .transfer {
    grid-template-columns: 1fr;
  }

  .transfer-controls {
    flex-direction: row;
    gap: 4px;
  }

  .transfer-controls button {
    flex: 1;
  }
}

@media (max-width: 700px) {
  main, .app-shell, .screen-root, #app {
    padding: 10px;
  }

  h1 { font-size: 22px; }
  h2 { font-size: 18px; }
  h3 { font-size: 14px; }

  section, aside, nav.toolbar, .panel, .box, .card {
    padding: 12px;
    margin-bottom: 12px;
  }

  nav.toolbar, #toolbar, [role="toolbar"] {
    gap: 6px;
  }

  nav.toolbar button, #toolbar button, [role="toolbar"] button {
    flex: 1;
    min-width: 80px;
  }

  #search, #filter, [type="search"] {
    width: 100%;
    min-width: auto;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  table {
    font-size: 12px;
  }

  th, td {
    padding: 8px;
  }

  .transfer {
    gap: 8px;
  }
}

@media (max-width: 480px) {
  main, .app-shell, .screen-root, #app {
    padding: 8px;
  }

  button {
    min-height: 40px;
    padding: 8px 12px;
  }

  input, select, textarea {
    min-height: 40px;
    padding: 8px 10px;
  }

  dialog, .modal-box, .modal-content {
    width: 95%;
    max-width: 100%;
    padding: 16px;
  }
}