/**
 * Portal CSS - Custom styles for the public submission portal
 * Uses Bootstrap 5 as the base framework
 */

/* =============================================================================
   CSS Custom Properties (Theme Variables)
   ============================================================================= */
:root {
  --portal-primary: #0d6efd;
  --portal-primary-dark: #0a58ca;
  --portal-secondary: #6c757d;
  --portal-accent: #ffc107;
  --portal-success: #198754;
  --portal-danger: #dc3545;
  --portal-warning: #ffc107;
  --portal-info: #0dcaf0;
  --portal-light: #f8f9fa;
  --portal-dark: #212529;

  --portal-bg: #f5f7fa;
  --portal-card-bg: #ffffff;
  --portal-border-color: #dee2e6;

  --portal-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --portal-heading-font: var(--portal-font-family);

  --portal-shadow-sm: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  --portal-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  --portal-shadow-lg: 0 1rem 3rem rgba(0, 0, 0, 0.175);

  --portal-border-radius: 0.375rem;
  --portal-border-radius-lg: 0.5rem;
}

/* =============================================================================
   Base Styles
   ============================================================================= */
body {
  font-family: var(--portal-font-family);
  background-color: var(--portal-bg);
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--portal-heading-font);
  font-weight: 600;
}

/* =============================================================================
   Authentication Pages
   ============================================================================= */
.portal-auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - 80px);
  padding: 2rem 1rem;
  background: linear-gradient(135deg, var(--portal-primary) 0%, var(--portal-primary-dark) 100%);
}

.portal-auth-card {
  max-width: 420px;
  width: 100%;
  border: none;
  border-radius: var(--portal-border-radius-lg);
}

.portal-logo {
  max-height: 60px;
  width: auto;
}

.portal-title {
  color: var(--portal-dark);
}

/* Password toggle button */
.toggle-password {
  border-color: var(--portal-border-color);
}

.toggle-password:hover {
  background-color: var(--portal-light);
}

/* =============================================================================
   Navigation
   ============================================================================= */
.navbar {
  padding: 0.75rem 0;
}

.navbar-brand {
  font-weight: 600;
}

.nav-link {
  padding: 0.5rem 1rem;
  font-weight: 500;
  color: var(--portal-secondary);
  transition: color 0.15s ease-in-out;
}

.nav-link:hover,
.nav-link.active {
  color: var(--portal-primary);
}

.nav-link i {
  font-size: 1rem;
}

/* =============================================================================
   Dashboard Cards
   ============================================================================= */
.card {
  border-radius: var(--portal-border-radius-lg);
  transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

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

.card-header {
  border-bottom: 1px solid var(--portal-border-color);
  padding: 1rem 1.25rem;
}

.card-header h5 {
  margin: 0;
}

/* Form cards */
.form-card {
  cursor: pointer;
}

.form-card:hover {
  box-shadow: var(--portal-shadow);
}

.form-card .card-title {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.form-card .card-text {
  font-size: 0.9rem;
  line-height: 1.5;
}

/* =============================================================================
   Tables
   ============================================================================= */
.table {
  margin-bottom: 0;
}

.table th {
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  color: var(--portal-secondary);
  border-bottom-width: 1px;
}

.table td {
  vertical-align: middle;
  padding: 1rem 0.75rem;
}

/* Status badges */
.badge-status {
  font-weight: 500;
  font-size: 0.75rem;
  padding: 0.35em 0.65em;
  border-radius: 0.25rem;
}

.badge-draft {
  background-color: #e3e6ea;
  color: #495057;
}

.badge-submitted {
  background-color: #cfe2ff;
  color: #084298;
}

.badge-rated {
  background-color: #d1e7dd;
  color: #0f5132;
}

.badge-error {
  background-color: #f8d7da;
  color: #842029;
}

.badge-pending {
  background-color: #fff3cd;
  color: #664d03;
}

/* =============================================================================
   Forms
   ============================================================================= */
.form-control,
.form-select {
  border-radius: var(--portal-border-radius);
  padding: 0.625rem 0.875rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--portal-primary);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.form-label {
  font-weight: 500;
  margin-bottom: 0.375rem;
  font-size: 0.9rem;
}

.form-text {
  font-size: 0.8rem;
}

/* =============================================================================
   Buttons
   ============================================================================= */
.btn {
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--portal-border-radius);
  transition: all 0.15s ease-in-out;
}

.btn-primary {
  background-color: var(--portal-primary);
  border-color: var(--portal-primary);
}

.btn-primary:hover {
  background-color: var(--portal-primary-dark);
  border-color: var(--portal-primary-dark);
}

.btn i {
  font-size: 0.9rem;
}

/* Loading state for buttons */
.btn .spinner-border {
  width: 1rem;
  height: 1rem;
  margin-left: 0.5rem;
}

.btn.loading .btn-text {
  opacity: 0.7;
}

/* =============================================================================
   Alerts & Notifications
   ============================================================================= */
.alert {
  border-radius: var(--portal-border-radius);
  border: none;
  font-size: 0.9rem;
}

/* Toast notifications */
.toast {
  border-radius: var(--portal-border-radius);
}

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

.toast-error {
  background-color: var(--portal-danger);
  color: white;
}

/* =============================================================================
   Loading States
   ============================================================================= */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--portal-border-radius);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* =============================================================================
   Responsive Adjustments
   ============================================================================= */
@media (max-width: 768px) {
  .portal-auth-container {
    padding: 1rem;
    min-height: calc(100vh - 60px);
  }

  .portal-auth-card .card-body {
    padding: 1.5rem !important;
  }

  .table-responsive {
    font-size: 0.875rem;
  }

  .navbar-brand img {
    max-height: 32px;
  }
}

@media (max-width: 576px) {
  .card-header h5 {
    font-size: 1rem;
  }

  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* =============================================================================
   Utility Classes
   ============================================================================= */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.min-h-100 {
  min-height: 100vh;
}

.cursor-pointer {
  cursor: pointer;
}

/* Hide elements initially when page loads */
.portal-hidden {
  display: none !important;
}

/* Fade in animation */
.fade-in {
  animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* =============================================================================
   Form Rendering (for form-fill page)
   ============================================================================= */
.form-section {
  background: var(--portal-card-bg);
  border-radius: var(--portal-border-radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--portal-shadow-sm);
}

.form-section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--portal-primary);
}

.form-section-description {
  color: var(--portal-secondary);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Fieldset repeater */
.fieldset-repeater-item {
  background: var(--portal-light);
  border: 1px solid var(--portal-border-color);
  border-radius: var(--portal-border-radius);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.fieldset-repeater-item .remove-item-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}

/* Form progress indicator */
.form-progress {
  display: flex;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.form-progress-step {
  flex: 1;
  text-align: center;
  position: relative;
}

.form-progress-step::before {
  content: '';
  position: absolute;
  top: 14px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--portal-border-color);
  z-index: 0;
}

.form-progress-step:first-child::before {
  left: 50%;
}

.form-progress-step:last-child::before {
  right: 50%;
}

.form-progress-step .step-number {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--portal-light);
  border: 2px solid var(--portal-border-color);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
  position: relative;
  z-index: 1;
}

.form-progress-step.active .step-number {
  background: var(--portal-primary);
  border-color: var(--portal-primary);
  color: white;
}

.form-progress-step.completed .step-number {
  background: var(--portal-success);
  border-color: var(--portal-success);
  color: white;
}

.form-progress-step .step-label {
  display: block;
  margin-top: 0.5rem;
  font-size: 0.75rem;
  color: var(--portal-secondary);
}

/* =============================================================================
   Submission/Policy View Page
   ============================================================================= */

/* Page container */
.submission-view-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Two-column layout - Documents sticky on left */
.submission-view-container .col-lg-5 {
  position: sticky;
  top: 1rem;
  align-self: flex-start;
}

/* Make info-card fill height in documents column */
.submission-view-container .col-lg-5 .info-card {
  min-height: 400px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
}

/* Documents content scrollable */
#documents-content {
  max-height: calc(100vh - 10rem);
  overflow-y: auto;
}

/* Documents Accordion Styles */
#documents-accordion {
  border-radius: 8px;
  overflow: hidden;
}

#documents-accordion .accordion-item {
  border: 1px solid #e2e8f0;
  margin-bottom: 0.5rem;
  border-radius: 8px !important;
  overflow: hidden;
}

#documents-accordion .accordion-item:last-child {
  margin-bottom: 0;
}

#documents-accordion .accordion-button {
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  background-color: #f8fafc;
  color: #334155;
}

#documents-accordion .accordion-button:not(.collapsed) {
  background-color: #f1f5f9;
  color: #1e293b;
  box-shadow: none;
}

#documents-accordion .accordion-button:focus {
  box-shadow: none;
  border-color: transparent;
}

#documents-accordion .accordion-button::after {
  width: 1rem;
  height: 1rem;
  background-size: 1rem;
}

#documents-accordion .folder-name {
  flex-grow: 1;
}

#documents-accordion .badge {
  font-size: 0.7rem;
  font-weight: 500;
}

#documents-accordion .list-group-item {
  border-left: none;
  border-right: none;
  padding: 0.625rem 1rem;
}

#documents-accordion .list-group-item:hover {
  background-color: #f8fafc;
}

#documents-accordion .document-name {
  font-weight: 500;
  font-size: 0.875rem;
  color: #334155;
}

#documents-accordion .min-width-0 {
  min-width: 0;
}

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--portal-secondary);
  text-decoration: none;
  font-weight: 500;
  margin-bottom: 1.5rem;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--portal-primary);
}

/* Page header */
.submission-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.submission-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--portal-dark);
  margin-bottom: 0;
}

/* Summary Card (Premium Display) */
.summary-card {
  background: linear-gradient(135deg, #1e3a5f 0%, #2c5282 100%);
  color: white;
  border-radius: 16px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(30, 58, 95, 0.3);
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.summary-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.summary-label {
  font-size: 0.8rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-value {
  font-size: 1rem;
  font-weight: 500;
}

.control-number {
  font-size: 1.5rem;
  font-weight: 700;
}

.premium-display {
  text-align: center;
  padding: 1.5rem 0;
  border-top: 1px solid rgba(255,255,255,0.2);
  border-bottom: 1px solid rgba(255,255,255,0.2);
  margin-bottom: 1.5rem;
}

.premium-label {
  font-size: 0.85rem;
  opacity: 0.8;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
}

.premium-amount {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
}

.premium-monthly {
  font-size: 1rem;
  opacity: 0.8;
  margin-top: 0.5rem;
}

.summary-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.9rem;
  opacity: 0.9;
}

/* Info Cards */
.info-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.info-card-header {
  padding: 1rem 1.5rem;
  background: linear-gradient(to right, #f8fafc, white);
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.info-card-header i {
  font-size: 1.25rem;
  color: var(--portal-primary);
}

.info-card-header h5 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
}

.info-card-body {
  padding: 1.5rem;
}

/* Data Grid */
.data-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.data-item {
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
}

.data-item.full-width {
  grid-column: 1 / -1;
}

.data-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.data-value {
  font-size: 0.95rem;
  font-weight: 500;
  color: #1e293b;
}

/* Premium Breakdown */
.breakdown-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid #e2e8f0;
}

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

.breakdown-item.total {
  font-weight: 700;
  font-size: 1.1rem;
  border-top: 2px solid #e2e8f0;
  margin-top: 0.5rem;
  padding-top: 1rem;
  border-bottom: none;
}

.breakdown-label {
  color: #64748b;
}

.breakdown-value {
  color: #1e293b;
  font-weight: 500;
}

.breakdown-item.total .breakdown-label,
.breakdown-item.total .breakdown-value {
  color: #1e293b;
}

/* Status Badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-draft {
  background: #e2e8f0;
  color: #64748b;
}

.status-submitted {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-rated {
  background: #dcfce7;
  color: #16a34a;
}

.status-error {
  background: #fee2e2;
  color: #dc2626;
}

.status-bound {
  background: #f3e8ff;
  color: #9333ea;
}

/* Actions Card */
.actions-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Loading State */
.submission-loading {
  text-align: center;
  padding: 4rem 2rem;
}

.submission-loading .spinner-border {
  width: 3rem;
  height: 3rem;
  color: var(--portal-primary);
}

/* Error State */
.submission-error {
  text-align: center;
  padding: 4rem 2rem;
}

.submission-error i {
  font-size: 4rem;
  color: var(--portal-danger);
  margin-bottom: 1rem;
}

/* Responsive - Tablet */
@media (max-width: 991px) {
  /* Remove sticky behavior on smaller screens */
  .submission-view-container .col-lg-5 {
    position: static;
  }

  .submission-view-container .col-lg-5 .info-card {
    min-height: auto;
    max-height: none;
  }

  #documents-content {
    max-height: none;
  }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
  .submission-view-container {
    padding: 1rem;
  }

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

  .summary-header {
    flex-direction: column;
  }

  .summary-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .premium-amount {
    font-size: 2.5rem;
  }

  .submission-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Print Styles */
@media print {
  .navbar,
  .back-link,
  .actions-card {
    display: none !important;
  }

  .submission-view-container {
    max-width: 100%;
    padding: 0;
  }

  .summary-card {
    background: #1e3a5f !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .info-card {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #e2e8f0;
  }

  .portal-footer {
    display: none !important;
  }
}

/* =============================================================================
   Portal Footer
   ============================================================================= */
.portal-footer {
  background: var(--portal-light);
  border-top: 1px solid var(--portal-border-color);
  padding: 1rem;
  text-align: center;
  font-size: 0.875rem;
  color: var(--portal-secondary);
  margin-top: auto;
}

.portal-footer a {
  color: var(--portal-primary);
  text-decoration: none;
}

.portal-footer a:hover {
  text-decoration: underline;
}

.portal-footer-content {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.portal-footer .legal-links {
  border-left: 1px solid var(--portal-border-color);
  padding-left: 1rem;
}

@media (max-width: 576px) {
  .portal-footer-content {
    flex-direction: column;
    gap: 0.5rem;
  }

  .portal-footer .legal-links {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid var(--portal-border-color);
    padding-top: 0.5rem;
  }
}
