/* Portfolio Review Tool Page Styles */
.iv-portfolio-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* Autocomplete Suggestion Dropdown */
.iv-portfolio-search-box {
  margin-top: 12px;
}

.iv-search-input-group {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.iv-search-input-group .iv-primary-btn {
  margin-top: 0;
  border-radius: 12px;
  padding: 12px 24px;
  white-space: nowrap;
  font-size: 14px;
}

.iv-search-input-wrapper {
  position: relative;
  flex: 1;
}

.iv-search-input-wrapper input {
  width: 100%;
  border: 1px solid rgba(var(--iv-accent-rgb), 0.24);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(var(--iv-bg-rgb), 0.6);
  color: var(--iv-text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.iv-search-input-wrapper input:focus {
  border-color: var(--iv-accent);
  box-shadow: 0 0 0 3px rgba(var(--iv-accent-rgb), 0.15);
}

.iv-autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--iv-bg-alt);
  border: 1px solid rgba(var(--iv-accent-rgb), 0.3);
  border-radius: 12px;
  max-height: 280px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  scrollbar-width: thin;
}

.iv-autocomplete-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--iv-border-subtle);
  cursor: pointer;
  transition: background 0.2s;
}

.iv-autocomplete-item:last-child {
  border-bottom: none;
}

.iv-autocomplete-item:hover,
.iv-autocomplete-item.is-selected {
  background: rgba(var(--iv-accent-rgb), 0.12);
}

.iv-autocomplete-item .stock-name {
  font-weight: 600;
  color: var(--iv-text);
}

.iv-autocomplete-item .stock-codes {
  font-size: 11px;
  color: var(--iv-text-muted);
  background: var(--iv-card);
  padding: 2px 6px;
  border-radius: 4px;
}

/* Evaluation Table Styling */
.iv-portfolio-table-wrap {
  margin-top: 12px;
  overflow-x: auto;
}

.iv-portfolio-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.iv-portfolio-table-wrap th {
  background: var(--iv-bg);
  color: var(--iv-text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 14px 16px;
  text-align: left;
  border-bottom: 2px solid rgba(var(--iv-accent-rgb), 0.16);
  white-space: normal;
  line-height: 1.4;
  vertical-align: bottom;
}

.iv-portfolio-table-wrap td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--iv-border-subtle);
  color: var(--iv-text);
}

.nse-code-sub {
  font-size: 11px;
  text-transform: lowercase;
  font-variant: small-caps;
  color: var(--iv-text-muted);
  margin-top: 4px;
  font-family: monospace;
  font-weight: normal;
  display: block;
}

.iv-portfolio-table-wrap tr:hover td {
  background: rgba(var(--iv-accent-rgb), 0.03);
}

/* Score Interactive Badges */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  border-radius: 20px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  user-select: none;
  min-width: 54px;
}

.score-badge:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.score-badge.score-green {
  background: rgba(46, 204, 113, 0.15);
  color: var(--iv-success);
  border: 1px solid rgba(46, 204, 113, 0.3);
}

.score-badge.score-yellow {
  background: rgba(241, 196, 15, 0.15);
  color: var(--iv-warning);
  border: 1px solid rgba(241, 196, 15, 0.3);
}

.score-badge.score-red {
  background: rgba(231, 76, 60, 0.15);
  color: var(--iv-danger);
  border: 1px solid rgba(231, 76, 60, 0.3);
}

/* Action Delete Button */
.btn-delete {
  background: none;
  border: none;
  color: rgba(231, 76, 60, 0.8);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-delete:hover {
  background: rgba(231, 76, 60, 0.12);
  color: var(--iv-danger);
}

/* Slide-out Drawer Container */
.iv-portfolio-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none; /* Controlled dynamically */
}

.iv-portfolio-drawer.is-open {
  display: block;
}

.iv-drawer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 8, 16, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.iv-portfolio-drawer.is-open .iv-drawer-overlay {
  opacity: 1;
}

.iv-drawer-content {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  max-width: 100%;
  background: var(--iv-bg-alt);
  border-left: 1px solid rgba(var(--iv-accent-rgb), 0.25);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.iv-portfolio-drawer.is-open .iv-drawer-content {
  transform: translateX(0);
}

.iv-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(var(--iv-accent-rgb), 0.15);
}

.iv-drawer-header h3 {
  margin: 0;
  color: var(--iv-accent-light);
  font-size: 18px;
  font-weight: 600;
}

.iv-drawer-close {
  background: none;
  border: none;
  color: var(--iv-text-muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.2s;
}

.iv-drawer-close:hover {
  color: var(--iv-text);
}

.iv-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  scrollbar-width: thin;
}

.iv-drawer-stock-info {
  padding: 20px 24px;
  background: var(--iv-card);
  border-bottom: 1px solid var(--iv-border-subtle);
}

.iv-drawer-stock-info h4 {
  margin: 0 0 6px 0;
  font-size: 20px;
  color: var(--iv-text);
  font-weight: 700;
}

.iv-drawer-stock-codes {
  display: flex;
  gap: 12px;
}

.iv-drawer-stock-codes span {
  font-size: 12px;
  color: var(--iv-text-muted);
  background: var(--iv-card);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Drawer Score Summary Card */
.iv-drawer-score-card {
  margin: 20px 24px;
  background: rgba(var(--iv-accent-rgb), 0.04);
  border: 1px solid rgba(var(--iv-accent-rgb), 0.16);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.iv-drawer-score-label {
  color: var(--iv-text-secondary);
  font-weight: 500;
  font-size: 14px;
}

.iv-drawer-score-value {
  color: var(--iv-accent-light);
  font-size: 22px;
  font-weight: 800;
}

/* Detailed Parameters Checklist */
.iv-drawer-section {
  padding: 0 24px 24px 24px;
}

.iv-drawer-section h4 {
  margin: 0 0 12px 0;
  color: var(--iv-text-secondary);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--iv-border-subtle);
  padding-bottom: 6px;
}

.iv-drawer-param-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--iv-border-subtle);
}

.iv-drawer-param-item:last-child {
  border-bottom: none;
}

.iv-param-meta {
  flex: 1;
  padding-right: 12px;
}

.iv-param-name {
  color: var(--iv-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.iv-param-threshold {
  color: var(--iv-text-muted);
  font-size: 11px;
  margin-top: 3px;
}

.iv-param-status-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.iv-param-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--iv-text);
}

.iv-param-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  line-height: 1;
}

.iv-param-badge.pass {
  background: rgba(46, 204, 113, 0.18);
  color: var(--iv-success);
}

.iv-param-badge.fail {
  background: rgba(231, 76, 60, 0.18);
  color: var(--iv-danger);
}

.iv-param-badge.neutral {
  background: var(--iv-card);
  color: var(--iv-text-secondary);
}

/* Card Header layout adjustment */
.iv-card-header h3 {
  color: var(--iv-text);
  font-size: 16px;
  font-weight: 600;
}

/* Ensure the autocomplete dropdown is not clipped by the card container */
.iv-portfolio-page .iv-card {
  overflow: visible;
}

/* CSV Portfolio Import Styling */
.iv-portfolio-upload-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed rgba(var(--iv-accent-rgb), 0.18);
}

.iv-upload-label {
  display: block;
  margin-bottom: 8px;
  color: var(--iv-text-muted);
  font-size: 13px;
  font-weight: 500;
}

.iv-file-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  border: 2px dashed rgba(var(--iv-accent-rgb), 0.25);
  border-radius: 12px;
  background: rgba(var(--iv-bg-rgb), 0.4);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}

.iv-file-dropzone:hover,
.iv-file-dropzone.dragover {
  border-color: var(--iv-accent);
  background: rgba(var(--iv-accent-rgb), 0.08);
}

.iv-upload-icon {
  width: 32px;
  height: 32px;
  color: var(--iv-accent);
  margin-bottom: 8px;
  transition: transform 0.2s;
}

.iv-file-dropzone:hover .iv-upload-icon {
  transform: translateY(-2px);
}

.dropzone-text {
  color: var(--iv-text-secondary);
  font-size: 13px;
  text-align: center;
  line-height: 1.4;
}

.dropzone-text .browse-link {
  color: var(--iv-accent);
  text-decoration: underline;
  font-weight: 600;
}

/* Upload Status & Progress bar */
.iv-upload-status {
  margin-top: 12px;
  background: rgba(var(--iv-bg-rgb), 0.3);
  border: 1px solid var(--iv-border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
}

.iv-upload-status-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

#ivUploadProgressLabel {
  font-size: 12px;
  color: var(--iv-text-secondary);
}

#ivUploadProgressPct {
  font-size: 12px;
  font-weight: 700;
  color: var(--iv-accent);
}

.iv-upload-progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--iv-card);
  border-radius: 3px;
  overflow: hidden;
}

#ivUploadProgressBar {
  width: 0%;
  height: 100%;
  background: var(--iv-accent);
  border-radius: 3px;
  transition: width 0.1s linear;
}

/* Log messages container */
.iv-upload-logs {
  margin-top: 12px;
  max-height: 140px;
  overflow-y: auto;
  background: rgba(3, 8, 16, 0.5);
  border: 1px solid rgba(var(--iv-accent-rgb), 0.15);
  border-radius: 8px;
  padding: 10px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  color: var(--iv-text-secondary);
  scrollbar-width: thin;
}

.iv-upload-log-row {
  margin-bottom: 4px;
  line-height: 1.4;
  word-break: break-all;
}

.iv-upload-log-row:last-child {
  margin-bottom: 0;
}

.iv-upload-log-row.success {
  color: var(--iv-success);
}

.iv-upload-log-row.error {
  color: var(--iv-danger);
}

.iv-upload-log-row.info {
  color: var(--iv-text-secondary);
}

/* Custom Confirmation Modal */
.iv-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.iv-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(3, 8, 16, 0.75);
  backdrop-filter: blur(4px);
}

.iv-modal-content {
  position: relative;
  background: var(--iv-bg-alt);
  border: 1px solid rgba(var(--iv-accent-rgb), 0.28);
  border-radius: 16px;
  width: 380px;
  max-width: 90%;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.85);
  z-index: 10001;
  overflow: hidden;
  animation: ivModalScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes ivModalScaleIn {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.iv-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(var(--iv-accent-rgb), 0.14);
}

.iv-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--iv-accent-light);
}

.iv-modal-body {
  padding: 20px;
}

.iv-modal-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--iv-text);
}

.iv-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(var(--iv-accent-rgb), 0.03);
  border-top: 1px solid rgba(var(--iv-accent-rgb), 0.1);
}

.iv-modal-btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.iv-modal-btn.cancel {
  background: transparent;
  color: var(--iv-text-muted);
  border: 1px solid rgba(var(--iv-accent-rgb), 0.2);
}

.iv-modal-btn.cancel:hover {
  color: var(--iv-text);
  background: rgba(var(--iv-accent-rgb), 0.05);
}

.iv-modal-btn.confirm {
  background: var(--iv-danger);
  color: #fff;
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.2);
}

.iv-modal-btn.confirm:hover {
  background: #c0392b;
  transform: translateY(-1px);
}

.iv-modal-btn.alert-ok {
  background: linear-gradient(135deg, var(--iv-gold), #AA8121);
  color: var(--iv-navy-3);
  box-shadow: 0 4px 12px rgba(var(--iv-accent-rgb), 0.17);
}

.iv-modal-btn.alert-ok:hover {
  background: var(--iv-gold);
  transform: translateY(-1px);
}
