﻿/* Custom Colors */
:root {
    --primary: #1B5E7A;
    --primary-light: #2A7699;
    --primary-lighter: #E8F4F8;
    --primary-dark: #0F4C63;
    --secondary: #38B2AC;
    --text: #1A202C;
    --text-light: #64748B;
    --text-lighter: #94A3B8;
    --white: #FFFFFF;
    --danger: #F44336;
    --gray-50: #F9FAFB;
    --gray-200: #E5E7EB;
    --gray-800: #1F2937;
}

/* Reset and Base */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Vazirmatn', sans-serif;
    background: var(--white);
    color: var(--text);
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Loading Container */
.loading-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}

/* Loading Logo */
.loading-logo {
    text-align: center;
    margin-bottom: 2rem;
    width: 100%;
}

.medical-icon {
    font-size: clamp(2.5rem, 10vw, 3.5rem);
    display: block;
    margin-bottom: 1rem;
    color: var(--primary);
    animation: gentlePulse 3s infinite ease-in-out;
}

@keyframes gentlePulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.05);
        opacity: 0.95;
    }
}

.loading-logo h1 {
    color: var(--primary-dark);
    font-size: clamp(1.1rem, 4.5vw, 1.5rem);
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    line-height: 1.3;
}

.loading-logo p {
    color: var(--text-light);
    margin: 0;
    font-size: clamp(0.8rem, 3.5vw, 0.9rem);
    line-height: 1.5;
}

/* Circular Progress */
.circular-progress {
    position: relative;
    width: min(140px, 33vw);
    height: min(140px, 33vw);
    margin: clamp(1.5rem, 5vh, 2rem) 0;
}

    .circular-progress svg {
        width: 100%;
        height: 100%;
        transform: rotate(-90deg);
    }

    .circular-progress circle {
        fill: none;
        stroke-width: clamp(8px, 2vw, 10px);
        stroke-linecap: round;
        stroke-linejoin: round;
    }

    .circular-progress .background-circle {
        stroke: var(--gray-200);
    }

    .circular-progress .progress-circle {
        stroke: var(--primary);
        stroke-dasharray: 283; /* 2 * π * 45 */
        stroke-dashoffset: 283;
        transition: stroke-dashoffset 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(1.5rem, 6vw, 1.75rem);
    font-weight: 700;
    color: var(--primary-dark);
    text-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

/* Loading Details */
.loading-details {
    text-align: center;
    margin-top: 1rem;
    width: 100%;
    max-width: min(300px, 85vw);
}

.loading-message {
    color: var(--text);
    font-size: clamp(0.9rem, 3.8vw, 1rem);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.status-text {
    color: var(--primary);
    font-size: clamp(0.75rem, 3.2vw, 0.85rem);
    font-weight: 500;
    line-height: 1.4;
    min-height: 1.2em;
    opacity: 0.9;
}

/* Loading Progress Bar */
.loading-bar-container {
    width: 100%;
    max-width: min(300px, 85vw);
    margin-top: clamp(1rem, 4vh, 1.5rem);
}

.loading-bar {
    width: 100%;
    height: clamp(3px, 0.8vw, 4px);
    background: var(--gray-200);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-light), var(--secondary));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* Version Info */
.version-info {
    position: absolute;
    bottom: clamp(1rem, 4vh, 1.5rem);
    color: var(--text-lighter);
    font-size: clamp(0.65rem, 2.8vw, 0.75rem);
    opacity: 0.7;
}

/* Blazor Error UI */
#blazor-error-ui {
    background: linear-gradient(135deg, var(--danger), #DC2626);
    color: var(--white);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: clamp(0.75rem, 3vw, 1rem);
    display: none;
    z-index: 10000;
    box-shadow: 0 -2px 10px rgba(220, 38, 38, 0.2);
}

    #blazor-error-ui.show {
        display: block;
        animation: slideUp 0.3s ease-out;
    }

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.error-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1200px;
    margin: 0 auto;
    gap: 1rem;
}

.error-icon {
    font-size: clamp(1.1rem, 4.5vw, 1.25rem);
    margin-left: clamp(0.5rem, 2vw, 1rem);
    opacity: 0.9;
    flex-shrink: 0;
}

.error-message {
    flex: 1;
    min-width: 0;
}

    .error-message h5 {
        margin: 0 0 0.25rem 0;
        font-size: clamp(0.85rem, 3.5vw, 0.95rem);
        font-weight: 600;
        line-height: 1.3;
    }

    .error-message p {
        margin: 0;
        font-size: clamp(0.75rem, 3vw, 0.85rem);
        opacity: 0.9;
        line-height: 1.4;
    }

.error-actions {
    display: flex;
    gap: clamp(0.25rem, 1.5vw, 0.5rem);
    flex-shrink: 0;
}

    .error-actions a {
        padding: clamp(0.4rem, 2vw, 0.5rem) clamp(0.8rem, 3vw, 1rem);
        border-radius: 6px;
        text-decoration: none;
        font-size: clamp(0.75rem, 3vw, 0.85rem);
        display: flex;
        align-items: center;
        gap: clamp(0.25rem, 1.5vw, 0.5rem);
        font-weight: 500;
        transition: all 0.2s;
        white-space: nowrap;
    }

    .error-actions .btn-primary {
        background: var(--white);
        color: var(--danger);
        font-weight: 600;
    }

        .error-actions .btn-primary:active {
            background: var(--gray-50);
            transform: translateY(1px);
        }

    .error-actions .btn-outline {
        border: 1px solid var(--white);
        color: var(--white);
        background: transparent;
    }

        .error-actions .btn-outline:active {
            background: rgba(255, 255, 255, 0.1);
        }

/* Fade out animation */
@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }

    to {
        opacity: 0;
        transform: scale(0.98);
        visibility: hidden;
    }
}

.fade-out {
    animation: fadeOut 0.4s ease forwards;
}

/* Media Queries */
@media (max-height: 700px) {
    .loading-logo {
        margin-bottom: 1.5rem;
    }

    .medical-icon {
        margin-bottom: 0.75rem;
    }

    .circular-progress {
        margin: 1rem 0;
    }

    .loading-bar-container {
        margin-top: 1rem;
    }

    .version-info {
        bottom: 0.75rem;
    }
}

@media (max-height: 600px) {
    .loading-logo {
        margin-bottom: 1rem;
    }

    .circular-progress {
        width: min(120px, 30vw);
        height: min(120px, 30vw);
    }

    .loading-details {
        margin-top: 0.75rem;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .loading-container {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        padding: 1rem;
    }

    .loading-logo {
        margin-bottom: 0;
        text-align: right;
        flex: 1;
        max-width: 40%;
    }

    .medical-icon {
        font-size: clamp(1.8rem, 8vw, 2.5rem);
        margin-bottom: 0.5rem;
    }

    .loading-logo h1 {
        font-size: clamp(0.9rem, 4vw, 1.1rem);
        margin-bottom: 0.25rem;
    }

    .loading-logo p {
        font-size: clamp(0.7rem, 3vw, 0.8rem);
    }

    .circular-progress {
        width: min(100px, 25vw);
        height: min(100px, 25vw);
        margin: 0;
        flex-shrink: 0;
    }

    .progress-text {
        font-size: clamp(1.2rem, 5vw, 1.4rem);
    }

    .loading-details {
        margin-top: 0;
        max-width: 40%;
        text-align: right;
        flex: 1;
    }

    .loading-bar-container {
        display: none;
    }

    .version-info {
        position: fixed;
        bottom: 0.5rem;
        right: 0.5rem;
        font-size: 0.7rem;
    }
}

@media (max-width: 320px) {
    .loading-container {
        padding: 15px;
    }

    .circular-progress {
        width: 110px;
        height: 110px;
    }

    .loading-details {
        max-width: 280px;
    }
}

/* Safe Area for iPhone X and newer */
@supports (padding: max(0px)) {
    .loading-container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
        padding-top: max(20px, env(safe-area-inset-top));
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .version-info {
        bottom: max(1rem, env(safe-area-inset-bottom));
    }

    #blazor-error-ui {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* Prevent zoom on mobile */
@media (max-width: 768px) {
    input, textarea, select {
        font-size: 16px; /* Prevent automatic zoom */
    }
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
    body {
        background: var(--gray-800);
        color: var(--white);
    }

    .loading-container {
        background: var(--gray-800);
    }

    .loading-logo h1 {
        color: var(--white);
    }

    .loading-logo p {
        color: var(--text-lighter);
    }

    .circular-progress .background-circle {
        stroke: rgba(255, 255, 255, 0.1);
    }

    .progress-text {
        color: var(--white);
    }

    .loading-message {
        color: var(--white);
    }

    .status-text {
        color: var(--primary-light);
    }

    .loading-bar {
        background: rgba(255, 255, 255, 0.1);
    }

    .version-info {
        color: rgba(255, 255, 255, 0.5);
    }
}
