/* Loading Screen Styles */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    min-width: 100vw;
    min-height: 100vh;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeOut 0.5s ease-out 3.5s forwards;
    overflow: hidden;
    box-sizing: border-box;
}

.loading-content {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4vw;
    width: 100%;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    flex-wrap: nowrap;
    overflow: hidden;
    max-width: 100vw;
    max-height: 100vh;
}

/* Mobile adjustments for loading content */
@media (max-width: 768px) {
    .loading-content {
        gap: 2vw;
        padding: 10px;
        width: 100vw;
        height: 100vh;
    }
}

@media (max-width: 480px) {
    .loading-content {
        gap: 10px;
        padding: 5px;
        width: 100vw;
        height: 100vh;
    }
    
    .loading-screen {
        width: 100vw;
        height: 100vh;
    }
}

/* Prevent overflow on all devices - already defined above, this is redundant but ensures it */

/* Allow shrinking on mobile */
@media (max-width: 768px) {
    .rotating-circle,
    .fixed-text {
        flex-shrink: 1;
        flex-grow: 0;
    }
}

.logo-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 4vw;
    width: 100%;
    max-width: 1400px;
    height: 100%;
    padding: 20px;
    box-sizing: border-box;
    flex-wrap: nowrap;
    overflow: hidden;
}

/* Mobile adjustments for logo container */
@media (max-width: 768px) {
    .logo-container {
        gap: 2vw;
        padding: 10px;
        width: 100%;
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .logo-container {
        gap: 10px;
        padding: 5px;
        width: 100%;
        max-width: 100%;
        flex-wrap: wrap;
    }
}

/* Ensure images scale properly on all devices */
.circle-image,
.text-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    image-rendering: auto;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.rotating-circle {
    width: min(35vw, 400px);
    height: min(35vw, 400px);
    min-width: 80px;
    min-height: 80px;
    max-width: 400px;
    max-height: 400px;
    position: relative;
    animation: rotate 3s linear infinite, shrinkCircle 0.5s ease-out 3.5s forwards;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 1;
    box-sizing: border-box;
}

.circle-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}

.fixed-text {
    width: min(40vw, 500px);
    height: min(32vw, 400px);
    min-width: 100px;
    min-height: 80px;
    max-width: 500px;
    max-height: 400px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 1;
    animation: centerAndGrow 0.8s ease-out 3.2s forwards;
    box-sizing: border-box;
}

.text-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}

/* Responsive animation adjustments for mobile */
@media (max-width: 768px) {
    .fixed-text {
        animation: centerAndGrowMobile 0.8s ease-out 3.2s forwards;
    }
}

@media (max-width: 480px) {
    .fixed-text {
        animation: centerAndGrowSmall 0.8s ease-out 3.2s forwards;
    }
}

@keyframes centerAndGrowMobile {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(calc(-50vw + 20%)) scale(2);
        opacity: 0;
    }
}

@keyframes centerAndGrowSmall {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(calc(-50vw + 15%)) scale(1.8);
        opacity: 0;
    }
}

@keyframes centerAndGrow {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(calc(-50vw + 25%)) scale(2.5);
        opacity: 0;
    }
}

.text-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
}

@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes shrinkCircle {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0);
        opacity: 0;
    }
}

.main-content {
    animation: fadeIn 0.5s ease-in;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        visibility: hidden;
    }
}

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

/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Ensure body and html don't cause overflow */
html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #ffffff;
    color: #333333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Container */
.container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

/* Login Card */
.login-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 40px 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
    border: 1px solid #f0f0f0;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.welcome-text {
    font-size: 32px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.app-name {
    font-size: 18px;
    color: #666666;
    font-weight: 500;
}

.egov {
    color: #2563eb;
    font-weight: 600;
}

.ph {
    color: #1a1a1a;
    font-size: 18px;
    font-weight: 600;
}

/* Forms Container */
.forms-container {
    position: relative;
    margin-bottom: 30px;
}

.login-form {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.login-form.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* Input Groups */
.input-group {
    position: relative;
    margin-bottom: 20px;
}

/* Email login: white wrapper + shadow (index.php #emailForm) */
#emailForm .input-group {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}

.input-group input {
    width: 100%;
    padding: 16px 20px;
    border: 1px solid #565657;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    background: #ffffff;
    transition: all 0.3s ease;
    outline: none;
}


.input-group input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

/* Country Code for Mobile */
.country-code {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 2;
    pointer-events: none;
}

.flag-icon {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    object-fit: cover;
}

.code {
    font-size: 16px;
    font-weight: 500;
    color: #374151;
}

#mobile {
    padding-left: 80px;
}

/* Switch Link */
.switch-link {
    display: block;
    text-align: center;
    color: #2563eb;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 24px;
    transition: color 0.3s ease;
}

.switch-link:hover {
    color: #1d4ed8;
    text-decoration: underline;
}

/* Login Button */
.login-btn {
    width: 50%;
    margin-left: 25%;
    padding: 16px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #ffffff;
    border: none;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 30px;
}

.login-btn:hover {
    background: linear-gradient(135deg, #007bff 0%, #0057b3bc 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 100, 235, 0.461);
}

.login-btn:active {
    transform: translateY(0);
}

/* Separator */
.separator {
    display: flex;
    align-items: center;
    margin-bottom: 30px;
}

.line {
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.or-text {
    padding: 0 20px;
    color: #9ca3af;
    font-size: 14px;
    font-weight: 500;
}

/* Create Account */
.create-account {
    text-align: center;
}

.account-text {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 16px;
    font-weight: 500;
}

.create-btn {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: #ffffff;
    border: none;
    border-radius: 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.create-btn:hover {
    background: linear-gradient(135deg, #007bff 0%, #0057b3bc 100%);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 100, 235, 0.436);
}

.create-btn:active {
    transform: translateY(0);
}

/* Responsive Design - Loading Screen */
/* Tablet and smaller desktop */
@media (max-width: 1024px) {
    .rotating-circle {
        width: min(30vw, 350px);
        height: min(30vw, 350px);
    }
    
    .fixed-text {
        width: min(35vw, 450px);
        height: min(28vw, 350px);
    }
    
    .logo-container {
        gap: 3vw;
    }
    
    .loading-content {
        gap: 3vw;
    }
}

/* Tablet portrait */
@media (max-width: 768px) {
    .rotating-circle {
        width: min(22vw, 200px);
        height: min(22vw, 200px);
        min-width: 100px;
        min-height: 100px;
        max-width: 200px;
        max-height: 200px;
    }
    
    .fixed-text {
        width: min(26vw, 240px);
        height: min(20vw, 180px);
        min-width: 120px;
        min-height: 90px;
        max-width: 240px;
        max-height: 180px;
    }
    
    .logo-container {
        gap: 2.5vw;
        padding: 15px;
    }
    
    .loading-content {
        gap: 2.5vw;
        padding: 15px;
    }
}

/* Mobile landscape and large phones */
@media (max-width: 768px) and (orientation: landscape) {
    .rotating-circle {
        width: min(20vh, 200px);
        height: min(20vh, 200px);
        min-width: 150px;
        min-height: 150px;
    }
    
    .fixed-text {
        width: min(25vh, 250px);
        height: min(20vh, 200px);
        min-width: 180px;
        min-height: 140px;
    }
    
    .logo-container {
        gap: 2vw;
        padding: 10px;
    }
    
    .loading-content {
        gap: 2vw;
        padding: 10px;
    }
}

/* Medium phones */
@media (max-width: 480px) {
    .container {
        padding: 16px;
    }
    
    .login-card {
        padding: 30px 20px;
        border-radius: 12px;
    }
    
    .welcome-text {
        font-size: 28px;
    }
    
    .app-name {
        font-size: 16px;
    }
    
    .loading-screen {
        width: 100vw !important;
        height: 100vh !important;
        min-width: 100vw !important;
        min-height: 100vh !important;
    }
    
    .rotating-circle {
        width: min(15vw, 100px) !important;
        height: min(15vw, 100px) !important;
        min-width: 50px !important;
        min-height: 50px !important;
        max-width: 100px !important;
        max-height: 100px !important;
    }
    
    .fixed-text {
        width: min(16vw, 90px) !important;
        height: min(13vw, 75px) !important;
        min-width: 50px !important;
        min-height: 40px !important;
        max-width: 90px !important;
        max-height: 75px !important;
    }
    
    .logo-container {
        gap: 5px !important;
        padding: 3px !important;
        flex-wrap: nowrap;
        width: 100% !important;
        max-width: 100vw !important;
        height: auto !important;
    }
    
    .loading-content {
        gap: 5px !important;
        padding: 3px !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
    }
    
    /* Ensure images don't overflow */
    .circle-image,
    .text-image {
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
    }
    
    /* Reduce login button size on mobile */
    .login-btn {
        font-size: 14px !important;
        padding: 14px !important;
    }
    
    .login-btn.loading {
        font-size: 13px !important;
    }
}

/* Medium phones landscape */
@media (max-width: 480px) and (orientation: landscape) {
    .rotating-circle {
        width: min(12vh, 100px) !important;
        height: min(12vh, 100px) !important;
        min-width: 60px !important;
        min-height: 60px !important;
        max-width: 100px !important;
        max-height: 100px !important;
    }
    
    .fixed-text {
        width: min(13vh, 100px) !important;
        height: min(10vh, 80px) !important;
        min-width: 60px !important;
        min-height: 45px !important;
        max-width: 100px !important;
        max-height: 80px !important;
    }
    
    .logo-container {
        gap: 5px !important;
        padding: 3px !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .loading-content {
        gap: 5px !important;
        padding: 3px !important;
        width: 100vw !important;
        height: 100vh !important;
    }
}

/* Small phones */
@media (max-width: 360px) {
    .welcome-text {
        font-size: 24px;
    }
    
    .login-card {
        padding: 24px 16px;
    }
    
    .loading-screen {
        width: 100vw !important;
        height: 100vh !important;
    }
    
    .rotating-circle {
        width: min(18vw, 100px) !important;
        height: min(18vw, 100px) !important;
        min-width: 50px !important;
        min-height: 50px !important;
        max-width: 100px !important;
        max-height: 100px !important;
    }
    
    .fixed-text {
        width: min(22vw, 130px) !important;
        height: min(18vw, 100px) !important;
        min-width: 70px !important;
        min-height: 55px !important;
        max-width: 130px !important;
        max-height: 100px !important;
    }
    
    .logo-container {
        gap: 5px !important;
        padding: 3px !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .loading-content {
        gap: 5px !important;
        padding: 3px !important;
        width: 100vw !important;
        height: 100vh !important;
    }
}

/* Small phones landscape */
@media (max-width: 360px) and (orientation: landscape) {
    .rotating-circle {
        width: min(12vh, 90px);
        height: min(12vh, 90px);
        min-width: 50px;
        min-height: 50px;
    }
    
    .fixed-text {
        width: min(16vh, 110px);
        height: min(12vh, 85px);
        min-width: 70px;
        min-height: 55px;
    }
    
    .logo-container {
        gap: 8px;
        padding: 6px;
    }
    
    .loading-content {
        gap: 8px;
        padding: 6px;
    }
}

/* Very small phones */
@media (max-width: 320px) {
    .loading-screen {
        width: 100vw !important;
        height: 100vh !important;
    }
    
    .rotating-circle {
        width: min(18vw, 90px) !important;
        height: min(18vw, 90px) !important;
        min-width: 45px !important;
        min-height: 45px !important;
        max-width: 90px !important;
        max-height: 90px !important;
    }
    
    .fixed-text {
        width: min(18vw, 85px) !important;
        height: min(15vw, 70px) !important;
        min-width: 45px !important;
        min-height: 35px !important;
        max-width: 85px !important;
        max-height: 70px !important;
    }
    
    .logo-container {
        gap: 4px !important;
        padding: 2px !important;
        flex-wrap: nowrap;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .loading-content {
        gap: 4px !important;
        padding: 2px !important;
        width: 100vw !important;
        height: 100vh !important;
    }
    
    /* Ensure images don't overflow on very small screens */
    .circle-image,
    .text-image {
        max-width: 100% !important;
        max-height: 100% !important;
        object-fit: contain !important;
    }
}

/* Very small phones landscape */
@media (max-width: 320px) and (orientation: landscape) {
    .rotating-circle {
        width: min(10vh, 80px) !important;
        height: min(10vh, 80px) !important;
        min-width: 45px !important;
        min-height: 45px !important;
        max-width: 80px !important;
        max-height: 80px !important;
    }
    
    .fixed-text {
        width: min(14vh, 100px) !important;
        height: min(10vh, 75px) !important;
        min-width: 60px !important;
        min-height: 50px !important;
        max-width: 100px !important;
        max-height: 75px !important;
    }
    
    .logo-container {
        gap: 3px !important;
        padding: 2px !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    .loading-content {
        gap: 3px !important;
        padding: 2px !important;
        width: 100vw !important;
        height: 100vh !important;
    }
}

/* Short screens (landscape phones, etc.) */
@media (max-height: 600px) {
    .rotating-circle {
        width: min(20vh, 200px) !important;
        height: min(20vh, 200px) !important;
        min-width: 80px !important;
        min-height: 80px !important;
        max-width: 200px !important;
        max-height: 200px !important;
    }
    
    .fixed-text {
        width: min(25vh, 250px) !important;
        height: min(20vh, 180px) !important;
        min-width: 100px !important;
        min-height: 70px !important;
        max-width: 250px !important;
        max-height: 180px !important;
    }
    
    .logo-container {
        gap: 1vw !important;
        padding: 5px !important;
    }
    
    .loading-content {
        gap: 1vw !important;
        padding: 5px !important;
    }
}

/* Very short screens */
@media (max-height: 500px) {
    .rotating-circle {
        width: min(18vh, 180px) !important;
        height: min(18vh, 180px) !important;
        min-width: 70px !important;
        min-height: 70px !important;
        max-width: 180px !important;
        max-height: 180px !important;
    }
    
    .fixed-text {
        width: min(22vh, 220px) !important;
        height: min(18vh, 160px) !important;
        min-width: 90px !important;
        min-height: 65px !important;
        max-width: 220px !important;
        max-height: 160px !important;
    }
    
    .logo-container {
        gap: 1vw !important;
        padding: 3px !important;
    }
    
    .loading-content {
        gap: 1vw !important;
        padding: 3px !important;
    }
}

/* Extra short screens */
@media (max-height: 400px) {
    .rotating-circle {
        width: min(16vh, 160px) !important;
        height: min(16vh, 160px) !important;
        min-width: 60px !important;
        min-height: 60px !important;
        max-width: 160px !important;
        max-height: 160px !important;
    }
    
    .fixed-text {
        width: min(20vh, 200px) !important;
        height: min(16vh, 140px) !important;
        min-width: 80px !important;
        min-height: 60px !important;
        max-width: 200px !important;
        max-height: 140px !important;
    }
    
    .logo-container {
        gap: 1vw !important;
        padding: 2px !important;
    }
    
    .loading-content {
        gap: 1vw !important;
        padding: 2px !important;
    }
}

/* Error Message Styling */
.error-message {
    color: #ef4444;
    font-size: 14px;
    font-weight: 500;
    margin-top: 8px;
    text-align: left;
    line-height: 1.4;
    animation: slideDown 0.3s ease;
}

/* Input Error State */
.input-group input.error {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.input-group input.error:focus {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Focus and Accessibility */

/* Loading State */
.login-btn.loading {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.login-btn.loading:hover {
    transform: none;
    box-shadow: none;
}
