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

:root {
    /* Colors */
    --color-primary: #e60012;
    --color-primary-dark: #c1000f;
    --color-primary-darker: #991b1b;
    --color-primary-light: #fecaca;
    --color-primary-lighter: #fef2f2;

    --color-neutral-300: #d4d4d4;
    --color-neutral-500: #737373;
    --color-neutral-800: #262626;

    --color-white: #ffffff;
    --color-black: #000000;

    /* Typography */
    --font-family: 'Noto Sans JP', 'Hiragino Sans', 'ヒラギノ角ゴ ProN', 'Hiragino Kaku Gothic ProN', 'Yu Gothic Medium', '游ゴシック Medium', 'YuGothic', '游ゴシック体', 'Meiryo', sans-serif;
    --font-size-sm: 0.875rem;   /* 14px */
    --font-size-base: 1rem;     /* 16px */
    --font-size-lg: 1.125rem;   /* 18px */
    --font-size-xl: 1.25rem;    /* 20px */
    --font-size-2xl: 1.5rem;    /* 24px */
    --font-size-3xl: 1.875rem;  /* 30px */
    --font-size-4xl: 2.25rem;   /* 36px */

    /* Spacing */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */

    /* Border Radius */
    --radius-lg: 0.5rem;    /* 8px */
    --radius-xl: 0.75rem;   /* 12px */

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-primary: 0 4px 16px rgba(230, 0, 18, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease-in-out;
    --transition-normal: 300ms ease-in-out;
    --transition-slow: 500ms ease-in-out;
}

/* Base Styles */
html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    overscroll-behavior-x: none;
    touch-action: pan-y;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    line-height: 1.6;
    color: var(--color-neutral-800);
    background-color: var(--color-white);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    overflow-y: scroll; /* Always show scrollbar */
    overscroll-behavior-x: none;
    touch-action: pan-y;
}

/* App Layout */
.app-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 var(--space-4);
}

/* Site Header */
.site-header {
    background: var(--color-white);
    border-bottom: 4px solid var(--color-primary);
    width: 100%;
    height: 64px; /* Fixed height to prevent layout shift */
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.branding {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding-top: var(--space-3);
    padding-bottom: var(--space-3);
    height: 100%; /* Use full header height */
    box-sizing: border-box;
}

.site-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    transition: transform var(--transition-fast);
}

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

/* Main Content */
.app-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-8) var(--space-4);
    margin-top: 64px;
    min-height: calc(100vh - 140px);
}

/* Footer */
.app-footer {
    background-color: var(--color-white);
    padding: var(--space-4) 0;
    margin-top: auto;
    /* Stable layout - prevent reflow */
    min-height: 60px; /* Minimum height to prevent layout shift */
    box-sizing: border-box;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-4);
    text-align: center;
}

.copyright {
    color: var(--color-neutral-500);
    font-size: var(--font-size-sm);
}

/* iPad Responsive Styles */
@media (min-width: 768px) and (max-width: 1024px) {
    :root {
        --font-size-base: 1.125rem;   /* 18px for better readability on iPad */
        --font-size-lg: 1.25rem;      /* 20px */
        --font-size-xl: 1.375rem;     /* 22px */
        --font-size-2xl: 1.75rem;     /* 28px */
    }

    .site-logo {
        height: 45px; /* Slightly larger for iPad */
    }

    .app-main {
        padding: var(--space-12) var(--space-6);
    }
}

/* iPad Pro Styles */
@media (min-width: 1024px) and (max-width: 1366px) {
    .app-main {
        padding: var(--space-16) var(--space-8);
    }
}

/* iPad Landscape Orientation */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {
    .app-main {
        padding: var(--space-8) var(--space-6);
    }
}

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

/* Session expiry modal */
.session-expiry-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none; /* hidden by default; JS will set to flex */
    align-items: center;
    justify-content: center;
}

.session-expiry-modal__content {
    background: var(--color-white);
    padding: 30px 40px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    max-width: 550px;
    width: 90%;
    text-align: center;
    border: none; /* remove any default border */
    outline: none; /* remove focus outline */
}

.session-expiry-modal__content:focus {
    outline: none; /* ensure no outline when focused */
}

.session-expiry-modal {
    border: none; /* ensure overlay has no border */
}

.session-expiry-modal__message {
    margin: 0 0 25px 0;
    color: var(--color-neutral-800);
    line-height: 1.6;
}

.session-expiry-modal__button {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 10px 30px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
}

.session-expiry-modal__icon svg {
    width: 50px;
    height: 50px;
}

/* When modal is visible, disable background clicks */
.session-expiry-modal[style*="display: flex"] ~ .app-wrapper {
    pointer-events: none;
}

/* Spinner animations for Utils.showButtonLoading */
@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes dash {
    0% {
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dashoffset: -15.7;
        transform: rotate(135deg);
    }
    100% {
        stroke-dashoffset: -31.4;
        transform: rotate(450deg);
    }
}

/* Password Modal Styles (shared between complete and reception pages) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: modalFadeIn 0.3s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--color-white);
    border-radius: 15px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 400px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 25px 25px 15px;
}

.modal-header h2 {
    margin: 0;
    font-size: 22px;
    color: var(--color-neutral-800);
    font-weight: 600;
}

.modal-body {
    padding: 20px 25px;
}

.modal-body p {
    margin: 0 0 20px 0;
    font-size: 16px;
    line-height: 1.5;
}

.input-group {
    margin-bottom: 10px;
}

.input-group input {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--color-neutral-300);
    border-radius: 10px;
    font-size: 16px;
    transition: border-color var(--transition-fast);
    background-color: #f9f9f9;
    box-sizing: border-box;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
    background-color: var(--color-white);
}

/* Error state for password input inside modal */
.modal-body .input-group input.input-error {
    background-color: var(--color-white);
}

/* Error message inside modal - simple styling like original */
/* Must have higher specificity to override reception.css */
.modal .modal-body .error-message {
    color: var(--color-primary);
    font-size: 12px;
    margin-top: 8px;
    min-height: 20px;
    display: none;
    /* Reset styles from reception.css */
    background-color: transparent !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    margin: 8px 0 0 0 !important;
    font-weight: normal !important;
    position: static !important;
    top: auto !important;
    z-index: auto !important;
    box-shadow: none !important;
    width: auto !important;
}

.modal .modal-body .error-message.show {
    display: block;
}

.modal-footer {
    padding: 15px 25px 25px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.confirm-button,
.cancel-button {
    padding: 12px 25px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    min-width: 80px;
    outline: none;
}

.confirm-button {
    background: var(--color-primary);
    color: var(--color-white);
    border: none;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.confirm-button:focus {
    outline: none;
    border: none;
}

.confirm-button:hover {
    background: var(--color-primary-dark);
}

.cancel-button {
    background: #f8f9fa;
    border: 2px solid var(--color-neutral-300);
}

.cancel-button:focus {
    outline: none;
}

.cancel-button:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

/* Spinner inside confirm button */
.btn-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spinBtn 0.8s linear infinite;
    display: none;
}

@keyframes spinBtn {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.confirm-button.loading .confirmBtnText {
    display: none;
}

.confirm-button.loading .btn-spinner {
    display: inline-block !important;
}

/* iPad Responsive Design for Modal */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .modal-content {
        max-width: 450px;
    }

    .modal-header h2 {
        font-size: 24px;
    }

    .modal-body p {
        font-size: 18px;
    }

    .input-group input {
        padding: 18px;
        font-size: 18px;
    }

    .confirm-button,
    .cancel-button {
        padding: 14px 30px;
        font-size: 18px;
    }
}
