/* Modern fonts (Inter for UI and JetBrains Mono for data) are loaded via <link> in index.html for better performance */

/* Base styles using Tailwind's approach */
* {
    box-sizing: border-box;
    font-family: inherit;
}

/* CRITICAL: Ensure consistent base font-size across all environments - MUST override everything */
html {
    font-size: 12px !important;
    -webkit-text-size-adjust: 100% !important;
    -moz-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
}

html, body {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
    margin: 0;
    padding: 0;
    height: 100%;
    background-color: #f8faf9;
    color: #1e293b;
    font-size: 12px !important;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100% !important;
    -moz-text-size-adjust: 100% !important;
    text-size-adjust: 100% !important;
}

/* SIMPLE: Just ensure everything inherits 12px from body */
/* No complex overrides - just let rem values work naturally with 12px base */
body {
    font-size: 12px !important;
}

/* CRITICAL: Force Tailwind text classes to exact pixel values */
/* This ensures production and development match exactly, regardless of rem calculations */
.text-xs { font-size: 9px !important; } /* 0.75rem at 12px base */
.text-sm { font-size: 10.5px !important; } /* 0.875rem at 12px base */
.text-base { font-size: 12px !important; } /* 1rem at 12px base */
.text-lg { font-size: 13.5px !important; } /* 1.125rem at 12px base */
.text-xl { font-size: 15px !important; } /* 1.25rem at 12px base */
.text-2xl { font-size: 18px !important; } /* 1.5rem at 12px base */
.text-3xl { font-size: 22.5px !important; } /* 1.875rem at 12px base */
.text-4xl { font-size: 27px !important; } /* 2.25rem at 12px base */

/* Also target attribute selectors for Tailwind classes */
[class*="text-xs"] { font-size: 9px !important; }
[class*="text-sm"] { font-size: 10.5px !important; }
[class*="text-base"] { font-size: 12px !important; }
[class*="text-lg"] { font-size: 13.5px !important; }
[class*="text-xl"] { font-size: 15px !important; }
[class*="text-2xl"] { font-size: 18px !important; }
[class*="text-3xl"] { font-size: 22.5px !important; }
[class*="text-4xl"] { font-size: 27px !important; }

/* Reset any browser default font-size overrides */
body, p, div, span, a, button, input, select, textarea, label, h1, h2, h3, h4, h5, h6 {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Enable tabular numbers for financial data - ensures perfect number alignment */
table,
.table,
.financial-data,
.currency,
.amount,
.number-cell,
input[type="number"],
.numeric {
    font-variant-numeric: tabular-nums;
}

/* Use monospace font for specific data displays */
.data-table,
.code,
.monospace,
.font-mono {
    font-family: 'JetBrains Mono', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-variant-numeric: tabular-nums;
}

/* Ensure date inputs use the same font as other form controls */
input[type="date"] {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Remove default link styles */
a {
    color: inherit;
    text-decoration: none;
}

/* CSS Variables (kept for backward compatibility if needed) */
:root {
    --primary-color: #10b981;
    --primary-dark: #059669;
    --primary-light: #34d399;
    --secondary-color: #064e3b;
    --accent-color: #6ee7b7;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-primary: #ffffff;
    --bg-secondary: #f8faf9;
    --bg-tertiary: #ecfdf5;
    --border-color: #e2e8f0;
    --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 15px rgba(0, 0, 0, 0.1);
}

/* Authentication screens */
.auth-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    text-align: center;
    background: white;
}

.auth-screen h3 {
    color: var(--primary-dark);
    margin-bottom: 1rem;
    font-weight: 600;
    font-size: 1.5rem;
}

.auth-screen p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
}

.auth-screen.error h3 {
    color: #dc2626;
}

.auth-screen a {
    color: var(--primary-color);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid var(--primary-color);
    border-radius: 8px;
    transition: all 0.3s;
    font-weight: 500;
}

.auth-screen a:hover {
    background-color: var(--primary-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.auth-screen button {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border: 1px solid #4b5563;
    border-radius: 8px;
    transition: all 0.3s;
    font-weight: 500;
    background-color: #4b5563;
    cursor: pointer;
}

.auth-screen button:hover {
    background-color: #374151;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.auth-screen .btn-dashboard {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.auth-screen .btn-dashboard:hover {
    background-color: #059669;
}

/* Auth actions container */
.auth-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

/* Button styles for auth screen */
.auth-screen .btn-primary,
.auth-screen .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.75rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-decoration: none;
}

.auth-screen .btn-primary {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.auth-screen .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.auth-screen .btn-primary:active {
    transform: translateY(0);
}

.auth-screen .btn-secondary {
    background: white;
    color: #10b981;
    border: 2px solid #10b981;
}

.auth-screen .btn-secondary:hover {
    background: #ecfdf5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.auth-screen .btn-secondary:active {
    transform: translateY(0);
}

.auth-screen .icon {
    width: 1.25rem;
    height: 1.25rem;
}

/* Auth loading screen */
.auth-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: white;
}

.auth-loading-content {
    text-align: center;
    padding: 3rem;
    background: white;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    max-width: 400px;
}

.auth-loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 3px solid var(--bg-tertiary);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.auth-loading h3 {
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 1.25rem;
}

.auth-loading p {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.95rem;
}

/* Login Display Component */
.login-display {
    display: flex;
    align-items: center;
    gap: 1rem;
}

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

.btn-login,
.btn-logout {
    background-color: white;
    color: #0066cc;
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-login:hover,
.btn-logout:hover {
    background-color: #f0f0f0;
    transform: translateY(-1px);
}

.btn-logout {
    background-color: rgba(255, 255, 255, 0.9);
}

/* Loading progress */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--primary-color);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--bg-tertiary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* Spin animation */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Standard page loader (matches Branch page) */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    padding: 3rem;
}

.spinner-wrapper {
    position: relative;
    width: 80px;
    height: 80px;
    margin-bottom: 2rem;
}

.spinner-ring {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 6px solid #d1fae5;
    border-top-color: #10b981; /* emerald */
    animation: spin 1s linear infinite;
}

.spinner-ring-inner {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 6px solid transparent;
    border-top-color: #059669; /* darker emerald */
    animation: spin 1.5s linear infinite reverse;
    opacity: 0.5;
}

.loading-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937; /* slate-800 */
    margin: 0 0 0.5rem 0;
}

.loading-subtitle {
    font-size: 0.875rem;
    color: #6b7280; /* gray-500 */
    margin: 0;
}

/* Error UI */
#blazor-error-ui {
    background: #dc2626;
    color: white;
    bottom: 0;
    box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.3);
    display: none;
    left: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1.5rem;
    top: 0.75rem;
}

#blazor-error-ui a {
    color: white;
    text-decoration: underline;
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    /* Ensure proper touch targets */
    button, a, input, select, textarea {
        min-height: 44px;
    }
    
    /* Improve text readability on mobile */
    body {
        font-size: 16px; /* Prevent zoom on iOS */
        -webkit-text-size-adjust: 100%;
    }
    
    /* Better spacing for mobile */
    .container, .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Improve form controls */
    input, select, textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    /* Better button spacing */
    .btn, button {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
    
    /* Improve table responsiveness */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Better card layouts */
    .card {
        margin-bottom: 1rem;
    }
    
    /* Improve navigation */
    .nav-link {
        padding: 0.75rem 1rem;
        min-height: 44px;
    }
}

/* Tablet improvements */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Better spacing for tablets */
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* High DPI display improvements */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Ensure crisp rendering on high DPI displays */
    svg, img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

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

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles here if needed */
}
