/* ============================================
   LIZENZ-INVENTAR - STYLES
   ============================================ */

/* ============================================
   CSS VARIABLES
   ============================================ */

:root {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #6b7280;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --background: #f9fafb;
    --surface: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --transition: all 0.2s ease;
}

/* Dark Mode Variables */
@media (prefers-color-scheme: dark) {
    :root {
        --background: #111827;
        --surface: #1f2937;
        --text-primary: #f9fafb;
        --text-secondary: #9ca3af;
        --border-color: #374151;
    }
}

/* ============================================
   GLOBAL STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 {
    font-weight: 600;
    line-height: 1.2;
}

h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }

/* ============================================
   LOGIN SCREEN
   ============================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #6366f1 100%);
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    border-radius: 16px;
    margin-bottom: 1rem;
    color: white;
}

.login-header h1 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ============================================
   FORMS & INPUTS
   ============================================ */

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.input-group input,
.input-group select,
.input-group textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: var(--transition);
}

.input-group input:focus,
.input-group select:focus,
.input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-group textarea {
    resize: vertical;
    min-height: 80px;
}

.input-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.char-counter {
    text-align: right;
}

.password-field {
    position: relative;
}

.password-field input {
    padding-right: 2.5rem;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-password:hover {
    color: var(--text-primary);
}

.category-input-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

/* ============================================
   BUTTONS
   ============================================ */

.btn-primary,
.btn-secondary,
.btn-danger,
.btn-icon {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary-color);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4b5563;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
}

.btn-icon:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   MAIN APP HEADER
   ============================================ */

.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), #6366f1);
    border-radius: 12px;
    color: white;
}

.header-left h1 {
    font-size: 1.5rem;
    margin: 0;
}

.product-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-display {
    padding: 0.5rem 1rem;
    background: var(--background);
    border-radius: var(--radius);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   SEARCH & FILTER BAR
   ============================================ */

.search-bar {
    background: var(--surface);
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.search-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-input-wrapper {
    flex: 1;
    min-width: 300px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 3rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    background: var(--background);
}

.clear-search {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition);
}

.clear-search:hover {
    color: var(--text-primary);
}

.filter-container {
    display: flex;
    gap: 0.75rem;
}

.category-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#categoryFilter {
    padding: 0.75rem 1rem;
    min-width: 200px;
}

.category-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ============================================
   STATS BAR
   ============================================ */

.stats-bar {
    padding: 0.75rem 1.5rem;
    background: var(--background);
    border-bottom: 1px solid var(--border-color);
}

.stats-bar {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 2rem;
    font-size: 0.875rem;
}

.stat-item {
    display: flex;
    gap: 0.5rem;
}

.stat-label {
    color: var(--text-secondary);
}

.stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   PRODUCTS GRID
   ============================================ */

.products-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    min-height: calc(100vh - 300px);
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.25rem;
}

.product-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 1.25rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.product-category {
    padding: 0.25rem 0.625rem;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    display: inline-block;
}

.product-actions {
    display: flex;
    gap: 0.25rem;
}

.action-btn {
    padding: 0.375rem;
    background: transparent;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
}

.action-btn:hover {
    background: var(--background);
}

.action-btn.edit:hover {
    color: var(--primary-color);
}

.action-btn.delete:hover {
    color: var(--danger-color);
}

.product-name {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.product-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 1rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.product-plan {
    background: var(--background);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.product-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 0.875rem;
    transition: var(--transition);
}

.product-link:hover {
    background: var(--primary-hover);
}

/* ============================================
   NO RESULTS
   ============================================ */

.no-results {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.no-results svg {
    margin-bottom: 1.5rem;
    color: var(--text-secondary);
}

.no-results h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.no-results p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
}

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

.spinner-small {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner p {
    margin-top: 1rem;
    color: var(--text-secondary);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.2s ease;
}

.modal-small {
    max-width: 420px;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
}

.modal-header-danger {
    background: #fef2f2;
    border-bottom-color: #fecaca;
}

.modal-header-danger h2 {
    color: var(--danger-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: var(--transition);
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.product-delete-preview {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--background);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.delete-product-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.delete-category {
    padding: 0.25rem 0.625rem;
    background: var(--surface);
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ============================================
   MESSAGES & TOASTS
   ============================================ */

.error-message,
.success-message {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    display: none;
}

.error-message {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.success-message {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #86efac;
}

.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.9375rem;
    z-index: 2000;
    transform: translateX(400px);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    background: var(--success-color);
    color: white;
}

.toast-error {
    background: var(--danger-color);
    color: white;
}

.toast-info {
    background: var(--primary-color);
    color: white;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .search-input-wrapper {
        min-width: 100%;
    }
    
    .filter-container {
        width: 100%;
        justify-content: space-between;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .category-input-wrapper {
        grid-template-columns: 1fr;
    }
    
    .modal-content {
        margin: 0.5rem;
    }
    
    .toast {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 1.5rem;
    }
    
    .header-logo {
        display: none;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .btn-primary,
    .btn-secondary {
        width: 100%;
    }
    
    .products-container {
        padding: 1rem;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .app-header,
    .search-bar,
    .stats-bar,
    .product-actions,
    .modal,
    .toast {
        display: none !important;
    }
    
    .products-container {
        padding: 0;
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .product-card {
        page-break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 0.5rem 1rem;
    z-index: 100;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}