/**
 * EZ Virtual Tools - Enhanced Features CSS
 * Styles for internationalization, save/export, themes, print, and accessibility
 */

/* ============================================
   CSS CUSTOM PROPERTIES (Theme Variables)
   ============================================ */
:root {
    /* Dark theme (default) */
    --bg-primary: #0f0f17;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #232338;
    --bg-card: rgba(255, 255, 255, 0.03);
    --text-primary: #ffffff;
    --text-secondary: #a0a0b0;
    --text-muted: #6b7280;
    --border-color: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(245, 158, 11, 0.3);
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --success: #22c55e;
    --error: #ef4444;
    --info: #3b82f6;
    --shadow: rgba(0, 0, 0, 0.4);
}

/* Light theme */
[data-theme="light"],
.theme-light {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e5e5e7;
    --bg-card: rgba(0, 0, 0, 0.02);
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5a;
    --text-muted: #888;
    --border-color: rgba(0, 0, 0, 0.1);
    --border-accent: rgba(245, 158, 11, 0.4);
    --shadow: rgba(0, 0, 0, 0.1);
}

/* ============================================
   SECONDARY RESULT VALUES (Metric Equivalents)
   ============================================ */
.result-secondary {
    font-size: 0.75rem;
    color: var(--text-muted, #6b7280);
    margin-top: 4px;
    font-family: 'JetBrains Mono', monospace;
}

/* ============================================
   ACTION BUTTONS
   ============================================ */
.ez-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.ez-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    color: white;
}

.ez-action-btn:hover {
    transform: translateY(-2px);
}

.ez-action-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.ez-action-btn.save { background: var(--success, #22c55e); }
.ez-action-btn.save:hover { background: #16a34a; }
.ez-action-btn.pdf { background: var(--error, #ef4444); }
.ez-action-btn.pdf:hover { background: #dc2626; }
.ez-action-btn.share { background: var(--info, #3b82f6); }
.ez-action-btn.share:hover { background: #2563eb; }
.ez-action-btn.history { background: #8b5cf6; }
.ez-action-btn.history:hover { background: #7c3aed; }

.ez-action-btn svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   DUAL UNIT DISPLAY
   ============================================ */
.result-box .result-dual {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.result-box .result-primary {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--accent, #f59e0b);
    font-family: 'JetBrains Mono', monospace;
}

.result-box .result-metric {
    font-size: 0.8rem;
    color: var(--text-muted, #888);
}

/* ============================================
   UNIT BADGES
   ============================================ */
.unit-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unit-badge.imperial {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.unit-badge.metric {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

/* ============================================
   HELP TOOLTIPS
   ============================================ */
.ez-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
}

.ez-tooltip-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent, #f59e0b);
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    transition: all 0.2s;
}

.ez-tooltip:hover .ez-tooltip-icon {
    background: var(--accent, #f59e0b);
    color: white;
}

.ez-tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-secondary, #1a1a2e);
    color: var(--text-primary, #fff);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.5;
    white-space: nowrap;
    max-width: 280px;
    white-space: normal;
    box-shadow: 0 4px 20px var(--shadow, rgba(0,0,0,0.3));
    border: 1px solid var(--border-color);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    z-index: 1000;
    margin-bottom: 8px;
}

.ez-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--bg-secondary, #1a1a2e);
}

.ez-tooltip:hover .ez-tooltip-content {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   INPUT VALIDATION
   ============================================ */
.ez-input-wrapper {
    position: relative;
}

.ez-input-error {
    border-color: var(--error, #ef4444) !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.ez-input-success {
    border-color: var(--success, #22c55e) !important;
}

.ez-error-message {
    color: var(--error, #ef4444);
    font-size: 12px;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ez-error-message svg {
    width: 14px;
    height: 14px;
}

/* ============================================
   FAVORITES
   ============================================ */
.ez-favorite-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
    color: var(--text-muted, #888);
}

.ez-favorite-btn:hover {
    background: rgba(245, 158, 11, 0.1);
    color: var(--accent, #f59e0b);
}

.ez-favorite-btn.active {
    color: var(--accent, #f59e0b);
}

.ez-favorite-btn svg {
    width: 20px;
    height: 20px;
}

/* ============================================
   EXAMPLE PRESETS
   ============================================ */
.ez-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.ez-preset-btn {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.ez-preset-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(245, 158, 11, 0.1);
}

.ez-preset-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

/* ============================================
   RELATED CALCULATORS
   ============================================ */
.ez-related {
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.ez-related-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent);
    margin-bottom: 16px;
}

.ez-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.ez-related-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
}

.ez-related-card:hover {
    border-color: var(--border-accent);
    background: rgba(245, 158, 11, 0.05);
    transform: translateY(-2px);
}

.ez-related-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(245, 158, 11, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.ez-related-name {
    font-weight: 600;
    font-size: 14px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    .ez-actions {
        flex-direction: column;
    }

    .ez-action-btn {
        width: 100%;
        justify-content: center;
    }

    .ez-tooltip-content {
        left: 0;
        transform: none;
        max-width: 200px;
    }

    .ez-related-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
/* Focus visible for keyboard navigation */
.ez-action-btn:focus-visible,
.ez-preset-btn:focus-visible,
.ez-favorite-btn:focus-visible,
.ez-related-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .ez-action-btn,
    .ez-preset-btn,
    .ez-related-card,
    .ez-tooltip-content {
        transition: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .ez-action-btn {
        border: 2px solid currentColor;
    }

    .ez-tooltip-content {
        border: 2px solid var(--text-primary);
    }
}

/* ============================================
   SKIP LINK (Accessibility)
   ============================================ */
.ez-skip-link {
    position: fixed;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent);
    color: white;
    padding: 12px 24px;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
    font-weight: 600;
    transition: top 0.2s;
}

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

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    /* Hide UI elements */
    #ezUnitToggle,
    .ez-actions,
    .ez-tooltip-icon,
    .ez-presets,
    .ez-related,
    .ez-favorite-btn,
    header,
    footer,
    nav,
    .no-print {
        display: none !important;
    }

    /* Reset colors for print */
    body {
        background: white !important;
        color: black !important;
        font-size: 12pt;
        line-height: 1.5;
    }

    /* Make cards visible */
    .card,
    .calc-card,
    .result-box {
        background: white !important;
        border: 1px solid #ddd !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }

    /* Ensure text is readable */
    h1, h2, h3, h4, h5, h6 {
        color: black !important;
        page-break-after: avoid;
    }

    p, li, td, th {
        color: #333 !important;
    }

    /* Result values */
    .result-primary,
    .result-value {
        color: #d97706 !important;
    }

    .result-secondary,
    .result-metric {
        color: #666 !important;
    }

    /* Links */
    a {
        color: black !important;
        text-decoration: underline;
    }

    a[href^="http"]:after {
        content: " (" attr(href) ")";
        font-size: 10pt;
        color: #666;
    }

    /* Tables */
    table {
        border-collapse: collapse;
        width: 100%;
    }

    th, td {
        border: 1px solid #ddd;
        padding: 8px;
        text-align: left;
    }

    th {
        background: #f5f5f5 !important;
    }

    /* Page breaks */
    .page-break {
        page-break-before: always;
    }

    /* Print header */
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 20px;
        padding-bottom: 10px;
        border-bottom: 2px solid #d97706;
    }

    .print-footer {
        display: block !important;
        position: fixed;
        bottom: 0;
        width: 100%;
        text-align: center;
        font-size: 10pt;
        color: #666;
        padding: 10px 0;
        border-top: 1px solid #ddd;
    }
}

/* ============================================
   THEME TRANSITION
   ============================================ */
body {
    transition: background-color 0.3s, color 0.3s;
}

.theme-light body,
[data-theme="light"] body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

/* ============================================
   INPUT UNIT LABELS
   ============================================ */
.ez-input-unit {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
}

.ez-input-with-unit {
    padding-right: 50px !important;
}

/* ============================================
   LOADING STATES
   ============================================ */
.ez-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.ez-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: ez-spin 0.8s linear infinite;
}

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

/* ============================================
   EMPTY STATES
   ============================================ */
.ez-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: var(--text-muted);
}

.ez-empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.ez-empty-state p {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.ez-empty-state span {
    font-size: 13px;
    opacity: 0.7;
}
