/* ========================================
   PROFILE PAGE LAYOUT - CLEAN REWRITE
   ======================================== */

/* Main Layout Container */
.profile-sidebar-row {
    display: flex;
    gap: 20px;
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

#profile-container {
    flex: 1;
    min-width: 0;
    max-width: 800px; /* Match dreamer page width constraint */
    background: #ffffff;
    border: 2px solid #d0c7f0;
    padding: 20px;
    transition: opacity 0.3s ease;
}

#profile-container.loading {
    opacity: 0.5;
    pointer-events: none;
}

#profile-container.loaded {
    animation: fadeIn 0.4s ease;
}

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

#search-container {
    flex: 0 0 320px;
    min-width: 320px;
    max-width: 320px;
    background: #ffffff;
    border: 2px solid #d0c7f0;
    padding: 16px;
}

/* ========================================
   HEADER ROW - Identity + Meta Boxes
   ======================================== */

.profile-header-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: flex-start;
}

.profile-identity {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
    align-items: flex-start;
    margin-top: 5px;
}

.profile-picture {
    align-self: flex-start;
}

.profile-picture img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    border: 1.5px solid #d0c7f0;
    object-fit: cover;
    display: block;
}

.profile-name-server {
    width: 100%;
}

.profile-name h1 {
    margin: 0;
    font-size: 1.8rem;
    font-weight: 700;
    color: #372e42;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    display: flex;
    align-items: center;
    gap: 10px;
    word-wrap: break-word;
    line-height: 1.3;
}

.profile-name h1 a {
    color: inherit;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.profile-name img {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Meta Boxes (Handle + Souvenirs) */
.profile-meta-boxes {
    flex: 0 0 364px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.handle-box {
    background: white;
    border: 1.5px solid #d0c7f0;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.handle-box p {
    margin: 0;
    padding: 2px 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 0.9rem;
}

.data-label {
    min-width: 70px;
    font-weight: 700;
    color: #372e42;
    text-transform: lowercase;
    font-family: monospace;
    font-size: 0.85rem;
}

.data-value {
    color: #372e42;
    font-weight: 400;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-value a {
    color: #734ba1;
    text-decoration: none;
}

.data-value a:hover {
    text-decoration: underline;
}

.souvenirs-box-container {
    background: white;
    border: 1.5px solid #d0c7f0;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.souvenirs-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #5a4a7a;
    margin-bottom: 10px;
    text-align: center;
    font-family: monospace;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.souvenirs-grid-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.souvenirs-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}

.souvenir-item img {
    width: 36px;
    height: 36px;
    object-fit: contain;
    transition: all 0.2s ease;
    cursor: pointer;
}

.souvenir-item img:hover {
    transform: scale(1.15);
}

.souvenirs-empty {
    text-align: center;
    color: #999;
    font-size: 0.9rem;
    font-style: italic;
    padding: 10px;
}

/* ========================================
   INFO ROW - Bio + Stats
   ======================================== */

.profile-info-row {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.bio-box {
    flex: 1;
    background: white;
    border: 1.5px solid #d0c7f0;
    padding: 16px 18px;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #372e42;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 150px;
    text-align: left;
}

.bio-box:empty::before,
.bio-box:contains('No bio written yet.')::before {
    color: #999;
    font-style: italic;
}

.stats-box {
    flex: 0 0 168px;
    background: #f8f6ff;
    border: 1.5px solid #e8e6f5;
    padding: 16px;
}

.stats-box-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 6px;
    background: #ffffff;
    border-left: 2px solid #d0c7f0;
}

.stat-name {
    font-size: 0.7rem;
    color: #5a4a7a;
    font-weight: 600;
    font-family: monospace;
}

.stat-value {
    font-size: 0.8rem;
    color: #372e42;
    font-weight: 700;
    font-family: monospace;
}

.stat-divider {
    height: 1px;
    background: #e8e6f5;
    margin: 4px 0;
}

/* ========================================
   SPECTRUM SECTION
   ======================================== */

.spectrum-section {
    margin-bottom: 20px;
    max-width: fit-content; /* Don't stretch wider than content needs */
}

.spectrum-layout {
    display: flex;
    gap: 0; /* No gap - controls affix to graph */
    align-items: stretch; /* Match heights */
    justify-content: flex-start; /* Align items to the left */
    max-width: 100%; /* Prevent overflow */
}

.spectrum-graph-box {
    flex: 1 1 auto; /* Allow graph to shrink */
    max-width: 450px; /* Limit graph box width */
    background: #f8f6ff;
    border: 2px solid #d0c7f0; /* Match controls border */
    border-right: none; /* Remove right border to affix controls */
    padding: 16px;
    min-width: 0; /* Allow shrinking below content size */
}

#profileSpectrumCanvas {
    display: block;
    width: 100%; /* Make canvas responsive */
    height: auto;
    max-width: 400px;
    background: #faf7ff;
    border: 1px solid #e8e6f5;
}

.spectrum-controls-box {
    flex: 0 0 auto; /* Don't grow or shrink */
    width: 200px; /* Fixed width for controls */
    background: #f8f6ff; /* Match graph box background */
    border: 2px solid #d0c7f0; /* Add border to complete the box */
    padding: 16px; /* Match graph box padding */
    align-self: stretch; /* Match height of graph box */
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.spectrum-section-title {
    margin: 0 0 12px 0; /* Add bottom margin for spacing */
    font-size: 1rem;
    font-weight: 600;
    color: #734ba1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: monospace;
}

/* ========================================
   ADVENTURE/CANON BOX
   ======================================== */

.adventure-box {
    background: white;
    border: 2px solid #d0c7f0;
    padding: 16px;
}

.adventure-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #734ba1;
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: monospace;
}

.canon-log {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.log-entry {
    font-size: 0.85rem;
    margin: 0;
    padding: 2px 6px;
    text-align: left;
    font-family: monospace;
    margin-left: 8px;
    line-height: 1.2;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.log-entry span {
    flex: 1;
}

.log-entry code {
    font-size: 0.7rem;
    color: #ccc;
    cursor: pointer;
    margin-left: 8px;
    flex-shrink: 0;
}

.log-entry a {
    color: var(--canon-text-color, #5a4a7a);
    text-decoration: none;
}

.log-entry a:hover {
    color: var(--canon-link-hover-color, #734ba1);
}

.log-timestamp {
    font-size: 0.75rem;
    color: #999;
    font-family: monospace;
    margin-left: 8px;
}

/* Sidebar / Search Container Styles */
.search-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1.5px solid #e8e6f5;
}

.search-header img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}

.search-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #372e42;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    line-height: 24px;
    letter-spacing: 0.02em;
}

.dreamers-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 12px;
}

.autofill-container {
    display: flex;
    flex-direction: column;
}

.dreamer-item {
    padding: 8px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
    border: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.dreamer-item:nth-child(odd) {
    background: #f0f0f0;
}

.dreamer-item:nth-child(even) {
    background: #ffffff;
}

.dreamer-item:hover {
    background: #e8e6f5;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.search-area {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

#search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1.5px solid #d0c7f0;
    border-radius: 0;
    font-size: 0.9rem;
    color: #372e42;
    background: #faf7ff;
    transition: all 0.2s;
}

#search-input:focus {
    outline: none;
    border-color: #734ba1;
    background: white;
    box-shadow: 0 0 0 3px rgba(115, 75, 161, 0.1);
}

#refresh-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 0;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#refresh-button:hover {
    background: #f8f6ff;
}

#refresh-button img {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

#refresh-button:hover img {
    transform: rotate(180deg);
}

/* Kindred Panel */
.kindred-panel {
    background: #f8f6ff;
    border: 1.5px solid #e8e6f5;
    border-radius: 0;
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-shrink: 0;
}

.kindred-panel a {
    color: #734ba1;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
}

.kindred-panel a:hover {
    text-decoration: underline;
}

#kindred-panel {
    background: #f8f6ff;
    border: 1.5px solid #e8e6f5;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

#kindred-content {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

#kindred-content a {
    color: #734ba1;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#kindred-content a:hover {
    text-decoration: underline;
}

#kindred-content img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
}

#kindred-prev,
#kindred-next {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.3rem;
    color: #734ba1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
}

#kindred-prev:hover,
#kindred-next:hover {
    background: #e8e6f5;
    transform: scale(1.1);
}

/* Name Request Section */
.invitation-text {
    text-align: center;
    padding: 12px;
    background: #f8f6ff;
    border: 1.5px solid #e8e6f5;
    border-radius: 0;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.6;
    flex-shrink: 0;
}

.invitation-text a {
    color: #734ba1;
    font-weight: 600;
    text-decoration: none;
}

.invitation-text a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 1000px) {
    .profile-sidebar-row {
        flex-direction: column;
        padding: 16px;
    }
    
    #search-container {
        flex: 1;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        order: 2;
    }
    
    #profile-container {
        order: 1;
    }
    
    .profile-header-row {
        flex-direction: column;
    }
    
    .profile-meta-boxes {
        flex: 1;
        width: 100%;
    }
    
    .profile-info-row {
        flex-direction: column;
    }
    
    .stats-box {
        flex: 1;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .stats-box-content {
        max-width: 100%;
        overflow-x: auto;
    }
    
    .stat-row {
        min-width: 0;
        font-size: 0.85rem;
    }
    
    .spectrum-layout {
        flex-direction: column;
    }
    
    .spectrum-controls-box {
        max-width: 100%;
    }
}
