/**
 * GTAW Furniture Catalog - Shared Base Styles
 * 
 * Contains CSS custom properties and shared component styles
 * used by both the public site (style.css) and admin panel (admin.css).
 * 
 * Include this file BEFORE style.css or admin.css.
 */

/* ============================================
   CSS CUSTOM PROPERTIES
   ============================================ */
:root {
    /* Brand colors */
    --primary: #f97316;
    --primary-hover: #ea580c;
    --primary-focus: rgba(249, 115, 22, 0.25);
    
    /* Background colors */
    --bg-dark: #0a0a0a;
    --bg-surface: #141414;
    --bg-card: #1a1a1a;
    --bg-elevated: #262626;
    
    /* Text colors */
    --text-primary: #fafafa;
    --text-secondary: #a3a3a3;
    --text-muted: #737373;
    
    /* Semantic colors */
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --warning: #eab308;
    --info: #3b82f6;
    
    /* Borders */
    --border-color: #2a2a2a;
    --border-color-hover: #404040;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Pico CSS dark theme overrides */
[data-theme="dark"] {
    --pico-background-color: var(--bg-dark);
    --pico-card-background-color: var(--bg-card);
    --pico-card-sectioning-background-color: var(--bg-surface);
    --pico-primary: var(--primary);
    --pico-primary-hover: var(--primary-hover);
    --pico-color: var(--text-primary);
    --pico-muted-color: var(--text-secondary);
    --pico-border-color: var(--border-color);
}

/* Light theme overrides */
[data-theme="light"] {
    --bg-dark: #f8fafc;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-color-hover: #cbd5e1;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
}

/* ============================================
   BASE STYLES
   ============================================ */
html {
    scroll-behavior: smooth;
}

body {
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ============================================
   TOAST NOTIFICATIONS
   Shared toast system for all pages
   ============================================ */
.toast-container {
    position: fixed;
    bottom: var(--spacing-xl);
    right: var(--spacing-xl);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
    font-size: 0.875rem;
    animation: toastSlideIn 0.3s ease;
    max-width: 350px;
}

.toast-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.success .toast-icon { color: var(--success); }

.toast.error {
    border-left: 4px solid var(--error);
}

.toast.error .toast-icon { color: var(--error); }

.toast.info {
    border-left: 4px solid var(--info);
}

.toast.info .toast-icon { color: var(--info); }

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast.warning .toast-icon { color: var(--warning); }

.toast.hiding {
    animation: toastFadeOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translateX(50%);
    }
}

/* ============================================
   MODAL DIALOGS
   Shared modal system for all pages
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    padding: var(--spacing-lg);
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: var(--spacing-lg);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border-color);
}

/* ============================================
   SHARED BUTTON STYLES
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0 var(--spacing-lg);
    height: 38px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-fast);
    box-sizing: border-box;
    line-height: 1;
}

.btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
}

.btn-danger {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: white;
}

.btn-success {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.btn-success:hover {
    background: #16a34a;
    border-color: #16a34a;
    color: white;
}

.btn-sm {
    padding: 0 var(--spacing-sm);
    height: 30px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0 var(--spacing-xl);
    height: 44px;
    font-size: 1rem;
}

/* ============================================
   MINI ITEM CARDS
   Compact card layout for inline item display
   Used by: duplicate detection, related items
   ============================================ */
.item-card-mini {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.item-card-mini img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background: var(--bg-surface);
}

.item-card-mini-info {
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.item-card-mini-name {
    font-weight: 500;
    font-size: 0.875rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.item-card-mini-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-card-mini-actions {
    display: flex;
    gap: var(--spacing-xs);
    flex-shrink: 0;
}

.item-card-mini-actions .btn {
    font-size: 0.7rem;
    padding: 4px 8px;
}

/* ============================================
   DUPLICATE DETECTION PANEL
   Advisory panel showing potential duplicates
   ============================================ */
.duplicate-panel {
    background: rgba(239, 68, 68, 0.08);
    border: 2px solid var(--error);
    border-radius: var(--radius-lg);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.duplicate-panel.hidden {
    display: none;
}

.duplicate-panel-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
    font-weight: 600;
    color: var(--error);
}

.duplicate-panel-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--spacing-md);
}

/* Duplicate items use .item-card-mini as base */
.duplicate-item {
    margin-bottom: var(--spacing-sm);
}

.duplicate-item:last-child {
    margin-bottom: 0;
}

/* ============================================
   COLLECTION PICKER MODAL
   Shared collection picker styles
   ============================================ */
.collection-picker-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.collection-picker-btn {
    justify-content: space-between;
    width: 100%;
}

.collection-picker-name {
    text-align: left;
}

.collection-picker-status {
    opacity: 0.7;
    font-size: 0.875rem;
}

.collection-picker-footer {
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--border-color);
}

/* ============================================
   ALERT BANNERS
   ============================================ */
.alert {
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    border: 1px solid;
}

.alert-success {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

.alert-error {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--error);
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border-color: var(--info);
    color: var(--info);
}

.alert-warning {
    background: rgba(234, 179, 8, 0.1);
    border-color: var(--warning);
    color: var(--warning);
}

/* ============================================
   BADGE STYLES
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.4;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

.badge-warning {
    background: rgba(234, 179, 8, 0.1);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--info);
}

/* ============================================
   IMAGE PREVIEW
   ============================================ */
.image-preview {
    margin-top: var(--spacing-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-elevated);
    max-width: 200px;
}

.image-preview img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }

/* ============================================
   COMMUNITY SWITCHER
   Header dropdown for community/locale selection
   ============================================ */
.community-switcher {
    position: relative;
}

.community-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.6rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-primary);
}

.community-toggle:hover {
    background: var(--bg-elevated);
    border-color: var(--border-color-hover);
}

.community-toggle-arrow {
    font-size: 0.6rem;
    opacity: 0.6;
    transition: transform var(--transition-fast);
}

.community-dropdown.open + .community-toggle .community-toggle-arrow,
.community-toggle[aria-expanded="true"] .community-toggle-arrow {
    transform: rotate(180deg);
}

.community-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 1000;
    overflow: hidden;
}

.community-dropdown.open {
    display: block;
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.community-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.85rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: background var(--transition-fast);
    font-size: 0.9rem;
}

.community-option:hover {
    background: var(--bg-elevated);
}

.community-option.active {
    background: var(--bg-elevated);
}

.community-flag {
    font-size: 1.1rem;
}

.community-name {
    flex: 1;
}

.community-check {
    color: var(--success);
    font-size: 0.85rem;
}

/* Sidebar Community Switcher (Dashboard) */
.sidebar-community-switcher {
    position: relative;
    margin-bottom: var(--spacing-sm);
}

.sidebar-community-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-community-toggle:hover {
    border-color: var(--border-color-hover);
}

.sidebar-community-name {
    flex: 1;
    text-align: left;
}

.sidebar-community-arrow {
    font-size: 0.6rem;
    opacity: 0.6;
    transition: transform var(--transition-fast);
}

.sidebar-community-toggle[aria-expanded="true"] .sidebar-community-arrow {
    transform: rotate(180deg);
}

.sidebar-community-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 0.35rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 100;
}

.sidebar-community-dropdown.open {
    display: block;
    animation: dropdownFadeIn 0.15s ease;
}

.sidebar-community-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: background var(--transition-fast);
}

.sidebar-community-option:hover {
    background: var(--bg-elevated);
}

.sidebar-community-option.active {
    background: var(--bg-elevated);
}

.sidebar-community-option .check {
    margin-left: auto;
    color: var(--success);
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible styles */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE TOAST
   ============================================ */
@media (max-width: 768px) {
    .toast-container {
        left: var(--spacing-md);
        right: var(--spacing-md);
        bottom: var(--spacing-md);
    }
    
    .toast {
        max-width: none;
    }
}

