/* Global Variable & Style Tokens */
:root {
    --color-bg-base: #f5f3ef; /* Warm cream */
    --color-primary: #10b981; /* Forest green */
    --color-primary-hover: #059669;
    
    --text-dark: #1e293b;
    --text-muted: #475569;
    --text-dim: #64748b;
    
    --border-soft: #e2e8f0;
    --border-card-hover: rgba(16, 185, 129, 0.4);
    
    --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 20px 45px rgba(0, 0, 0, 0.15);
    
    --font-sans: 'Zilla Slab', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --border-radius-lg: 24px;
    --border-radius-md: 16px;
    --border-radius-sm: 10px;
    
    --transition-cozy: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    scroll-behavior: smooth;
}

body {
    background-color: var(--color-bg-base);
    color: var(--text-dark);
    font-family: var(--font-sans);
    font-weight: 500;
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Background Image Container */
.background-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image: url('assets/background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transform: scale(1.02); /* Slight scale to prevent edge bleed */
}

/* Overlay for dusk/sunset look and text legibility */
.sunset-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(185deg, rgba(254, 215, 170, 0.15) 0%, rgba(20, 20, 30, 0.45) 80%);
}

/* Cozy Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-family: var(--font-sans);
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all var(--transition-cozy);
    text-decoration: none;
    border: none;
    user-select: none;
}

.btn-primary {
    background: #10b981;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.9);
    color: var(--text-dark);
    border: 2px solid var(--border-soft);
}

.btn-secondary:hover {
    background: #ffffff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: var(--border-radius-sm);
}

.btn-block {
    width: 100%;
}

/* ==========================================================
   1. LOGIN SCREEN STYLING
   ========================================================== */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    z-index: 10;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.login-wrapper.hidden {
    opacity: 0;
    transform: scale(0.95);
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
}

.login-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: var(--border-radius-lg);
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 40px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    text-align: center;
    /* animation handled by JS */
}

@keyframes popup {
    from { opacity: 0; transform: translateY(20px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.cabin-icon {
    font-size: 4rem;
    margin-bottom: 8px;
    display: inline-block;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.1));
    animation: sway 4s infinite alternate ease-in-out;
}

@keyframes sway {
    0% { transform: rotate(-5deg); }
    100% { transform: rotate(5deg); }
}

.login-title {
    font-size: 2.2rem;
    font-weight: 750;
    color: var(--text-dark);
    margin-bottom: 2px;
}

.login-subtitle {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-bottom: 30px;
}

.login-step {
    display: none;
    text-align: left;
}

.login-step.active {
    display: block;
    animation: slideIn 0.3s ease;
}

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

.step-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.input-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    background: #ffffff;
    border: 2px solid var(--border-soft);
    border-radius: var(--border-radius-sm);
    padding: 12px 16px;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-dark);
    outline: none;
    transition: all var(--transition-cozy);
}

.form-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.text-center {
    text-align: center;
}

.font-mono {
    font-family: var(--font-mono) !important;
    font-weight: 700;
    letter-spacing: 4px;
}

.login-button-row {
    display: flex;
    gap: 12px;
}

.flex-grow {
    flex-grow: 1;
}

/* PIN Inputs */
.pin-hint {
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
    margin-bottom: 18px;
    text-align: center;
}

.pin-inputs {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 6px;
}

.pin-digit {
    width: 48px;
    height: 56px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--border-radius-sm);
    outline: none;
    transition: all var(--transition-cozy);
    caret-color: transparent;
}

.pin-digit:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.3);
    background: #ffffff;
}

.pin-digit.filled {
    border-color: rgba(16, 185, 129, 0.6);
}

/* Error message */
.auth-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: var(--border-radius-sm);
    color: #fecaca;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 12px;
    margin-bottom: 14px;
    text-align: center;
}

/* Resend button */
.resend-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 14px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all var(--transition-cozy);
    display: block;
    width: 100%;
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.resend-btn:hover {
    color: #ffffff;
}

/* Loading spinner on buttons */
.btn.loading {
    opacity: 0.7;
    pointer-events: none;
    cursor: not-allowed;
}


/* ==========================================================
   2. DASHBOARD STYLING
   ========================================================== */
.dashboard-wrapper {
    display: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.dashboard-wrapper.visible {
    display: block;
    opacity: 1;
}

/* Floating Status Pill (top-right) */
.status-floating {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    padding: 8px 16px;
    border-radius: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    animation: fadeSlideDown 0.5s ease 0.3s both;
}

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

.status-pulse {
    width: 8px;
    height: 8px;
    background-color: var(--color-primary);
    border-radius: 50%;
    animation: pulse-cozy 1.8s infinite;
    flex-shrink: 0;
}

@keyframes pulse-cozy {
    0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.status-text {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-muted);
}

.sign-out-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: all var(--transition-cozy);
}

.sign-out-btn:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.08);
}

.sign-out-btn svg {
    width: 16px;
    height: 16px;
}

/* Main Content */
.main-content {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

/* Services Grid & Cards */
.services-section {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

.services-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.service-card {
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 2px solid rgba(255, 255, 255, 0.7);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    transition: all var(--transition-cozy);
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    animation: cardAppear 0.5s ease both;
}

.service-card:nth-child(1) { animation-delay: 0.1s; }
.service-card:nth-child(2) { animation-delay: 0.18s; }
.service-card:nth-child(3) { animation-delay: 0.26s; }
.service-card:nth-child(4) { animation-delay: 0.34s; }
.service-card:nth-child(5) { animation-delay: 0.42s; }

@keyframes cardAppear {
    from { opacity: 0; transform: translateY(20px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.service-card:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
    border-color: var(--border-card-hover);
}

.service-card:active {
    transform: translateY(-2px) scale(0.99);
    transition-duration: 0.1s;
}

/* Card Image */
.card-image {
    width: 100%;
    height: 180px;
    overflow: hidden;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    position: relative;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.service-card:hover .card-image img {
    transform: scale(1.06);
}

/* Card Name */
.service-name {
    font-size: 1.15rem;
    font-weight: 750;
    color: var(--text-dark);
    padding: 16px 20px 18px 20px;
    text-align: center;
    letter-spacing: 0.3px;
}

/* Footer */
.site-footer {
    padding: 30px 20px;
    text-align: center;
    margin-top: 40px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    border-top: 2px solid var(--border-soft);
}

.site-footer p {
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Media Queries */
@media (max-width: 600px) {
    .login-card {
        padding: 30px 20px;
    }
    
    .services-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .card-image {
        height: 160px;
    }
    
    .status-floating {
        top: 12px;
        right: 12px;
        padding: 6px 12px;
    }
    
    .main-content {
        padding: 80px 16px 40px 16px;
    }
}

@media (max-width: 400px) {
    .services-grid {
        grid-template-columns: 1fr;
    }
}
