/* Panel-profile specific styles */
.ip-profile {
  background: var(--ip-active);
  /* divider color for profile info table */
  --ip-divider: #dee2e6;
  padding: 18px;
  margin-bottom: 16px;
  border-radius: 10px;
  border: 1px solid #45546d;
  text-align: center;
  color: #fff;
}

.ip-profile img.ip-avatar {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  border: 4px solid var(--ip-hover);
  display: block;
  margin: 0 auto 10px;
  object-fit: cover;
}

.ip-profile--large {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 18px;
}

.ip-card--profile {
  padding: 18px;
}

.ip-profile-cards {
  display: flex !important;
  gap: 16px;
  align-items: flex-start;
}

.ip-card--main {
  flex: 1 1 420px;
  min-width: 300px;
}

.ip-card--extra {
  flex: 1 1 420px;
  min-width: 300px;
}

.ip-row {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

/* Styles for disabled fields */
.ip-input.disabled-field,
input[disabled],
select[disabled],
textarea[disabled],
input[readonly],
select[readonly],
textarea[readonly] {
  background-color: #f8f9fa !important;
  color: #6c757d !important;
  cursor: not-allowed;
  opacity: 0.8;
}

.ip-card--readonly-message {
  /* background-color: #e9ecef; */
  padding: 15px;
  border-radius: 6px;
  text-align: center;
  margin-top: 15px;
  border: 1px solid #dee2e6;
}

.ip-card--readonly-message p {
  margin: 0;
  color: #495057;
  font-weight: 500;
}

.ip-group {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ip-group label {
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ip-muted);
}

.ip-input {
  padding: 8px 10px;
  border: 1px solid #e6e6e6;
  border-radius: 6px;
  background: #fff;
}

.ip-input[type="date"] {
  padding: 8px;
}

.ip-input textarea {
  resize: vertical;
}

.ip-title {
  background-color: var(--ip-bg);
  padding: 8px 0;
  border-radius: 6px;
  font-size: 17px;
  margin-bottom: 16px;
  color: var(--ip-primary);
  font-weight: bold;
  border-right: solid 3px;
  padding-right: 4px;
}

input,
select,
textarea {
  border: 1px solid #e0e0e0 !important;
  border-radius: 6px !important;
}

.ip-panel--profile {
  flex: 1 1 auto;
  width: auto;
}

.ip-panel--profile .ip-card--profile {
  width: 100%;
}

@media (max-width: 600px) {
  /* Mobile: stack fields vertically */
  .ip-row {
    flex-direction: column;
  }
  .ip-group {
    flex: 1 1 100%;
    width: 100%;
  }
  .ip-group[style] {
    flex: 1 1 100%;
  }
  .ip-input {
    width: 100%;
    box-sizing: border-box;
  }
  .ip-profile-cards {
    flex-direction: column;
  }
}

@media (max-width: 1000px) {
  .ip-profile-cards {
    flex-direction: column;
    gap: 12px;
  }
}

/* Profile header: avatar + basic info */
.ip-profile-header {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 16px;
}

.ip-profile-header .ip-avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(0,0,0,0.06);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.ip-profile-basic {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ip-profile-basic .name {
  font-size: 18px;
  font-weight: 700;
  color: var(--ip-primary, #222);
}

.ip-profile-basic .meta {
  color: var(--ip-muted, #6c757d);
  font-size: 14px;
}

.ip-profile-info-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}
.ip-profile-info-table td {
  padding: 8px 6px;
  vertical-align: top;
  border-bottom: 1px solid var(--ip-divider) !important;
}

/* Ensure table has a visible bottom border and last row separators */
.ip-profile-info-table {
  border-collapse: collapse;
  border-bottom: 1px solid var(--ip-divider) !important;
}
.ip-profile-info-table tr td {
  border-bottom: 1px solid var(--ip-divider) !important;
}
.ip-profile-info-table td:first-child {
  color: #495057;
  width: 130px;
  font-weight: 600;
}

.ip-program-list {
  list-style: none;
  margin: 8px 0 0 0;
  padding: 0;
}
.ip-program-list li {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fafafa;
  margin-bottom: 6px;
  list-style: none;
}

.ip-program-list .title {
  color: #333;
  font-weight: 600;
  /* show full title inline, allow wrapping instead of ellipsis */
  display: inline;
  max-width: none;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
  overflow-wrap: anywhere;
}

.ip-btn--link-like {
  background: transparent;
  color: var(--ip-primary, #007cba);
  border: 1px solid transparent;
  padding: 6px 10px;
  font-weight: 600;
}

.ip-btn--small { padding: 6px 10px; font-size: 13px; }

@media (max-width: 700px) {
  .ip-profile-header { flex-direction: row; gap: 12px; }
}

/* Program categories layout: side-by-side on wide screens, stacked on small */
.ip-program-categories {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  /* Keep categories on single row when possible; allow shrinking to avoid overflow */
  flex-wrap: nowrap;
  overflow: hidden;
}
.ip-program-category {
  /* Use flexible thirds that can shrink when parent is narrow to avoid overflow */
  flex: 1 1 calc((100% - 16px) / 3);
  max-width: calc((100% - 16px) / 3);
  box-sizing: border-box;
  min-width: 0;
}

@media (max-width: 900px) {
  .ip-program-categories {
    flex-direction: column;
    /* Stack categories and allow them to expand vertically on small screens */
    flex-wrap: nowrap;
    overflow: visible;
  }
  .ip-program-category {
    /* Make each category take full width on mobile/tablet to ensure visibility */
    flex: 0 0 100%;
    max-width: 100%;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 8px;
  }

  /* Force visibility on small screens in case other rules hide or clip the categories */
  .ip-program-categories {
    display: block !important;
  }
  .ip-program-category {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
  }
  .ip-program-list {
    display: block !important;
  }
  .ip-program-list li {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  /* Force the profile grid to wrap and stack children vertically (override inline styles) */
  .ip-profile-grid {
    flex-wrap: wrap !important;
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* Ensure right column (programs) appears below left column */
  .ip-profile-left { order: 1 !important; }
  .ip-profile-right { order: 2 !important; }

  /* Small spacing for programs under the profile info */
  .ip-program-categories { margin-top: 12px !important; }
}

/* Profile grid left/right widths: 30% / 70% */
.ip-profile-grid {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.ip-profile-left {
  flex: 0 0 45%;
  max-width: 45%;
  min-width: 160px;
}
.ip-profile-right {
  /* flex: 0 0 55%; */
  max-width: 55%;
  min-width: 200px;
}

@media (max-width: 900px) {
  .ip-profile-left,
  .ip-profile-right {
    flex: 0 0 100%;
    max-width: 100%;
  }
}