/* Recs Club Design System */

/* ===================
   PRIMITIVE TOKENS
   =================== */

:root {
    /* Grey Scale */
    --grey-50: #fafafa;
    --grey-100: #f5f5f5;
    --grey-200: #eeeeee;
    --grey-300: #e0e0e0;
    --grey-400: #bdbdbd;
    --grey-500: #9e9e9e;
    --grey-600: #757575;
    --grey-700: #616161;
    --grey-800: #424242;
    --grey-900: #212121;

    /* Blue Scale (Primary) */
    --blue-50: #e3f2fd;
    --blue-100: #bbdefb;
    --blue-200: #90caf9;
    --blue-300: #64b5f6;
    --blue-400: #42a5f5;
    --blue-500: #2196f3;
    --blue-600: #1e88e5;
    --blue-700: #1976d2;
    --blue-800: #1565c0;
    --blue-900: #0d47a1;

    /* Status Colors */
    --green-100: #d4edda;
    --green-700: #155724;
    --green-border: #28a745;
    --yellow-100: #fff3cd;
    --yellow-700: #856404;
    --yellow-border: #ffc107;
    --red-100: #f8d7da;
    --red-700: #721c24;
    --red-border: #dc3545;

    /* Base Colors */
    --white: #ffffff;
    --black: #000000;

    /* Spacing Scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Border Radius */
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;
    --radius-xl: 12px;
    --radius-full: 9999px;

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;

    /* Font Weights */
    --font-normal: 400;
    --font-medium: 500;
    --font-semibold: 600;
    --font-bold: 700;

    /* Line Heights */
    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.15);

    /* ===================
       SEMANTIC TOKENS
       =================== */

    /* Background Colors */
    --color-background: var(--grey-100);
    --color-surface: var(--white);
    --color-surface-hover: var(--grey-50);

    /* Text Colors */
    --color-text-primary: var(--grey-900);
    --color-text-secondary: var(--grey-600);
    --color-text-muted: var(--grey-500);
    --color-text-inverse: var(--white);

    /* Border Colors */
    --color-border: var(--grey-300);
    --color-border-light: var(--grey-200);

    /* Primary Colors */
    --color-primary: var(--blue-700);
    --color-primary-hover: var(--blue-800);
    --color-primary-light: var(--blue-50);

    /* Status Colors (Semantic) */
    --color-success-bg: var(--green-100);
    --color-success-text: var(--green-700);
    --color-success-border: var(--green-border);
    --color-warning-bg: var(--yellow-100);
    --color-warning-text: var(--yellow-700);
    --color-warning-border: var(--yellow-border);
    --color-error-bg: var(--red-100);
    --color-error-text: var(--red-700);
    --color-error-border: var(--red-border);

    /* Layout */
    --sidebar-width: 320px;
    --content-max-width: 800px;

    /* Component-specific */
    --input-border-radius: var(--radius-md);
    --button-border-radius: var(--radius-md);
    --card-border-radius: var(--radius-lg);
}

/* ===================
   BASE STYLES
   =================== */

body {
    font-family: 'Noto Sans Hebrew', sans-serif;
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    background: var(--color-background);
    color: var(--color-text-primary);
    margin: 0;
    padding: 0;
}

h1, h2 {
    margin-top: 0;
}

/* ===================
   APP LAYOUT
   =================== */

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    padding: var(--space-6);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-top {
    flex: 1;
}

.sidebar-bottom {
    margin-top: auto;
}

.sidebar-title {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-8);
    color: var(--color-text-primary);
}

/* Sidebar cards (Admin, Profile, Impersonation) */
.sidebar-card {
    padding: var(--space-4);
    background: var(--color-background);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
}

.sidebar-card:last-child {
    margin-bottom: 0;
}

.sidebar-card--warning {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
}

.sidebar-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-card-header a:first-child {
    font-weight: var(--font-medium);
    text-decoration: none;
    color: var(--color-text-primary);
}

.sidebar-card-header a:first-child:hover {
    text-decoration: underline;
}

.sidebar-card-header a:first-child.active {
    color: var(--color-primary);
}

.sidebar-card-content {
    font-weight: var(--font-medium);
    font-size: var(--text-sm);
}

.sidebar-card-link,
.sidebar-card-links a {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

.sidebar-card-links {
    display: flex;
    gap: var(--space-4);
    margin-top: var(--space-2);
}

/* Icon button styling */
.sidebar-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
}

.sidebar-icon:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-primary);
}

/* Material Symbols - prevent layout shift */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    font-size: 20px;
    width: 20px;
    height: 20px;
    display: inline-block;
    opacity: 0;
    transition: opacity 0.2s;
}

.fonts-loaded .material-symbols-outlined {
    opacity: 1;
}

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li {
    margin-bottom: var(--space-2);
}

.sidebar-nav a {
    display: block;
    padding: var(--space-2) var(--space-4);
    color: var(--color-text-secondary);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-size: var(--text-base);
}

.sidebar-nav a:hover {
    background: var(--color-background);
    color: var(--color-text-primary);
}

.sidebar-nav a.active {
    background: var(--color-primary);
    color: var(--color-text-inverse);
}

.layout-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--space-8);
    background: var(--color-background);
    min-height: 100vh;
}

/* Login page (no sidebar) */
.page-login {
    max-width: 400px;
    margin: var(--space-12) auto;
    padding: var(--space-8);
    background: var(--color-surface);
    border-radius: var(--card-border-radius);
    box-shadow: var(--shadow-md);
}

.page-login h1 {
    font-size: var(--text-2xl);
    font-weight: var(--font-bold);
    margin-bottom: var(--space-6);
}

/* Two-column dashboard layout */
.dashboard {
    display: flex;
    gap: 20px;
}

.my-recs {
    flex: 2;
}

.add-recs {
    flex: 1;
}

/* Basic form styling */
form {
    margin: 0;
}

label {
    display: block;
    margin-bottom: 5px;
}

input[type="text"],
input[type="password"],
input[type="url"] {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
    border: 1px solid #ccc;
}

button {
    padding: 8px 16px;
    cursor: pointer;
}

/* Error/success messages */
.error {
    color: red;
    margin-bottom: 10px;
}

.success {
    color: green;
    margin-bottom: 10px;
}

/* Recs list */
.rec-list,
.recs-list {
    list-style: none;
    padding: 0;
}

.rec-list li,
.recs-list li {
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.rec-list a,
.recs-list a {
    word-break: break-all;
}

.rec-attribution {
    color: #666;
}

/* Admin tables */
.table {
    width: 100%;
    margin-bottom: 20px;
    border: 1px solid #ddd;
}

.table th,
.table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.table th {
    background: #f5f5f5;
    font-weight: 500;
}

.table tr:hover {
    background: #fafafa;
}

/* Form styling */
.form {
    margin: 0;
}

.form-row {
    margin-bottom: 15px;
}

.form-value {
    font-weight: 500;
}

.form-hint {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
}

/* Profile page */
.profile {
    max-width: 600px;
}

.profile-sections {
    max-width: 600px;
}

.profile-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.profile-section:last-child {
    border-bottom: none;
}

.profile-form .form-row {
    margin-bottom: 15px;
}

.profile-form .readonly-value {
    font-weight: 500;
}

.profile-form .help-text {
    display: block;
    color: #666;
    font-size: 0.9em;
    margin-top: 5px;
}

.profile-form label input[type="checkbox"] {
    margin-right: 8px;
}

/* User lists (following, followers, blocked) */
.user-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.user-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

.user-list li:last-child {
    border-bottom: none;
}

.user-name {
    font-weight: 500;
}

.username-hint,
.user-handle {
    font-weight: normal;
    color: #666;
    font-size: 0.9em;
}

.user-actions {
    display: flex;
    gap: 8px;
}

.inline-form {
    display: inline;
    margin: 0;
}

.empty-list {
    color: #666;
    font-style: italic;
}

/* Button base styles */
.btn {
    padding: 4px 12px;
    font-size: 0.9em;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    border-radius: var(--radius-md);
}

.btn:hover {
    background: #f5f5f5;
}

.btn--success {
    border-color: #28a745;
    color: #28a745;
}

.btn--success:hover {
    background: #28a745;
    color: #fff;
}

.btn--muted {
    border-color: #6c757d;
    color: #6c757d;
}

.btn--muted:hover {
    background: #6c757d;
    color: #fff;
}

.btn--danger {
    border-color: #dc3545;
    color: #dc3545;
}

.btn--danger:hover {
    background: #dc3545;
    color: #fff;
}

/* Small buttons for user actions (legacy) */
.btn-small {
    padding: 4px 12px;
    font-size: 0.9em;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
}

.btn-small:hover {
    background: #f5f5f5;
}

.btn-accept {
    border-color: #28a745;
    color: #28a745;
}

.btn-accept:hover {
    background: #28a745;
    color: #fff;
}

.btn-ignore {
    border-color: #6c757d;
    color: #6c757d;
}

.btn-ignore:hover {
    background: #6c757d;
    color: #fff;
}

.btn-unfollow {
    border-color: #dc3545;
    color: #dc3545;
}

.btn-unfollow:hover {
    background: #dc3545;
    color: #fff;
}

.btn-block {
    border-color: #dc3545;
    color: #dc3545;
}

.btn-block:hover {
    background: #dc3545;
    color: #fff;
}

.btn-unblock {
    border-color: #28a745;
    color: #28a745;
}

.btn-unblock:hover {
    background: #28a745;
    color: #fff;
}

/* Muted text for admin table */
.text-muted {
    color: #999;
    font-style: italic;
}

/* Rec item with social context */
.rec-item {
    padding: 12px 0;
}

.rec-url {
    margin-bottom: 4px;
}

.rec-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.85em;
}

.saved-by {
    color: #666;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 500;
}

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

.badge--first {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

/* ===================
   FAB & ADD REC SIDEBAR
   =================== */

/* FAB Button */
.fab {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border: none;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.fab:hover {
    background: var(--color-primary-hover);
}

.fab .material-symbols-outlined {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

/* Right Sidebar */
.add-rec-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    height: 100vh;
    background: var(--color-surface);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 200;
    padding: var(--space-6);
    overflow-y: auto;
}

.add-rec-sidebar.open {
    transform: translateX(0);
}

.add-rec-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
}

.add-rec-sidebar-header h2 {
    margin: 0;
}

.add-rec-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.add-rec-close:hover {
    color: var(--color-text-primary);
    background: var(--color-background);
}

/* Backdrop */
.add-rec-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 150;
}

.add-rec-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* ===================
   UNIFIED PANEL STACK SYSTEM
   =================== */

/* Shared backdrop for all panels */
.panel-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 150;
}

.panel-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* Base panel styles - all panels use this */
.panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: var(--color-surface);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease, right 0.3s ease;
    z-index: 200;
    padding: var(--space-6);
    overflow-y: auto;
}

.panel.open {
    transform: translateX(0);
}

/* Panel close button */
.panel-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-text-secondary);
    padding: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
}

.panel-close:hover {
    color: var(--color-text-primary);
    background: var(--color-background);
}

/* Thing panel content */
.thing-panel__content {
    padding-top: var(--space-4);
}

/* Recs list section (used in both feed cards and panel) */
.recs-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.recs-list__empty {
    color: var(--color-text-secondary);
}

/* ===================
   USER PANEL CONTENT STYLES
   =================== */

/* User panel content */
.user-panel-content {
    padding-top: var(--space-8);
}

.user-panel-header {
    margin-bottom: var(--space-4);
}

.user-panel-name {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    margin: 0 0 var(--space-1) 0;
}

.user-panel-handle {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

.user-panel-stats {
    margin-bottom: var(--space-6);
    color: var(--color-text-secondary);
}

.user-panel-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.user-panel-actions .btn {
    justify-content: center;
}

/* User panel following section */
.user-panel-following {
    margin-top: var(--space-6);
    padding-top: var(--space-6);
    border-top: 1px solid var(--color-border);
}

.user-panel-following-header {
    font-size: var(--text-base);
    font-weight: var(--font-medium);
    margin: 0 0 var(--space-3) 0;
    color: var(--color-text-secondary);
}

.user-panel-following-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.user-panel-following-item {
    padding: var(--space-2) var(--space-3);
    background: var(--color-background);
    border-radius: var(--radius-md);
}

.user-panel-following .empty-list {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    margin: 0;
}

/* ===================
   BLOCK CONFIRM PANEL CONTENT STYLES
   =================== */

/* Block confirm panel - center content vertically */
.panel[data-panel-id="block-confirm"] {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.block-confirm-content {
    text-align: center;
}

.block-confirm-message {
    font-size: var(--text-lg);
    margin-bottom: var(--space-6);
}

.block-confirm-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.block-confirm-actions .btn {
    justify-content: center;
}

/* ===================
   CLICKABLE USER LINKS
   =================== */

.user-link {
    color: inherit;
    text-decoration: none;
    cursor: pointer;
}

.user-link:hover {
    text-decoration: underline;
}

/* ===================
   RATING SLIDER
   =================== */

.rating-slider {
    margin-top: var(--space-2);
}

.rating-slider input[type="range"] {
    width: 100%;
    margin-bottom: var(--space-2);
    cursor: pointer;
    accent-color: var(--color-primary);
}

.rating-labels {
    display: flex;
    justify-content: space-between;
}

.rating-labels span {
    flex: 1;
    text-align: center;
    padding: var(--space-1) 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    cursor: pointer;
}

.rating-labels span:hover {
    color: var(--color-text-secondary);
}

.rating-labels span.active {
    color: var(--color-primary);
    font-weight: var(--font-semibold);
}

/* ===================
   BLURB TEXTAREA
   =================== */

textarea {
    width: 100%;
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    border-radius: var(--input-border-radius);
    font-family: inherit;
    font-size: var(--text-base);
    resize: vertical;
    min-height: 80px;
    box-sizing: border-box;
}

textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.blurb-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-1);
    font-size: var(--text-xs);
}

.blurb-counter {
    color: var(--color-text-muted);
}

.blurb-error {
    color: var(--color-error-text);
    opacity: 0;
    transition: opacity 0.15s;
}

.blurb-error.visible {
    opacity: 1;
}

/* ===================
   FEED COMPONENTS
   =================== */

/* Feed list container */
.feed-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

/* Thing card component - clickable container in feed */
.thing-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    background: var(--color-surface);
    cursor: pointer;
}

/* Thing header component - name, type chips, optional link */
.thing-header {
    margin-bottom: var(--space-3);
}

.thing-header__title {
    font-weight: 600;
}

/* Thing link component - smart link to open the thing URL */
.thing-link {
    display: inline-block;
    margin-top: var(--space-3);
    color: var(--color-link);
    text-decoration: none;
}

.thing-link:hover {
    text-decoration: underline;
}

/* Type chips - displays types as individual inline elements */
.type-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    margin-top: var(--space-2);
}

.type-chips__chip {
    display: inline-block;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--color-border);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

/* User rec component - a single user's recommendation */
.user-rec {
    padding: var(--space-3);
    background: var(--color-background);
    border-radius: var(--radius-md);
}

.user-rec__name {
    margin-bottom: var(--space-1);
}

.user-rec__name a {
    font-weight: var(--font-medium);
    color: var(--color-text-primary);
    text-decoration: none;
}

.user-rec__name a:hover {
    text-decoration: underline;
}

.user-rec__rating {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-1);
}

.user-rec__blurb {
    font-size: var(--text-sm);
    color: var(--color-text-primary);
    margin-bottom: var(--space-2);
    font-style: italic;
}

.user-rec__badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* Thing Stats - rating breakdown row */
.thing-stats {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-3);
}

.thing-stats__item {
    white-space: nowrap;
}

.thing-stats__separator {
    color: var(--color-text-tertiary);
}

/* My Rec - user's own rec display */
.my-rec {
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
}

.my-rec__rating {
    font-size: var(--text-sm);
}

.my-rec__blurb {
    font-size: var(--text-sm);
    font-style: italic;
    color: var(--color-text-secondary);
    margin-top: var(--space-1);
}

.my-rec__badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
}

/* First in network badge */
.badge--first-network {
    background: var(--color-success-bg);
    color: var(--color-success-text);
    border: 1px solid var(--color-success-border);
}
