/* WiseCrypto KYC Mini App — Telegram theme-aware */

:root {
    --tg-theme-bg-color: #ffffff;
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #999999;
    --tg-theme-link-color: #2481cc;
    --tg-theme-button-color: #2481cc;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #f0f0f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    -webkit-font-smoothing: antialiased;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 0 16px 16px;
    position: relative;
}

/* Progress Bar */
.progress-bar {
    height: 4px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: 2px;
    margin: 12px 0 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--tg-theme-button-color);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 20%;
}

.step-indicator {
    text-align: center;
    font-size: 13px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 12px;
}

/* Step Content */
.step-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 0;
    overflow: hidden;
}

.step-icon {
    font-size: 36px;
    margin-bottom: 6px;
}

.step-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.step-instruction {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
    max-width: 280px;
    line-height: 1.4;
    margin-bottom: 12px;
}

/* Camera Container */
.camera-container {
    flex: 1;
    width: 100%;
    max-width: 340px;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

.camera-container.camera-active video {
    display: block;
}

.camera-container.camera-front video {
    transform: scaleX(-1);
}

.camera-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
    position: absolute;
    top: 0;
    left: 0;
}

.camera-container.has-photo img {
    display: block;
}

.camera-container.has-photo video {
    display: none;
}

.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #999;
}

.camera-container.camera-active .camera-placeholder,
.camera-container.has-photo .camera-placeholder {
    display: none;
}

.camera-placeholder span {
    font-size: 12px;
}

/* Capture flash animation */
.camera-container.flash::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    animation: flashAnim 0.3s ease-out forwards;
    z-index: 10;
}

@keyframes flashAnim {
    0% { opacity: 0.8; }
    100% { opacity: 0; }
}

/* Buttons */
.actions {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    flex-shrink: 0;
}

.btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    opacity: 0.7;
}

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

.btn-primary {
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
}

.btn-secondary {
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.loading-overlay p {
    color: #ffffff;
    margin-top: 16px;
    font-size: 15px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Error Message */
.error-message {
    position: absolute;
    bottom: 80px;
    left: 16px;
    right: 16px;
    background: #ff3b30;
    color: #ffffff;
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    z-index: 50;
    animation: slideUp 0.3s ease;
}

.error-message p {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.4;
}

.error-message .btn {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

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

/* Result Screen */
.result-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
    background: var(--tg-theme-bg-color);
    z-index: 200;
}

.result-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.result-screen h2 {
    font-size: 22px;
    margin-bottom: 12px;
}

.result-screen p {
    font-size: 14px;
    color: var(--tg-theme-hint-color);
    margin-bottom: 32px;
    line-height: 1.5;
    max-width: 280px;
}

.result-screen .btn {
    width: 100%;
    max-width: 280px;
}
