/* ==========================================================================
   Code view – Enter session code
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Reset & base
   -------------------------------------------------------------------------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Gibson', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #F4F7FA;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
    position: relative;
    overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   2. Background assets
   -------------------------------------------------------------------------- */
.background-asset {
    position: fixed;
    z-index: 0;
    pointer-events: none;
}

.background-asset-left {
    bottom: 0;
    left: 0;
}

.background-asset-right {
    bottom: 0;
    right: 0;
}

.background-asset img {
    max-width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
   3. Layout
   -------------------------------------------------------------------------- */
.logo-container,
.session-card {
    position: relative;
    z-index: 1;
}

.logo-container {
    margin-bottom: 60px;
    display: flex;
    justify-content: center;
}

.logo {
    height: 36px;
    width: auto;
}

.session-card {
    background: white;
    border-radius: 12px;
    padding: 48px 36px; /* 45px − 20% for laptop/desktop */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: min(500px, 100%);
}

.session-card-inner {
    width: 100%;
    max-width: 396px;
    margin-left: auto;
    margin-right: auto;
    text-align: left;
}

/* --------------------------------------------------------------------------
   4. Main content – title & code inputs
   -------------------------------------------------------------------------- */
.session-title {
    font-family: 'Gibson', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 36px;
}

.session-title--rtl {
    text-align: right;
}

.code-inputs {
    display: flex;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.code-input {
    flex: 1 1 0;
    min-width: 0;
    max-width: 56px;
    width: 100%;
    height: auto;
    aspect-ratio: 56 / 77;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    font-size: 24px;
    font-weight: 600;
    color: #333;
    background: white;
    transition: all 0.2s ease;
}

.code-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.code-input.filled {
    border-color: #28a745;
    background-color: #f8f9fa;
}

.code-input.error {
    border-color: #dc3545;
}

.code-inputs.loading {
    opacity: 0.5;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   5. Error message & loading
   -------------------------------------------------------------------------- */
.error-message {
    display: none;
    margin-top: 28px;
    margin-left: auto;
    margin-right: auto;
    max-width: 396px;
    justify-content: flex-start;
    color: #333;
    font-size: 14px;
    align-items: center;
    gap: 8px;
}

.error-message.show {
    display: flex;
}

.error-message--rtl {
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.error-message--rtl #errorText {
    flex: 1;
    min-width: 0;
    text-align: right;
}

.error-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #dc3545;
}

.error-icon svg {
    width: 100%;
    height: 100%;
}

.loading-spinner {
    display: none;
    justify-content: center;
    align-items: center;
    margin-top: 28px;
}

.loading-spinner.show {
    display: flex;
}

.spinner {
    width: 100px;
    height: 100px;
    border: 18px solid #e8e8e8;
    border-top-color: #3399FF;
    border-right-color: #3399FF;
    border-bottom-color: #3399FF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* --------------------------------------------------------------------------
   6. Links
   -------------------------------------------------------------------------- */
.login-link-text {
    margin-top: 44px;
    font-size: 14px;
    color: #333;
    text-align: center;
}

.login-link-text a {
    color: #1D6CF5;
    text-decoration: none;
    font-weight: 500;
}

.login-link-text a:hover {
    text-decoration: underline;
}

/* --------------------------------------------------------------------------
   7. Animations
   -------------------------------------------------------------------------- */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE – different screen sizes
   ========================================================================== */

/* Background assets: scale by width */
@media (max-width: 1024px) {
    .background-asset img {
        max-width: 140px;
    }
}

@media (max-width: 480px) {
    .background-asset img {
        max-width: 100px;
    }
}

@media (max-width: 360px) {
    .background-asset img {
        max-width: 65px;
    }
}

/* Tablet */
@media (max-width: 1024px) {
    body {
        padding: 40px 16px; /* top matches desktop ratio (40/36 × logo) */
    }

    .logo-container {
        margin-bottom: 60px; /* same ratio to logo as desktop (60/36) */
    }

    .session-card {
        max-width: min(400px, 100%);
        padding: 40px 16px;
    }

    .session-card-inner {
        max-width: 326px; /* 6×46px + 5×10px gap */
    }

    .session-title {
        font-size: 19px;
        margin-bottom: 36px;
    }

    .code-inputs {
        gap: 10px;
    }

    .code-input {
        max-width: 46px;
        font-size: 22px;
    }

    .error-message {
        max-width: 100%;
        margin-top: 32px;
    }

    .loading-spinner {
        margin-top: 32px;
    }

    .login-link-text {
        margin-top: 40px;
        font-size: 14px;
    }
}

/* Mobile */
@media (max-width: 480px) {
    body {
        padding: 33px 14px; /* top = 40/36 × 30px for consistent ratio */
    }

    .logo-container {
        margin-bottom: 50px; /* 60/36 × 30px */
    }

    .logo {
        height: 30px;
    }

    .session-card {
        max-width: 80%;
        padding: 24px 24px; /* 20px + 20% */
    }

    .session-card-inner {
        max-width: 100%;
    }

    .session-title {
        font-size: 18px;
        margin-bottom: 32px;
    }

    .code-inputs {
        gap: 6px;
    }

    .code-input {
        max-width: none;
        font-size: 20px;
    }

    .error-message {
        max-width: 100%;
        margin-top: 28px;
    }

    .loading-spinner {
        margin-top: 28px;
    }

    .login-link-text {
        margin-top: 36px;
        font-size: 13px;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    body {
        padding: 31px 10px; /* top = 40/36 × 28px for consistent ratio */
    }

    .logo-container {
        margin-bottom: 47px; /* 60/36 × 28px */
    }

    .logo {
        height: 28px;
    }

    .session-card {
        padding: 20px 19px; /* 16px + 20% */
    }

    .session-card-inner {
        max-width: 100%;
    }

    .session-title {
        font-size: 17px;
        margin-bottom: 28px;
    }

    .code-inputs {
        gap: 4px;
    }

    .code-input {
        font-size: 18px;
    }

    .error-message {
        margin-top: 24px;
    }

    .loading-spinner {
        margin-top: 24px;
    }

    .login-link-text {
        margin-top: 32px;
        font-size: 12px;
    }
}

/* Short viewport (mobile landscape) */
@media (max-height: 600px) {
    .session-title {
        margin-bottom: 20px;
    }

    .error-message {
        margin-top: 20px;
    }

    .loading-spinner {
        margin-top: 20px;
    }

    .login-link-text {
        margin-top: 24px;
    }
}

/* Mobile/tablet landscape: increased horizontal padding */
@media (orientation: landscape) and (max-width: 1024px) {
    .session-card {
        padding-left: 38px;   /* 32px + 20% */
        padding-right: 38px;
    }
}

/* Very short viewport (e.g. mobile landscape) */
@media (max-height: 500px) {
    body {
        padding: 31px 10px;
        min-height: 100vh;
        min-height: 100dvh;
    }

    .logo-container {
        margin-bottom: 47px; /* 60/36 × 28px */
    }

    .logo {
        height: 28px;
    }

    .session-card {
        max-width: 346px;
        padding: 20px 26px; /* 24px + 10% */
    }

    .session-card-inner {
        max-width: 294px; /* 6×44px + 5×6px gap */
    }

    .session-title {
        font-size: 18px;
        margin-bottom: 20px;
    }

    .code-inputs {
        gap: 6px;
    }

    .code-input {
        max-width: 44px;
    }

    .error-message {
        margin-top: 20px;
    }

    .loading-spinner {
        margin-top: 20px;
    }

    .login-link-text {
        margin-top: 24px;
        font-size: 13px;
    }
}

/* Tablet/mobile width + short height */
@media (max-width: 1024px) and (max-height: 500px) {
    body {
        padding-top: 29px; /* 40/36 × 26px for consistent ratio */
    }

    .logo-container {
        margin-bottom: 43px; /* 60/36 × 26px */
    }

    .logo {
        height: 26px;
    }

    .session-card {
        max-width: 346px;
        padding: 18px 26px; /* 24px + 10% */
    }

    .session-title {
        margin-bottom: 18px;
    }

    .error-message {
        margin-top: 18px;
    }

    .loading-spinner {
        margin-top: 18px;
    }

    .login-link-text {
        margin-top: 22px;
    }
}
