/* ========================================
   SIGN-IN/OUT PAGE STYLESHEET
   ======================================== */

/* ========================================
   GLOBAL & SMOOTH SCROLL
   ======================================== */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Body & General */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #f5f5f7 0%, #efefef 100%);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-touch-callout: none;
    touch-action: pan-y;
    min-height: 100vh;
}

/* ========================================
   CONTAINER & CARD LAYOUT
   ======================================== */
.container {
    max-width: 500px;
    padding: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card {
    border-radius: 24px;
    border: none;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    background: #fff;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}

.card:hover {
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.12);
}

.card-body {
    padding: 24px;
}

/* ========================================
   LOGO & BRANDING
   ======================================== */
.navbar-brand {
    animation: fadeInDown 0.6s ease-out;
    opacity: 0.95;
    transition: opacity 0.3s ease;
}

.navbar-brand:hover {
    opacity: 1;
}

.navbar-brand img {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.navbar-brand:hover img {
    transform: scale(1.02);
}

/* ========================================
   ALERTS & WARNINGS
   ======================================== */
#browserWarning,
#privateBrowsingWarning,
#desktopWarning {
    display: none;
    margin-bottom: 20px;
    border-radius: 12px;
    border: 1px solid;
    animation: slideDown 0.4s ease-out;
}

.alert {
    border-radius: 12px;
    animation: slideInLeft 0.4s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.alert-danger {
    background-color: #fff5f5;
    border-color: #ffd6d6;
    color: #c41e3a;
}

.alert-info {
    background-color: #f0f8ff;
    border-color: #d1e7ff;
    color: #0055cc;
}

/* ========================================
   FORM ELEMENTS
   ======================================== */
.form-control,
.form-select {
    border-radius: 12px;
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    font-size: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-color: #fff;
    will-change: border-color, box-shadow;
}

.form-control:focus,
.form-select:focus {
    border-color: #0d6efd;
    outline: none;
    box-shadow: 0 0 0 0.3rem rgba(13, 110, 253, 0.15);
    background-color: #f8f9ff;
}

.form-control:active,
.form-select:active {
    box-shadow: 0 0 0 0.4rem rgba(13, 110, 253, 0.2);
}

.form-control::placeholder {
    color: #999;
    font-weight: 500;
}

.form-label {
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    font-size: 0.95rem;
    transition: color 0.3s ease;
}

.form-control:focus ~ .form-label,
.form-select:focus ~ .form-label {
    color: #0d6efd;
}

.mb-3 {
    margin-bottom: 16px;
    animation: fadeIn 0.4s ease-out;
}

/* Invalid state */
.is-invalid {
    border-color: #ff3b30 !important;
    animation: shake 0.3s ease-out;
}

.is-invalid:focus {
    box-shadow: 0 0 0 0.3rem rgba(255, 59, 48, 0.15);
}

/* Auto-filled state */
.auto-filled {
    background: linear-gradient(#fff, #fff) padding-box,
                linear-gradient(135deg, #28a745, #20c997) border-box;
    border: 2px solid transparent;
    animation: borderGlow 0.4s ease-out;
}

/* ========================================
   CAMERA CONTAINER
   ======================================== */
.camera-container {
    width: 100%;
    height: 320px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    border-radius: 20px;
    overflow: hidden;
    margin: 20px 0;
    position: relative;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    animation: zoomIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

video,
canvas {
    width: 100%;
    height: 320px;
    object-fit: cover;
    border-radius: 20px;
    display: block;
    transition: filter 0.3s ease;
}

video:active,
canvas:active {
    filter: brightness(0.95);
}

canvas {
    display: none;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    border-radius: 12px;
    font-weight: 600;
    padding: 12px 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-tap-highlight-color: transparent;
    border: none;
    position: relative;
    overflow: hidden;
    will-change: transform, box-shadow, background-color;
    min-height: 44px;
}

.btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn:active::before {
    width: 300px;
    height: 300px;
}

.btn-sm {
    font-size: 13px;
    padding: 6px 12px;
    min-height: 36px;
}

#captureButton,
#retakeButton {
    width: 65%;
    max-width: 260px;
    margin: 12px auto;
    display: block;
    border-radius: 14px;
    padding: 14px;
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: 0.5px;
}

#retakeButton {
    display: none;
}

#captureButton {
    background: linear-gradient(135deg, #ff3b30 0%, #ff453a 100%);
    color: white;
}

#captureButton:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 59, 48, 0.3);
}

#captureButton:active:not(:disabled) {
    transform: translateY(-1px);
}

#captureButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#retakeButton {
    background: linear-gradient(135deg, #ffa500 0%, #ffb900 100%);
    color: white;
}

#retakeButton:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 165, 0, 0.3);
}

.btn-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
}

.btn-success:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
    background: linear-gradient(135deg, #218838 0%, #1aa179 100%);
}

.btn-success:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-success:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: linear-gradient(135deg, #6c757d 0%, #5a6268 100%);
    color: white;
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(108, 117, 125, 0.2);
}

.btn-outline-primary {
    color: #0d6efd;
    border: 2px solid #0d6efd;
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-outline-primary:hover {
    background: #0d6efd;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.2);
}

/* ========================================
   GUEST FIELDS
   ======================================== */
#guestFields {
    background: linear-gradient(135deg, #f8f9fa 0%, #efefef 100%);
    padding: 16px;
    border-radius: 14px;
    margin-bottom: 16px;
    border: 2px dashed #dee2e6;
    animation: slideInDown 0.4s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#guestFields h6 {
    color: #666;
    font-size: 0.8rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 14px;
    font-weight: 700;
}

/* ========================================
   SITE START TIME INFO
   ======================================== */
.site-start-time-info {
    background: linear-gradient(135deg, #e8f5e8 0%, #d4edda 100%);
    border: 2px solid #28a745;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 16px;
    display: none;
    animation: slideInDown 0.4s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.site-start-time-info:hover {
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.15);
}

.site-start-time-info .badge {
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 8px;
    background: linear-gradient(135deg, #28a745, #20c997);
    font-weight: 600;
}

.site-start-time-info small {
    color: #5a7d5f;
    font-weight: 500;
}

/* ========================================
   TIME ADJUSTMENT INFO
   ======================================== */
#timeAdjustmentInfo {
    border-radius: 12px;
    border-left: 4px solid #0d6efd;
    background: linear-gradient(135deg, #f0f8ff 0%, #e7f1ff 100%);
    animation: slideInLeft 0.4s ease-out;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 12px 14px;
}

#timeAdjustmentInfo:hover {
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.1);
}

#timeAdjustmentInfo i {
    color: #0d6efd;
    margin-right: 8px;
    animation: pulse 2s infinite;
}

/* ========================================
   ERROR MESSAGES
   ======================================== */
#idError,
#idNotFoundError,
#signInMessage {
    display: none;
    font-weight: 600;
    margin-top: 8px;
    animation: shake 0.3s ease-out;
    color: #ff3b30;
}

/* ========================================
   FORGOTTEN LINK
   ======================================== */
.forgotten-link {
    text-align: center;
    margin-top: 24px;
    padding: 12px;
    animation: fadeIn 0.6s ease-out;
}

.forgotten-link a {
    color: #dc3545;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
}

.forgotten-link a:hover {
    color: #c41e3a;
    background: rgba(220, 53, 69, 0.1);
    transform: translateX(4px);
}

/* ========================================
   LOADING OVERLAY
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-overlay.visible {
    display: flex;
    opacity: 1;
}

.loading-content {
    text-align: center;
    position: relative;
}

.loading-logo {
    max-width: 140px;
    margin-bottom: 32px;
    animation: pulse 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

.spinner-ring {
    display: inline-block;
    width: 64px;
    height: 64px;
    position: relative;
}

.spinner-ring::after {
    content: '';
    position: absolute;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: 4px solid;
    border-color: #0d6efd transparent #0d6efd transparent;
    animation: spinRing 1.2s linear infinite;
}

.loading-text {
    margin-top: 24px;
    font-weight: 700;
    color: #333;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    animation: fadeIn 0.6s ease-out;
}

.debug-timestamp {
    color: #6c757d;
    font-weight: 700;
    margin-right: 6px;
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

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

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

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

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

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

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-4px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(4px);
    }
}

@keyframes borderGlow {
    0% {
        box-shadow: 0 0 0 rgba(40, 167, 69, 0.3);
    }
    50% {
        box-shadow: 0 0 12px rgba(40, 167, 69, 0.2);
    }
    100% {
        box-shadow: 0 0 0 rgba(40, 167, 69, 0.1);
    }
}

/* ========================================
   iOS & MOBILE OPTIMIZATION
   ======================================== */

/* Minimum touch target size */
button,
a,
input[type="button"],
input[type="submit"],
.btn {
    min-height: 44px;
}

/* Remove iOS input zoom */
@media (max-width: 768px) {
    input,
    textarea,
    select {
        font-size: 16px;
    }
    
    .card-body {
        padding: 18px;
    }
    
    .container {
        padding: 12px;
    }
    
    .camera-container {
        height: 280px;
        margin: 16px 0;
    }
    
    video,
    canvas {
        height: 280px;
    }
    
    #captureButton,
    #retakeButton {
        width: 70%;
        margin: 10px auto;
    }
}

/* iOS Safari specific */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-user-select: none;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    input,
    textarea,
    select {
        -webkit-user-select: text;
    }
    
    button,
    a,
    .btn {
        -webkit-user-select: none;
        -webkit-touch-callout: default;
    }
}

/* ========================================
   SCROLLBAR STYLING
   ======================================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
    transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.disabled-form {
    opacity: 0.6;
    pointer-events: none;
    filter: grayscale(0.5);
}

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

.text-danger {
    color: #ff3b30;
}

.text-muted {
    color: #999;
}

/* Button links in footer */
.btn-link {
    background: none;
    color: #0d6efd;
    padding: 8px 16px;
}
