/* CSS Custom Properties for consistent sizing */
:root {
    --app-height: 100dvh;
    --app-width: 100dvw;
    --timer-padding: clamp(0.25rem, 2vmin, 1rem);
}

/* Core resets - Office 365 add-in compatible */
*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    height: var(--app-height);
    overflow: hidden;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    /* Prevent text selection in timer app */
    -webkit-user-select: none;
    user-select: none;
}

#app {
    width: 100%;
    height: 100%;
    height: var(--app-height);
    display: flex;
    flex-direction: column;
}

.page {
    width: 100%;
    height: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

main {
    width: 100%;
    height: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Settings form styles */
.settings-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.setting-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.setting-group label {
    font-weight: 500;
    font-size: 0.875rem;
    color: #333;
}

.setting-row {
    display: flex;
    gap: 1rem;
}

.setting-row .setting-group {
    flex: 1;
}

/* License prompt */
.license-prompt {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: center;
}

/* Footer links */
.footer-links {
    display: flex;
    align-items: center;
}

.footer-links a {
    color: #0078d4;
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* 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: #d24726;
    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 */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

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

/* ============================================
   Office 365 Add-in Specific Fixes
   ============================================ */

/* Office add-in panels have constrained sizes (typically 320-400px width)
   These rules ensure the app works well in these constrained environments */

/* Fix for iOS Safari and Office mobile */
@supports (-webkit-touch-callout: none) {
    :root {
        --app-height: -webkit-fill-available;
    }
}

/* Ensure no scrollbars appear in the add-in panel */
html, body, #app, .page, main {
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Prevent pull-to-refresh on mobile Office */
body {
    overscroll-behavior: none;
}

/* Fix for Office Online specific iframe issues */
html {
    /* Ensure the app fills the Office panel completely */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Touch-friendly tap targets for Office mobile */
@media (pointer: coarse) {
    .control-btn {
        min-width: 44px;
        min-height: 44px;
    }
}

/* High contrast mode support for accessibility */
@media (prefers-contrast: high) {
    .control-btn {
        border-width: 3px;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
