/* ===== Fonts Import ===== */
@import url('https://fonts.googleapis.com/css2?family=Advent+Pro:ital,wght@0,100..900;1,100..900&family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap'); /* ===== CSS Variables ===== */

:root {
    /* Colors */
    --color-primary: #167796;
    --color-primary-dark: #0d5a6e;
    --color-primary-light: #1a8fb3;
    --color-primary-rgb: 22, 119, 150;
    
    --color-secondary: #757575;
    --color-secondary-dark: #616161;
    --color-secondary-light: #9e9e9e;
    
    --color-background: #f5f5f5;
    --color-surface: #ffffff;
    --color-text: #212121;
    --color-text-secondary: #757575;
    
    --color-error: #d32f2f;
    --color-success: #388e3c;
    --color-warning: #f57c00;
    --color-info: #1976d2;
    
    --color-border: #e0e0e0;
    --color-scrollbar-track: #f1f1f1;
    --color-scrollbar-thumb: var(--color-primary);
    --color-scrollbar-thumb-hover: var(--color-primary-dark);
    
    /* Fonts */
    --font-title: 'Advent Pro', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Nunito', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Font Sizes */
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 2rem;
    
    /* 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;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ===== CSS Reset & Base Styles ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
}

body {
    font-family: var(--font-body);
    line-height: 1.5;
    color: var(--color-text);
    background-color: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
    max-width: 100vw;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-title);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.5rem;
    color: var(--color-text);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }
h5 { font-size: var(--font-size-base); }
h6 { font-size: var(--font-size-sm); }

p {
    font-family: var(--font-body);
    margin-bottom: var(--spacing-md);
}

/* ===== Links ===== */
a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-base);
}

a:hover {
    color: var(--color-primary-dark);
}

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

/* ===== Form Elements ===== */
input, select, textarea, button {
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    line-height: 1.5;
}

input:focus, select:focus, textarea:focus, button:focus {
    outline: none;
}

/* ===== Buttons ===== */
button {
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
    font-family: var(--font-title);
    font-weight: 600;
}

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

/* MudBlazor specific overrides */
.mud-button-label {
    font-family: var(--font-title) !important;
    font-weight: 600 !important;
}

.mud-input-label {
    background-color: var(--color-background) !important;
}

.mud-typography {
    font-family: var(--font-body) !important;
}

.mud-typography-h6,
.mud-typography-h5,
.mud-typography-h4,
.mud-typography-h3,
.mud-typography-h2,
.mud-typography-h1 {
    font-family: var(--font-title) !important;
    font-weight: 600 !important;
}

.mud-typography-h6.header {
    color: var(--color-surface) !important;
}

.mud-appbar {
    font-family: var(--font-title) !important;
}

/* Fix appbar content overflow */
.mud-appbar .mud-toolbar {
    flex-wrap: nowrap;
    overflow: hidden;
}

.mud-appbar .mud-typography {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Ensure main layout doesn't overflow */
.main-layout {
    min-height: 100vh;
    background-color: var(--color-background);
    max-width: 100vw;
    overflow-x: hidden;
}

/* Handle text overflow in MudBlazor components */
.mud-typography {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Fix paper component overflow */
.mud-paper {
    max-width: 100%;
}

/* Fix select items text overflow */
.mud-select-item {
    white-space: normal;
    word-wrap: break-word;
}

/* Fix FAB position on mobile */
@media (max-width: 600px) {
    .mud-fab {
        bottom: 16px !important;
        right: 16px !important;
    }
}

.mud-appbar .mud-typography {
    font-family: var(--font-title) !important;
    font-weight: 600 !important;
}

/* ===== Images ===== */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* ===== Lists ===== */
ul, ol {
    list-style: none;
}

/* ===== Utility Classes ===== */

/* Layout */
.flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.justify-center {
    justify-content: center;
}

.align-center {
    align-items: center;
}

.gap-1 {
    gap: var(--spacing-sm);
}

.gap-2 {
    gap: var(--spacing-md);
}

.gap-3 {
    gap: var(--spacing-lg);
}

/* Spacing */
.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-sm); }
.p-2 { padding: var(--spacing-md); }
.p-3 { padding: var(--spacing-lg); }
.p-4 { padding: var(--spacing-xl); }

.m-0 { margin: 0; }
.m-1 { margin: var(--spacing-sm); }
.m-2 { margin: var(--spacing-md); }
.m-3 { margin: var(--spacing-lg); }
.m-4 { margin: var(--spacing-xl); }

.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

/* Text */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

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

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

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

.text-error {
    color: var(--color-error);
}

.text-success {
    color: var(--color-success);
}

/* Cursor */
.cursor-pointer {
    cursor: pointer;
}

.cursor-default {
    cursor: default;
}

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

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-fade-in {
    animation: fadeIn var(--transition-slow) ease-out;
}

.animate-slide-in {
    animation: slideInRight var(--transition-slow) ease-out;
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Hover Effects */
.hover-card {
    transition: all var(--transition-base) cubic-bezier(0.4, 0, 0.2, 1);
}

.hover-card:hover {
    transform: translateX(4px);
    box-shadow: var(--shadow-hover);
}

.hover-scale {
    transition: transform var(--transition-base) ease;
}

.hover-scale:hover {
    transform: scale(1.02);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-scrollbar-track);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb {
    background: var(--color-scrollbar-thumb);
    border-radius: var(--radius-sm);
    transition: background var(--transition-base);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-scrollbar-thumb-hover);
}

/* Firefox Scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-scrollbar-thumb) var(--color-scrollbar-track);
}

/* Selection */
::selection {
    background-color: rgba(var(--color-primary-rgb), 0.2);
    color: var(--color-primary);
}

/* Focus Visible (Accessibility) */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Mobile Optimizations */
@media (max-width: 600px) {
    html {
        font-size: 15px;
    }
    
    /* Prevent horizontal overflow */
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    /* Fix container overflow on mobile */
    .mud-container {
        max-width: 100% !important;
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    
    /* Reduce top margin on mobile to account for appbar */
    .mt-16 {
        margin-top: 56px !important;
    }
    
    /* Ensure cards don't overflow */
    .mud-card {
        max-width: 100%;
    }
    
    /* Handle long text in cards */
    .mud-card-content {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Fix flex layouts on mobile */
    .mud-card-content .d-flex {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    /* Ensure text fields don't overflow */
    .mud-input-control {
        max-width: 100%;
    }
    
    /* Fix grid items on mobile */
    .mud-grid-item {
        max-width: 100%;
    }
    
    /* Larger touch targets on mobile */
    button, 
    [role="button"],
    input[type="submit"],
    input[type="reset"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Prevent text selection on UI elements */
    .no-select {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* Safe area for notched devices */
@supports (padding-top: env(safe-area-inset-top)) {
    .safe-area-top {
        padding-top: env(safe-area-inset-top);
    }
    
    .safe-area-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Loading States */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Ripple Effect */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width var(--transition-slow) ease, height var(--transition-slow) ease;
}

.ripple:active::after {
    width: 200%;
    height: 200%;
}

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

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

.loading-progress circle:last-child {
    stroke: var(--color-primary);
    stroke-dasharray: 251.2;
    stroke-dashoffset: 251.2;
    stroke-linecap: round;
    animation: loading-progress 2s ease-out infinite;
}

@keyframes loading-progress {
    0% {
        stroke-dashoffset: 251.2;
    }
    50% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: -251.2;
    }
}

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

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

/* Blazor Error UI */
#blazor-error-ui {
    background: var(--color-surface);
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-family: var(--font-body);
}

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

#blazor-error-ui .reload {
    color: var(--color-primary);
    text-decoration: underline;
    cursor: pointer;
}
