@import "./common.css";
@import "./table.css";

.header-profiles {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    width: auto;
    margin-left: 0;
    margin-right: 0;
    padding: 0;
    box-sizing: border-box;
}

.filters-container {
    margin-bottom: 20px;
    background-color: #f9f9f9;
    border-radius: 5px;
    padding: 15px;
}

.filter-header {
    display: flex;
    width: 100%;
    gap: 8px;
}

.filter-cell {
    flex: 1;
    min-width: 110px;
}

.filter-cell input {
    width: 100%;
    font-size: 12px;
    margin-bottom: 5px;
}

.filter-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e0e0e0;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    font-size: 12px;
    margin-bottom: 5px;
    color: #666;
}

.filter-group input, .filter-group select {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 15px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

button {
    padding: 8px 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

button.secondary {
    background-color: #95a5a6;
}

button.secondary:hover {
    background-color: #7f8c8d;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    font-size: 14px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

th {
    background-color: #f2f2f2;
    position: relative;
    cursor: pointer;
}

th:hover {
    background-color: #e9e9e9;
}

th::after {
    content: "";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
}

th.sort-asc::after {
    content: "▲";
    font-size: 10px;
}

th.sort-desc::after {
    content: "▼";
    font-size: 10px;
}

tr:hover {
    background-color: #f5f5f5;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.pagination button {
    padding: 5px 10px;
    min-width: 30px;
}

.pagination button.active {
    background-color: #2c3e50;
}

.pagination button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100px;
}

.loading::after {
    content: "Loading...";
    font-size: 18px;
    color: #666;
}

.pubkey-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.numeric-cell {
    text-align: right;
}

.status-message {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
}

.status-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.status-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.tooltip {
    position: relative;
    display: inline-block;
    cursor: help;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 200px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -100px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

.pubkey-link {
    text-decoration: none;
    color: #337ab7;
}

.pubkey-link:hover {
    color: #23527c;
}

/* Profile count information */
.profile-counts {
    background-color: #f9f9f9;
    padding: 10px 15px;
    margin: 10px 0;
    border-radius: 4px;
    border-left: 4px solid #b234bd;
    font-size: 14px;
    color: #666;
}

.profile-counts #filteredCount,
.profile-counts #totalCount {
    font-weight: bold;
    color: #b234bd;
}

/* Table styles */
#mainProfilesTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background-color: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Table header styles */
#mainProfilesTable thead th {
    position: relative;
    padding: 10px;
    background-color: #f7f7f7;
    border-bottom: 2px solid #ddd;
    text-align: left;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

#mainProfilesTable thead th:hover {
    background-color: #f0f0f0;
}

/* Table filter row styles */
#mainProfilesTable .filter-row th {
    padding: 5px;
    background-color: #f0f0f0;
    border-bottom: 1px solid #ddd;
    cursor: default;
}

#mainProfilesTable .filter-row th:hover {
    background-color: #f0f0f0;
}

/* Table filter input styles */
.table-filter {
    width: 100%;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
}

.filter-inputs {
    display: flex;
    gap: 4px;
}

.small-input {
    width: calc(50% - 2px);
    min-width: 40px;
}

.filter-inputs-vertical {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Optional: make sure min/max inputs don't get too wide on small screens */
@media (max-width: 700px) {
  .filter-inputs-vertical input {
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }
}

/* Actions container */
.actions-container {
    margin: 10px 0;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 4px;
    display: flex;
    justify-content: flex-end;
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Sort indicator styles */

/* Table body cells */
#mainProfilesTable tbody td {
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
    vertical-align: middle;
}

/* Profile picture column */
.profile-pic-col {
    width: 40px;
    text-align: center;
}

.profile-pic-cell {
    text-align: center;
}

/* Profile picture link */
.profile-pic-link {
    display: inline-block;
    text-decoration: none;
    cursor: pointer;
    border-radius: 50%;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.profile-pic-link:hover {
    transform: scale(1.1);
    box-shadow: 0 0 5px rgba(178, 52, 189, 0.5);
}

.profile-pic-link:active {
    transform: scale(0.95);
}

/* Profile picture styling */
.profile-pic-cell img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    background-color: #f0f0f0;
    border: 1px solid #ddd;
}

/* Default profile picture placeholder */
.default-profile-pic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: #b234bd;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Pubkey cell */
.pubkey-cell {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Pic and Pubkey column width constraints for compact table view (force fixed width, even if only 1 or 2 columns) */
#mainProfilesTable.compact-table {
    table-layout: fixed !important;
    width: 100% !important;
    max-width: 100vw;
}
#mainProfilesTable.compact-table tr {
    width: 100%;
}
#mainProfilesTable.compact-table td.profile-pic-cell {
    width: 44px !important;
    min-width: 44px !important;
    max-width: 44px !important;
    box-sizing: border-box;
    overflow: hidden;
    padding-left: 4px;
    padding-right: 4px;
}
#mainProfilesTable.compact-table td:not(.profile-pic-cell) {
    width: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

@media (max-width: 900px) {
  #mainProfilesTable.compact-table td.profile-pic-cell {
      width: 44px !important;
      min-width: 44px !important;
      max-width: 44px !important;
      flex: 0 0 44px !important;
      padding-left: 4px;
      padding-right: 4px;
      box-sizing: border-box;
      overflow: hidden;
  }
}

@media (max-width: 900px) {
    .container {
        padding: 0 2vw;
        max-width: 100vw;
        box-sizing: border-box;
    }
    table, thead, tbody, th, td, tr {
        width: 100%;
        box-sizing: border-box;
    }
    /* Only switch to card view if not .compact-table */
    #mainProfilesTable:not(.compact-table) {
        display: block;
    }
    #mainProfilesTable:not(.compact-table) thead,
    #mainProfilesTable:not(.compact-table) tr,
    #mainProfilesTable:not(.compact-table) td,
    #mainProfilesTable:not(.compact-table) th,
    #mainProfilesTable:not(.compact-table) tbody {
        display: block;
    }
    #mainProfilesTable:not(.compact-table) {
        width: 100vw;
        min-width: unset;
        max-width: 100vw;
        margin-left: -2vw;
        margin-right: -2vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    #mainProfilesTable:not(.compact-table) thead {
        display: none;
    }
    #mainProfilesTable:not(.compact-table) tr {
        margin-bottom: 18px;
        border-radius: 6px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.05);
        background: #fff;
        padding: 10px 0;
        width: 100%;
        box-sizing: border-box;
    }
    #mainProfilesTable:not(.compact-table) td {
        display: flex;
        align-items: center;
        padding: 10px 6px;
        border: none;
        border-bottom: 1px solid #f0f0f0;
        position: relative;
        min-height: 38px;
        font-size: 15px;
        width: 100%;
        box-sizing: border-box;
        word-break: break-word;
    }
    #mainProfilesTable:not(.compact-table) td:last-child {
        border-bottom: none;
    }
    #mainProfilesTable:not(.compact-table) td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #666;
        min-width: 120px;
        margin-right: 12px;
        flex-shrink: 0;
        font-size: 13px;
        width: 120px;
        box-sizing: border-box;
    }
    #mainProfilesTable.compact-table td.pubkey-cell {
        max-width: 110px;
        min-width: 60px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 0 0 auto;
    }
    #mainProfilesTable.compact-table td:not(.profile-pic-cell):not(.pubkey-cell) {
        min-width: 0;
        max-width: 100%;
        flex: 1 1 0;
        white-space: normal;
    }
}
@media (max-width: 600px) {
    .header-profiles {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .container {
        padding: 0 1vw;
        max-width: 100vw;
        box-sizing: border-box;
    }
    #mainProfilesTable:not(.compact-table) {
        width: 100vw;
        max-width: 100vw;
        margin-left: -1vw;
        margin-right: -1vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    #mainProfilesTable:not(.compact-table) td {
        font-size: 13px;
        padding: 8px 4px;
        width: 100%;
        box-sizing: border-box;
    }
    #mainProfilesTable:not(.compact-table) td::before {
        min-width: 90px;
        font-size: 12px;
        width: 90px;
        box-sizing: border-box;
    }
}

/* Center report-type-selector on desktop, full width on mobile */
.header-profiles {
    width: auto;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
}

@media (max-width: 700px) {
  .header-profiles {
    width: auto;
    margin-left: -3vw;
    margin-right: -3vw;
    padding: 0;
    box-sizing: border-box;
  }
  .report-type-selector {
    max-width: 100vw;
    width: 100vw;
    margin-left: 0;
    margin-right: 0;
    padding-left: 3vw;
    padding-right: 3vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }
}
.report-type-selector {
    margin: 20px 0 30px 0;
    display: flex;
    align-items: center;
    gap: 18px;
    background: #f7f3ff;
    border: 2px solid #a58fff;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(122, 76, 255, 0.06);
    padding: 18px 22px;
    font-size: 1.18em;
    font-weight: 600;
    max-width: 510px;
    width: 100%;
    flex-wrap: wrap;
}

.report-type-selector label {
    font-size: 1.13em;
    color: #5a2bb6;
    letter-spacing: 0.5px;
    margin-right: 8px;
    font-weight: 700;
}

.report-type-selector select {
    font-size: 1.23em;
    font-weight: 700;
    padding: 9px 16px;
    background: #fff;
    border: 2px solid #a58fff;
    border-radius: 7px;
    color: #5a2bb6;
    box-shadow: 0 1px 3px rgba(122,76,255,0.06);
    outline: none;
    transition: border-color 0.2s;
    min-width: 120px;
    max-width: 210px;
}

.report-type-selector select:focus {
    border-color: #7a4cff;
}

@media (max-width: 700px) {
  .header-profiles {
    justify-content: stretch;
    width: auto;
    margin-left: -3vw;
    margin-right: -3vw;
    padding-left: 0;
    padding-right: 0;
    box-sizing: border-box;
  }
  .report-type-selector {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 3vw 14px 3vw;
    font-size: 1em;
    max-width: 100vw;
    width: 100vw;
    border-radius: 10px;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
    overflow-x: hidden;
  }
  .report-type-selector label {
    margin-bottom: 3px;
    margin-right: 0;
    font-size: 0.98em;
    color: #6d5c8d;
    font-weight: 600;
    letter-spacing: 0.2px;
  }
  .report-type-selector select {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    font-size: 1.28em;
    font-weight: 700;
    padding: 10px 16px;
    box-sizing: border-box;
    margin: 0 auto;
    background: #fff;
    color: #5a2bb6;
    border: 2px solid #a58fff;
    border-radius: 7px;
    box-shadow: 0 1px 3px rgba(122,76,255,0.06);
  }
}

/* Column panel controls styling */
.column-panel-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
#columnSettingsBtn {
    font-size: 1.06em;
    padding: 4px 4px;
    min-width: 32px;
    background-color: #95a5a6;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}
#columnSettingsBtn:hover {
    background-color: #7a7d7d;
}
.column-settings-panel {
    background: #f9f9f9;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    padding: 18px 18px 10px 18px;
    margin-bottom: 10px;
    margin-top: 0;
    border: 1px solid #e0e0e0;
    max-width: 420px;
}
#columnToggles label {
    font-size: 1em;
    margin-bottom: 7px;
    color: #444;
    display: flex;
    align-items: center;
    gap: 8px;
}
#columnToggles input[type='checkbox'] {
    margin-right: 7px;
}
#resetColumnDefaultsBtn {
    margin-top: 10px;
    background-color: #95a5a6;
    color: #fff;
}
#resetColumnDefaultsBtn:hover {
    background-color: #7a7d7d;
}

.panel {
    background: #f8f8fa;
    border: 1.2px solid #e3e3ee;
    border-radius: 7px;
    padding: 13px 18px 13px 18px;
    box-shadow: 0 1px 4px rgba(120,120,160,0.04);
    margin-bottom: 10px;
    font-size: 1.02em;
    color: #2d2d38;
}

/* Less prominent styling for Columns button in results row */
.columns-btn {
    background: #f7f3ff !important;
    color: #7a4cff !important;
    border: 1.5px solid #a58fff !important;
    font-size: 0.98em !important;
    padding: 7px 22px 7px 12px !important;
    box-shadow: none !important;
    font-weight: 500 !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    transition: background 0.2s;
}
.columns-btn svg {
    margin-right: 2px;
}
.columns-btn:hover {
    background: #ede7fa !important;
    color: #5a2bb6 !important;
    border-color: #7a4cff !important;
}
@media (max-width: 700px) {
  .results-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .columns-btn {
    width: auto !important;
    min-width: 90px;
    max-width: 180px;
    align-self: flex-start;
    font-size: 1em !important;
    padding: 9px 14px 9px 14px !important;
    margin-top: 2px;
    margin-bottom: 8px !important;
  }
}

/* Improve spacing and placement of column settings panel on mobile */
@media (max-width: 700px) {
  #columnSettingsPanel.column-settings-panel {
    position: static !important;
    margin-top: 10px !important;
    margin-bottom: 16px !important;
    width: 96vw !important;
    left: unset !important;
    right: unset !important;
    max-width: 98vw !important;
    box-sizing: border-box;
    z-index: 100;
  }
  .results-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .columns-btn {
    margin-bottom: 8px !important;
  }
}

/* When panel is open, scroll it into view below the button */
@media (max-width: 700px) {
  .columns-btn:focus + #columnSettingsPanel,
  .columns-btn:active + #columnSettingsPanel,
  #columnSettingsPanel[style*="display: block"] {
    scroll-margin-top: 14px;
  }
}

/* Compact table styles */
.compact-table th, .compact-table td {
  padding-top: 8px;
  padding-bottom: 8px;
  font-size: 1.05em;
}

.compact-table tr {
  border-bottom: 1px solid #e1e1e1;
}

@media (max-width: 700px) {
  .compact-table th, .compact-table td {
    padding-left: 5px;
    padding-right: 5px;
    font-size: 1.12em;
  }
  .compact-table {
    table-layout: auto;
    word-break: break-word;
  }
}

@media (max-width: 600px) {
    .header-profiles {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    .container {
        padding: 0 1vw;
        max-width: 100vw;
        box-sizing: border-box;
    }
    #mainProfilesTable:not(.compact-table) {
        width: 100vw;
        max-width: 100vw;
        margin-left: -1vw;
        margin-right: -1vw;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    #mainProfilesTable:not(.compact-table) td {
        font-size: 13px;
        padding: 8px 4px;
        width: 100%;
        box-sizing: border-box;
    }
    #mainProfilesTable:not(.compact-table) td::before {
        min-width: 90px;
        font-size: 12px;
        width: 90px;
        box-sizing: border-box;
    }
}

/* Subtle distinction for "bad" vs. "good" behaviour columns */
#mainProfilesTable th.bad-col, #mainProfilesTable td.bad-col {
    background: rgba(255, 80, 80, 0.06);
    color: #b14d4d;
    border-right: 1px solid #f3d1d1;
    font-weight: 600;
}
#mainProfilesTable th.good-col, #mainProfilesTable td.good-col {
    background: rgba(90, 210, 120, 0.07);
    color: #388e3c;
    border-right: 1px solid #b8eacb;
    font-weight: 600;
}
#mainProfilesTable th.good-col:last-child, #mainProfilesTable td.good-col:last-child {
    border-right: none;
}
@media (max-width: 900px) {
  #mainProfilesTable:not(.compact-table) td.bad-col {
    background: rgba(255, 80, 80, 0.035);
    color: #b14d4d;
  }
  #mainProfilesTable:not(.compact-table) td.good-col {
    background: rgba(90, 210, 120, 0.04);
    color: #388e3c;
  }
}
