/* ISD Original - Component Styles */
/* Faithful recreation of Flash Flex 3.5 UI */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  background: var(--color-body-bg);
  color: var(--color-text);
  overflow: hidden;
  height: 100%;
}

/* ── App Shell ── */
#app {
  width: var(--width-app);
  height: 100vh;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: var(--color-app-bg);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* ── Login Screen ── */
.login-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-body-bg);
  z-index: 1000;
}

.login-box {
  width: 575px;
  padding: 20px 24px;
  background: var(--color-panel-white);
  border: 1px solid var(--color-login-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-dialog);
}

.login-box h2 {
  margin: 0 0 16px 0;
  font-size: var(--font-size-xl);
  font-weight: 600;
}

.login-row {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
}

.login-row label {
  width: 140px;
  font-size: var(--font-size-base);
  text-align: right;
  padding-right: 12px;
}

.login-row input[type="text"],
.login-row input[type="password"] {
  width: 250px;
  padding: 4px 8px;
  font-size: var(--font-size-base);
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
}

.login-row input:focus {
  outline: none;
  border-color: var(--color-tab-header);
  box-shadow: 0 0 3px rgba(154, 223, 255, 0.5);
}

.login-actions {
  display: flex;
  gap: 8px;
  margin-left: 140px;
  margin-top: 12px;
}

.login-checkbox {
  margin-left: 140px;
  margin-top: 4px;
  margin-bottom: 4px;
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 6px;
}

.login-version {
  text-align: right;
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  margin-top: 8px;
}

/* ── Buttons (Flash-style) ── */
.btn {
  padding: 4px 16px;
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  border: 1px solid #999;
  border-radius: var(--radius-sm);
  background: linear-gradient(to bottom, #f8f8f8, #e0e0e0);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover {
  background: linear-gradient(to bottom, #fff, #e8e8e8);
}
.btn:active {
  background: linear-gradient(to bottom, #d8d8d8, #c8c8c8);
}
.btn-primary {
  background: linear-gradient(to bottom, #c8e8ff, #a0d0f0);
  border-color: #88b8d8;
}
.btn-primary:hover {
  background: linear-gradient(to bottom, #d8f0ff, #b0d8f8);
}
.btn-danger {
  background: linear-gradient(to bottom, #ffd0d0, #f0a0a0);
  border-color: #d88888;
}
.btn-sm {
  padding: 2px 10px;
  font-size: var(--font-size-sm);
}
.btn-link {
  background: none;
  border: none;
  color: var(--color-accent-blue);
  cursor: pointer;
  padding: 2px 4px;
  text-decoration: underline;
  font-size: var(--font-size-base);
}
.btn-link:hover { color: #0000cc; }

/* ── 3-Column Layout ── */
.app-layout {
  display: flex;
  width: 100%;
  height: 100vh;
  position: relative;
  gap: 2px;
}

.panel-left {
  width: var(--width-left-panel);
  height: 100%;
  background: var(--color-panel-blue-80);
  flex-shrink: 0;
  overflow: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

.panel-center {
  flex: 1;
  height: 100%;
  background: var(--color-panel-blue);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-right {
  width: var(--width-right-panel);
  height: 100%;
  background: var(--color-panel-blue-80);
  flex-shrink: 0;
  overflow: hidden;
  padding: 10px;
  display: flex;
  flex-direction: column;
}

/* Panel section titles */
.panel-title {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin: 0 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--color-rule-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-placeholder {
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-style: italic;
  text-align: center;
  padding: 20px 10px;
  opacity: 0.6;
}

/* ── Startscreen Overlay ── */
.startscreen {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 750px;
  max-height: 90vh;
  background: var(--color-panel-blue-80);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-dialog);
  z-index: 50;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.startscreen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--color-tab-header);
  border-bottom: 1px solid var(--color-rule-light);
}

.startscreen-header h1 {
  margin: 0;
  font-size: var(--font-size-xl);
  font-weight: 600;
}

.startscreen-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* ── Tab Navigator (Flash-style) ── */
.tab-nav {
  display: flex;
  background: var(--color-tab-header);
  border-bottom: 1px solid var(--color-rule-light);
  padding: 0;
  gap: 0;
}

.tab-nav-item {
  padding: 6px 14px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--color-text);
  margin-bottom: -1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
}
.tab-nav-item:hover {
  background: rgba(255,255,255,0.3);
}
.tab-nav-item.active {
  background: var(--color-panel-white);
  border-color: var(--color-rule-light);
  font-weight: 600;
}
.tab-nav-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tab-content {
  background: var(--color-panel-white);
  padding: 12px;
  min-height: 200px;
}

/* ── Top Tabs (center panel header) ── */
.top-tabs {
  background: var(--color-tab-header);
  border: 1px solid var(--color-text);
  border-radius: var(--radius-md);
  margin: 10px;
  box-shadow: 2px 2px 4px var(--color-shadow);
  overflow: hidden;
}

.top-tabs-header {
  display: flex;
  background: var(--color-tab-header);
  border-bottom: 1px solid var(--color-rule-light);
  padding: 0;
}

.top-tabs-body {
  background: var(--color-panel-white);
  padding: 10px;
  min-height: 140px;
}

/* ── Accordion (ICF panels) ── */
.accordion {
  width: 100%;
  border: 1px solid var(--color-rule-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.accordion-item {
  border-bottom: 1px solid var(--color-rule-light);
}
.accordion-item:last-child {
  border-bottom: none;
}

.accordion-header {
  padding: 6px 10px;
  background: linear-gradient(to bottom, #d8f0ff, #b8e4ff);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}
.accordion-header:hover {
  background: linear-gradient(to bottom, #e0f4ff, #c0e8ff);
}
.accordion-header.active {
  background: linear-gradient(to bottom, #c0e8ff, #a0d8f8);
  font-weight: 600;
}

.accordion-header .badge {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-left: 8px;
}

.accordion-body {
  background: var(--color-panel-white);
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal);
}
.accordion-body.open {
  max-height: 500px;
  overflow-y: auto;
}

/* ── Data Grid (Flash DataGrid style) ── */
.data-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}

.data-grid th {
  background: linear-gradient(to bottom, #e8e8e8, #d0d0d0);
  padding: 4px 8px;
  text-align: left;
  font-weight: 600;
  border: 1px solid #bbb;
  font-size: var(--font-size-xs);
  white-space: nowrap;
}

.data-grid td {
  padding: 3px 8px;
  border: 1px solid #ddd;
  vertical-align: top;
  line-height: 1.3;
}

.data-grid tr:nth-child(even) {
  background: #f5f5f5;
}

.data-grid tr:hover {
  background: #e0f0ff;
  cursor: pointer;
}

.data-grid tr.selected {
  background: #b8d8f0;
}

.data-grid .col-date {
  width: 80px;
  white-space: nowrap;
}

.data-grid .col-caption {
  word-wrap: break-word;
}

.data-grid .col-nr {
  width: 30px;
  text-align: center;
}

/* ── Editor Dialog (TitleWindow style) ── */
.editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.editor-dialog {
  width: 540px;
  background: var(--color-panel-white);
  border: 1px solid #999;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dialog);
}

.editor-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: linear-gradient(to bottom, #d8d8d8, #c0c0c0);
  border-bottom: 1px solid #999;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-weight: 600;
  font-size: var(--font-size-lg);
}

.editor-dialog-body {
  padding: 12px;
}

.editor-dialog-body textarea {
  width: 100%;
  min-height: 120px;
  padding: 6px 8px;
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  resize: vertical;
}
.editor-dialog-body textarea:focus {
  outline: none;
  border-color: var(--color-tab-header);
}

.editor-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.editor-row label {
  min-width: 80px;
  font-size: var(--font-size-sm);
}

.editor-row input,
.editor-row select {
  padding: 3px 6px;
  font-size: var(--font-size-base);
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
}

.editor-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 8px 12px;
  border-top: 1px solid #ddd;
}

/* ── ComboBox / Select (Flash style) ── */
.combo-box {
  padding: 3px 6px;
  font-size: var(--font-size-base);
  border: 1px solid #aaa;
  border-radius: var(--radius-sm);
  background: white;
  font-family: var(--font-family);
  min-width: 200px;
}

/* ── Search Field ── */
.search-field {
  padding: 3px 6px;
  font-size: var(--font-size-base);
  border: 1px solid #aaa;
  border-radius: var(--radius-sm);
  width: 100%;
  font-family: var(--font-family);
}

/* ── Horizontal Rules (Flash style) ── */
.hr-light {
  border: none;
  border-top: 1px solid var(--color-rule-light);
  margin: 8px 0;
}

.hr-dark {
  border: none;
  border-top: 1px solid var(--color-rule-dark);
  margin: 8px 0;
}

/* ── Checkbox (Flash style) ── */
.chk-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-sm);
  cursor: pointer;
}

/* ── Activity Summary Box ── */
.activity-box {
  background: var(--color-panel-white);
  border: 1px solid var(--color-rule-light);
  border-radius: var(--radius-md);
  padding: 10px;
  margin-top: 10px;
}

.activity-box h4 {
  margin: 0 0 6px 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.activity-list {
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

/* ── Scrollbar (thin, Flash-like) ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #f0f0f0; }
::-webkit-scrollbar-thumb { background: #c0c0c0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a0a0a0; }

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 20px;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-style: italic;
}

/* ── Flash-style Link Button ── */
.link-btn {
  background: none;
  border: none;
  color: var(--color-accent-blue);
  cursor: pointer;
  font-size: var(--font-size-base);
  text-decoration: underline;
  padding: 0;
  font-family: var(--font-family);
}
.link-btn:hover {
  color: #0000cc;
}

/* ── Admin Grid ── */
.admin-grid {
  margin-top: 10px;
}

.admin-form {
  background: #f8f8f8;
  border: 1px solid #ddd;
  border-radius: var(--radius-sm);
  padding: 10px;
  margin-top: 10px;
}

.admin-form .form-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.admin-form .form-row label {
  width: 120px;
  font-size: var(--font-size-sm);
  text-align: right;
  padding-right: 8px;
}

.admin-form .form-row input {
  flex: 1;
  padding: 3px 6px;
  font-size: var(--font-size-base);
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
}

/* ── Two-column access rights ── */
.access-columns {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.access-column {
  flex: 1;
  min-width: 0;
}

.access-column h4 {
  margin: 0 0 8px 0;
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.access-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: center;
  padding-top: 30px;
}

/* ── Notification Toast ── */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #333;
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  z-index: 9999;
  animation: toast-in 0.3s ease;
}

.toast.error {
  background: var(--color-warning-red);
}

.toast.success {
  background: var(--color-success);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Center panel main area ── */
.center-main {
  flex: 1;
  overflow-y: auto;
  padding: 0 10px 10px;
}

.center-tabs {
  margin: 0 10px;
}

.center-tabs .tab-nav {
  background: var(--color-panel-blue);
}

.center-tabs .tab-nav-item.active {
  background: var(--color-panel-white);
}

/* ── Report Builder ── */
.report-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-dialog {
  width: 1100px;
  max-width: 95vw;
  max-height: 90vh;
  background: var(--color-panel-white);
  border: 1px solid #999;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-dialog);
  display: flex;
  flex-direction: column;
}

.report-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(to bottom, #d8d8d8, #c0c0c0);
  border-bottom: 1px solid #999;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  font-weight: 600;
  font-size: var(--font-size-lg);
}

.report-dialog-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 10px;
  min-height: 0;
}

.report-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.report-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-size-sm);
}

.report-columns {
  display: flex;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.report-col-left {
  width: 200px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.report-col-center {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.report-col-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.report-section-label {
  font-size: var(--font-size-xs);
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.report-group-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #ddd;
  background: white;
  min-height: 200px;
  max-height: 400px;
}

.report-group-item {
  padding: 4px 8px;
  font-size: var(--font-size-sm);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
}

.report-group-item:hover {
  background: #e0f0ff;
}

.report-group-item.selected {
  background: #b8d8f0;
  font-weight: 600;
}

.report-entry-grid {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #ddd;
  min-height: 150px;
  max-height: 350px;
}

.report-copy-buttons {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.report-editor {
  flex: 1;
  width: 100%;
  min-height: 200px;
  padding: 8px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  resize: none;
  line-height: 1.5;
}

.report-editor:focus {
  outline: none;
  border-color: var(--color-tab-header);
}

.report-editor.drag-over {
  border-color: #0066cc;
  background: #f0f8ff;
}

.report-dialog-footer {
  padding: 8px 12px;
  border-top: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-title-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.report-title-row label {
  font-size: var(--font-size-sm);
  font-weight: 600;
}

.report-title-row input {
  padding: 3px 8px;
  font-size: var(--font-size-base);
  border: 1px solid #ccc;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
}

.report-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Print styles ── */
@media print {
  .login-overlay, .startscreen, .panel-left, .panel-right,
  .top-tabs, .tab-nav, .btn, .editor-overlay, .toast,
  .report-overlay {
    display: none !important;
  }
  body {
    background: white;
    overflow: visible;
  }
  .panel-center {
    width: 100% !important;
    overflow: visible;
  }
}
