/**
 * Livskalkyl.se - Custom Styles
 * Supplements Tailwind CSS
 * Version: 1.0.0
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Design Tokens)
   ============================================ */

:root {
    /* Colors - matches Tailwind config */
    --color-primary-50: #eff6ff;
    --color-primary-100: #dbeafe;
    --color-primary-500: #3b82f6;
    --color-primary-600: #2563eb;
    --color-primary-700: #1d4ed8;
    --color-primary-800: #1e40af;
    --color-primary-900: #1e3a8a;
    
    --color-accent-400: #2dd4bf;
    --color-accent-500: #14b8a6;
    --color-accent-600: #0d9488;
    
    --color-neutral-50: #fafafa;
    --color-neutral-100: #f5f5f5;
    --color-neutral-200: #e5e5e5;
    --color-neutral-600: #525252;
    --color-neutral-800: #262626;
    --color-neutral-900: #171717;
    
    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Spacing */
    --header-height: 72px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

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

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Respect user preference for reduced motion */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
    
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
}

/* ============================================
   HEADER - Reserved Height (Prevents CLS)
   ============================================ */

#site-header {
    min-height: var(--header-height);
}

/* ============================================
   FOCUS STYLES (Accessibility)
   ============================================ */

.user-is-tabbing *:focus {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

body:not(.user-is-tabbing) *:focus {
    outline: none;
}

/* ============================================
   SELECTION STYLES
   ============================================ */

::selection {
    background-color: var(--color-primary-100);
    color: var(--color-primary-900);
}

/* ============================================
   CALCULATOR FORM STYLES
   ============================================ */

.calc-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: var(--color-neutral-900);
    background-color: white;
    border: 1px solid var(--color-neutral-200);
    border-radius: 0.5rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.calc-input:hover {
    border-color: #d4d4d4;
}

.calc-input:focus {
    outline: none;
    border-color: var(--color-primary-500);
    box-shadow: 0 0 0 3px var(--color-primary-100);
}

.calc-input::placeholder {
    color: #a3a3a3;
}

.calc-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #404040;
}

/* Input with suffix (kr, %, etc) */
.calc-input-wrapper {
    position: relative;
}

.calc-input-suffix {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #737373;
    font-size: 0.875rem;
    pointer-events: none;
}

.calc-input-wrapper .calc-input {
    padding-right: 3rem;
}

/* Range slider */
.calc-range {
    width: 100%;
    height: 0.5rem;
    background: var(--color-neutral-200);
    border-radius: 9999px;
    appearance: none;
    cursor: pointer;
}

.calc-range::-webkit-slider-thumb {
    appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    background: var(--color-primary-600);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.calc-range::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 0 4px var(--color-primary-100);
}

.calc-range::-moz-range-thumb {
    width: 1.25rem;
    height: 1.25rem;
    background: var(--color-primary-600);
    border: none;
    border-radius: 50%;
    cursor: pointer;
}

/* ============================================
   RESULT DISPLAY STYLES
   ============================================ */

.calc-result {
    background: linear-gradient(135deg, var(--color-primary-50) 0%, white 100%);
    border: 1px solid var(--color-primary-100);
    border-radius: 1rem;
    padding: 1.5rem;
}

.calc-result-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary-700);
    line-height: 1.2;
}

.calc-result-label {
    font-size: 0.875rem;
    color: #737373;
    margin-top: 0.25rem;
}

.calc-result-highlight {
    background: linear-gradient(135deg, var(--color-accent-500) 0%, var(--color-accent-600) 100%);
    color: white;
    border: none;
}

.calc-result-highlight .calc-result-value {
    color: white;
}

.calc-result-highlight .calc-result-label {
    color: rgba(255, 255, 255, 0.8);
}

/* ============================================
   BUTTON STYLES
   ============================================ */

.calc-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.5;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.calc-button-primary {
    background: var(--color-primary-600);
    color: white;
    border: none;
}

.calc-button-primary:hover {
    background: var(--color-primary-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.calc-button-secondary {
    background: white;
    color: var(--color-neutral-700);
    border: 1px solid var(--color-neutral-200);
}

.calc-button-secondary:hover {
    background: var(--color-neutral-50);
    border-color: var(--color-neutral-300);
}

/* ============================================
   CARD STYLES
   ============================================ */

.calc-card {
    background: white;
    border: 1px solid var(--color-neutral-200);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: box-shadow var(--transition-normal), transform var(--transition-normal);
}

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

/* ============================================
   TABLE STYLES (for comparison tables)
   ============================================ */

.calc-table {
    width: 100%;
    border-collapse: collapse;
}

.calc-table th,
.calc-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-neutral-200);
}

.calc-table th {
    font-weight: 600;
    color: var(--color-neutral-700);
    background: var(--color-neutral-50);
}

.calc-table tr:last-child td {
    border-bottom: none;
}

.calc-table tr:hover td {
    background: var(--color-neutral-50);
}

/* ============================================
   TOOLTIP STYLES
   ============================================ */

.calc-tooltip {
    position: relative;
    cursor: help;
}

.calc-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--color-neutral-900);
    color: white;
    font-size: 0.75rem;
    border-radius: 0.375rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    z-index: 10;
}

.calc-tooltip:hover::after {
    opacity: 1;
    visibility: visible;
}

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

.calc-spinner {
    width: 1.5rem;
    height: 1.5rem;
    border: 2px solid var(--color-neutral-200);
    border-top-color: var(--color-primary-600);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

@media print {
    /* Hide navigation and non-essential elements */
    #site-header,
    #site-footer,
    .no-print {
        display: none !important;
    }
    
    /* Reset colors for print */
    body {
        background: white !important;
        color: black !important;
    }
    
    /* Ensure results are visible */
    .calc-result {
        background: #f5f5f5 !important;
        border: 1px solid #ccc !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    /* Page breaks */
    .page-break-before {
        page-break-before: always;
    }
    
    .page-break-after {
        page-break-after: always;
    }
    
    .no-page-break {
        page-break-inside: avoid;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Screen reader only */
.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;
}

/* Number formatting - tabular numbers */
.tabular-nums {
    font-variant-numeric: tabular-nums;
}

/* Gradient text */
.gradient-text {
    background: linear-gradient(135deg, var(--color-primary-600) 0%, var(--color-accent-500) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Smooth image loading */
img {
    opacity: 1;
    transition: opacity var(--transition-normal);
}

img[data-src] {
    opacity: 0;
}

img.loaded {
    opacity: 1;
}

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

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

.animate-fade-in {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-in {
    animation: slideIn 0.3s ease forwards;
}

/* Staggered animation for lists */
.stagger-animation > * {
    opacity: 0;
    animation: fadeIn 0.3s ease forwards;
}

.stagger-animation > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-animation > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-animation > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-animation > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-animation > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-animation > *:nth-child(6) { animation-delay: 0.3s; }
