/* /js/usernotes/user-notes.css */

/* --- Custom Variables --- */
:root {
  --un-bg-solid: #141414; 
  --bg-main-hover: #1e1e1e;
  --bg-card: #1e1e1e;
  --text-main: #f5f5f4; /* stone-100 */
  --text-muted: #a8a29e; /* stone-400 */
  --border-color: #2e2e2e;
  --border-color-subtle: #2e2e2e;
  --accent: #f97316; /* orange-500 */
  --accent-hover: #ea580c; /* orange-600 */
}

/* --- Base Styles --- */
html, body {
    font-family: 'Inter', sans-serif;
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5 {
    font-family: 'Bebas Neue', sans-serif;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-main);
}

a {
    transition: color 0.2s ease-in-out;
}

/* --- Loader & Initial Page Visibility --- */
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--un-bg-solid);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.loader-spinner {
  border: 4px solid var(--border-color);
  border-top: 4px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.content-hidden {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease;
}

.content-visible {
    opacity: 1;
    visibility: visible;
}

/* --- Main Page Layout --- */
.notes-page-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1024px) {
    .notes-page-layout {
        grid-template-columns: 320px 1fr;
        align-items: start;
        gap: 1.5rem;
    }
    .composer-column {
        position: sticky;
        top: 5rem;
    }
    .page-title-header {
      display: none;
    }
}


/* --- Note Composer (Left Column) --- */
.page-title-header .page-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.5rem;
    margin: 0;
    line-height: 1;
}

.page-title-header .page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}


.composer-column {
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 0;
}

#note-composer-container {
    padding: 1rem;
    border: 1px solid var(--border-color-subtle);
    border-radius: 0.5rem;
    background-color: var(--bg-card);
}

@media (max-width: 1023.98px) {
    body { padding-bottom: 180px; }
    main {
        padding-bottom: 2rem;
    }
    .composer-column {
        position: fixed; bottom: 0; left: 0; right: 0;
        z-index: 50; background: var(--bg-card);
        border-top: 1px solid var(--border-color-subtle);
        box-shadow: 0 -4px 15px rgba(0,0,0,0.2);
        padding: 0;
    }
    #note-composer-container {
        border-radius: 0; border: none; max-width: 720px;
        margin: 0 auto; padding: 0.75rem;
    }
     #album-search-results {
        bottom: calc(100% + 0.5rem); top: auto;
        box-shadow: 0 -4px 15px rgba(0,0,0,0.1);
    }
}

/* --- Global Feed (Right Column) --- */
.feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin: 0;
}

.usernotes-sort-controls {
    display: flex;
    gap: 0.5rem;
    background-color: var(--un-bg-solid);
    padding: 0.25rem;
    border-radius: 9999px;
    border: 1px solid var(--border-color-subtle);
}

.usernotes-sort-controls button {
    background-color: transparent;
    color: var(--text-muted);
    border: none;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.usernotes-sort-controls button:hover {
    color: var(--text-main);
}

.usernotes-sort-controls button.active {
    background-color: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 0 0 1px var(--border-color-subtle);
}

.feed-layout {
    display: flex;
    flex-direction: column;
}

.usernotes-feed-list {
    display: flex;
    flex-direction: column;
    gap: 1rem; /* Increased gap for better separation */
}

/* --- FEED CARD --- */
.usernote-card {
    display: grid;
    grid-template-columns: 200px 40px 1fr; /* Fixed width for album column */
    gap: 0.75rem 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color-subtle);
    border-radius: 8px;
    align-items: start;
}

.note-album-column {
    grid-column: 1;
    grid-row: 1 / span 2; /* Span across two rows */
    align-self: stretch; /* Make column stretch to card height */
}

.usernote-avatar-wrap {
    grid-column: 2;
}

.usernote-body {
    grid-column: 3;
    min-width: 0;
}

.usernote-avatar {
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  object-fit: cover;
  border: 2px solid var(--border-color-subtle);
}

.usernote-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.usernote-name {
  font-weight: 700;
  color: var(--text-main);
}

.usernote-handle, .usernote-time {
  color: var(--text-muted);
  font-size: 0.825rem;
}

.feed-note-text {
  position: relative;
  overflow: hidden;
  line-height: 1.5;
  font-family: ui-serif, Georgia, "Times New Roman", Times, serif;
  font-size: 1rem;
  color: var(--text-main);
  word-wrap: break-word;
  transition: max-height 0.35s ease-in-out;
}
.feed-text-inner {
    white-space: pre-wrap;
    margin-bottom: 0.75rem;
}

.feed-note-text.collapsed {
  max-height: 10em;
}

.feed-note-text.collapsed::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 5em;
  background: linear-gradient(to top, var(--bg-card) 20%, transparent);
  pointer-events: none;
}
.feed-note-text.collapsed[data-action="toggle-text"] {
    cursor: pointer;
}

.usernote-picks {
    margin-top: 0.5rem;
}
.usernote-picks-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-right: 0.5rem;
    font-family: 'Inter', sans-serif;
    text-transform: none;
    letter-spacing: normal;
}
.usernote-pick-pill {
    display: inline-block;
    background-color: var(--bg-main-hover);
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    padding: 0.25rem 0.75rem;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    margin: 2px;
}

.usernote-footer {
  display: flex;
  justify-content: space-between; /* Space out rating and like */
  align-items: center;
  gap: 10px;
  margin-top: 0.75rem;
}
.usernote-like {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--border-color-subtle);
  border-radius: 9999px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
  transition: 0.15s ease;
}
.usernote-like:hover {
  background: var(--bg-main-hover);
  color: var(--text-main);
}
.usernote-like .thumb {
  width: 18px;
  height: 18px;
  fill: currentColor;
  opacity: 0.85;
  transition: 0.15s ease;
}
.usernote-like.liked {
  color: #f87171;
}
.usernote-like.liked .thumb {
    opacity: 1;
}
.usernote-like .like-count {
  font-variant-numeric: tabular-nums;
}

/* --- NEW Album Card Styles --- */
.note-album-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background-color: var(--un-bg-solid);
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    height: 100%;
}
.note-album-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    border-color: var(--accent);
}
.note-album-cover img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
    background-color: var(--border-color);
}
.note-album-details {
    padding: 0.75rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}
.note-album-title {
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.3;
    text-transform: none;
    letter-spacing: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.note-album-artist {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 0.25rem;
}
.note-album-meta {
    margin-top: auto;
    padding-top: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-muted);
}


@media (max-width: 768px) {
    .usernote-card {
        grid-template-columns: 40px 1fr; /* Avatar | Content */
        gap: 0.5rem 0.75rem;
    }
    .note-album-column {
        grid-column: 1 / -1; /* Span full width */
        grid-row: 1;
        margin-bottom: 0.5rem;
        align-self: auto;
    }
    .note-album-card {
        flex-direction: row; /* Horizontal layout */
        align-items: center;
        height: auto;
    }
    .note-album-cover {
        flex-shrink: 0;
        width: 80px;
        height: 80px;
    }
    .usernote-avatar-wrap {
        grid-row: 2; /* Position avatar below album */
        grid-column: 1;
    }
    .usernote-body {
        grid-row: 2; /* Position body below album */
        grid-column: 2;
    }
}


/* --- COMPOSER & SHARED STYLES --- */
.composer-login-prompt {
    padding: 2rem 1rem;
    text-align: center;
}
.composer-login-prompt p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}
.album-selector-wrapper {
    position: relative;
    margin-bottom: 1rem;
}
#album-search-input {
    width: 100%;
    height: 44px;
    background-color: var(--un-bg-solid);
    border: 1px solid var(--border-color-subtle);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    font-size: 0.95rem;
}
#album-search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-color-subtle);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.album-search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color-subtle);
}
.album-search-result-item:last-child {
    border-bottom: none;
}
.album-search-result-item:hover {
    background-color: var(--bg-main-hover);
}
.album-search-result-item img {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}
.album-search-result-item .album-info {
    min-width: 0;
    width: 100%;
}
.album-search-result-item .album-info p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.composer-placeholder {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    border: 2px dashed var(--border-color-subtle);
    border-radius: 8px;
}
.selected-album-display {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background-color: var(--un-bg-solid);
    border: 1px solid var(--border-color-subtle);
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 1rem;
}
.selected-album-display img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    flex-shrink: 0;
}
.selected-album-display .album-info {
    min-width: 0;
    width: 100%;
}
.selected-album-display .album-info p {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.selected-album-display:hover::after {
    content: 'Change';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    border-radius: 8px;
}
.usernote-textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    padding: 10px 12px;
    background: var(--un-bg-solid);
    color: var(--text-main);
    border: 1px solid var(--border-color-subtle);
    border-radius: 10px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.usernote-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(249,115,22,0.2);
}
.usernote-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.usernote-char-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.usernote-char-count.error {
    color: #ef4444;
    font-weight: 700;
}
.usernote-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.btn {
    font-size: 0.875rem;
    font-weight: 700;
    padding: 0.45rem 0.9rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: 0.15s ease;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
}
.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color-subtle);
}
.btn-secondary:hover:not(:disabled) {
    background: var(--bg-main-hover);
    color: var(--text-main);
}
.note-publish-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    color: var(--text-muted);
}
.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
}
.switch input {
    display: none;
}
.switch .slider {
    width: 42px;
    height: 24px;
    border-radius: 9999px;
    background: var(--un-bg-solid);
    border: 1px solid var(--border-color-subtle);
    position: relative;
    transition: background 0.2s, border-color 0.2s;
}
.switch .slider::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 9999px;
    background: var(--text-muted);
    transition: transform 0.2s, background 0.2s;
}
.switch input:checked + .slider {
    background: #22c55e1a;
    border-color: #22c55e66;
}
.switch input:checked + .slider::after {
    transform: translateX(18px);
    background: #22c55e;
}
.switch .switch-state {
    min-width: 54px;
    text-align: left;
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--text-main);
}
.sax-rating-small {
    display: flex;
    align-items: center;
    gap: 1px;
}
.sax-icon-small {
    width: 16px;
    height: 16px;
    background-color: var(--border-color-subtle);
    -webkit-mask: url('https://firebasestorage.googleapis.com/v0/b/controlled-freedom.firebasestorage.app/o/ratingcf.svg?alt=media&token=2a093301-51b1-42cc-9475-324ff3ed200d') no-repeat center;
    mask: url('https://firebasestorage.googleapis.com/v0/b/controlled-freedom.firebasestorage.app/o/ratingcf.svg?alt=media&token=2a093301-51b1-42cc-9475-324ff3ed200d') no-repeat center;
    mask-size: contain;
}
.sax-icon-small.active {
    background-color: var(--accent);
}
.sax-icon-small.half-active {
    background: linear-gradient(to right, var(--accent) 50%, var(--border-color-subtle) 50%);
}
.custom-scrollbar::-webkit-scrollbar {
    width: 8px;
}
.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
    background-color: var(--border-color-subtle);
    border-radius: 20px;
    border: 3px solid transparent;
    background-clip: content-box;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background-color: var(--text-muted);
}
#toast-host {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast-message {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 10px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.25s, transform 0.25s;
}
.toast-message.success {
    background: #16a34a;
    color: white;
}
.toast-message.error {
    background: #dc2626;
    color: white;
}

/* --- Image Modal --- */
#image-modal {
    transition: all 0.2s ease-in-out;
}
#image-modal.hidden {
    opacity: 0;
    pointer-events: none;
}
#image-modal:not(.hidden) {
    opacity: 1;
}
#close-modal-button {
    text-shadow: 0 0 5px rgba(0,0,0,0.5);
}
