@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    min-height: 100%;
    min-height: -webkit-fill-available;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Mobile-first approach */
h1 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 0.8rem;
}

h3 {
    font-size: 1.3rem;
    margin-bottom: 0.6rem;
}

/* Improved form controls for touch */
.form-control {
    font-size: 16px; /* Prevents iOS zoom on focus */
    height: auto;
    padding: 0.75rem;
}

select.form-control {
    padding: 0.5rem;
    height: auto;
}

.btn {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 6px;
    min-height: 44px; /* iOS minimum touch target size */
}

/* Card improvements */
.card {
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.card-body {
    padding: 1.25rem;
}

/* Sidebar colors */
.sidebar {
    background-image: linear-gradient(180deg, #2e7d32 0%, #1b5e20 70%) !important;
}

/* iOS Safari specific improvements */
@supports (-webkit-touch-callout: none) {
    /* Better tap targets */
    .btn, .form-control, select, input[type="date"], input[type="datetime-local"] {
        min-height: 44px;
    }

    /* Prevent double-tap zoom */
    a, button, input, select {
        touch-action: manipulation;
    }

    /* Remove tap highlight */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    /* Improve scrolling */
    .content {
        -webkit-overflow-scrolling: touch;
    }
}

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

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

.loading-progress circle:last-child {
    stroke: #1b6ec2;
    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: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

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

/* Error UI - Improved for PWA and mobile accessibility */
#blazor-error-ui {
    background: #ff6b6b;
    color: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    display: none;
    position: fixed;
    width: 100%;
    z-index: 2000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-align: center;
    /* Position at top to avoid iOS status bar conflicts */
    top: 0;
    left: 0;
    right: 0;
    padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem 1rem;
    border-bottom: 2px solid #ff5252;
}

/* Mobile-first error UI styling */
#blazor-error-ui {
    padding: 1rem;
    font-size: 14px;
    line-height: 1.4;
}

#blazor-error-ui .reload {
    display: inline-block;
    background: white;
    color: #ff6b6b;
    text-decoration: none;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    margin: 0.5rem 0.5rem 0 0.5rem;
    min-height: 44px;
    min-width: 120px;
    box-sizing: border-box;
    border: 2px solid white;
    transition: all 0.2s ease;
}

#blazor-error-ui .reload:hover {
    background: #f5f5f5;
    transform: translateY(-1px);
}

#blazor-error-ui .dismiss {
    display: inline-block;
    background: transparent;
    color: white;
    text-decoration: none;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    font-weight: 600;
    margin: 0.5rem;
    min-height: 44px;
    min-width: 80px;
    box-sizing: border-box;
    border: 2px solid white;
    cursor: pointer;
    transition: all 0.2s ease;
}

#blazor-error-ui .dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* PWA standalone mode adjustments */
@media all and (display-mode: standalone) {
    #blazor-error-ui {
        /* Ensure it's above the safe area on iOS */
        padding-top: max(1rem, env(safe-area-inset-top));
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* Larger screens */
@media (min-width: 768px) {
    #blazor-error-ui {
        font-size: 16px;
        padding: 1.5rem;
    }
    
    #blazor-error-ui .reload,
    #blazor-error-ui .dismiss {
        padding: 0.75rem 2rem;
        font-size: 16px;
    }
}

/* Dark mode support for error UI */
@media (prefers-color-scheme: dark) {
    #blazor-error-ui {
        background: #d32f2f;
        border-bottom-color: #b71c1c;
    }
    
    #blazor-error-ui .reload {
        background: #1a1a1a;
        color: #ff6b6b;
        border-color: #1a1a1a;
    }
    
    #blazor-error-ui .reload:hover {
        background: #2d2d2d;
    }
    
    #blazor-error-ui .dismiss {
        border-color: #ffffff;
    }
}

/* Desktop enhancements */
@media (min-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }

    h2 {
        font-size: 2rem;
    }

    h3 {
        font-size: 1.75rem;
    }

    .btn {
        padding: 0.5rem 1rem;
    }

    .form-control {
        padding: 0.5rem;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #1a1a1a;
        color: #ffffff;
    }

    .card {
        background-color: #2d2d2d;
        border-color: #404040;
    }

    .form-control {
        background-color: #333333;
        border-color: #404040;
        color: #ffffff;
    }

    .form-control:focus {
        background-color: #404040;
        border-color: #666666;
        color: #ffffff;
    }

    .table {
        color: #ffffff;
    }
    
    .table-hover tbody tr:hover {
        background-color: #444444;
        color: #ffffff;
    }

    .alert-info {
        background-color: #2d2d2d;
        border-color: #404040;
        color: #ffffff;
    }
}
