/* KYC Mini App Styles */

:root {
    --primary-color: #3390ec;
    --primary-dark: #2b7cd3;
    --success-color: #31b545;
    --error-color: #e53935;
    --warning-color: #ff9800;
    --bg-color: #ffffff;
    --text-color: #000000;
    --text-secondary: #707579;
    --border-color: #e0e0e0;
    --card-bg: #f5f5f5;
}

/* Telegram theme support */
body.tg-theme-dark {
    --bg-color: #212121;
    --text-color: #ffffff;
    --text-secondary: #aaaaaa;
    --border-color: #424242;
    --card-bg: #303030;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    padding-bottom: 100px;
}

#app {
    max-width: 500px;
    margin: 0 auto;
    padding: 16px;
}

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

.header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 16px;
}

.progress-bar {
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    margin-bottom: 12px;
    overflow: hidden;
}

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

.steps {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.step {
    flex: 1;
    text-align: center;
    padding: 4px;
    transition: color 0.3s;
}

.step.active {
    color: var(--primary-color);
    font-weight: 600;
}

.step.completed {
    color: var(--success-color);
}

/* Step Content */
.step-content {
    display: none;
    text-align: center;
    padding: 20px 0;
}

.step-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

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

.icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.step-content h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.step-content p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.5;
}

/* Camera Container */
.camera-container {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 auto 20px;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    aspect-ratio: 3/4;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.face-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 220px;
    border: 3px dashed rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    pointer-events: none;
}

/* Preview Container */
.preview-container {
    width: 100%;
    max-width: 320px;
    margin: 0 auto 20px;
}

.preview-container img {
    width: 100%;
    border-radius: 16px;
    margin-bottom: 12px;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 16px;
    padding: 40px 20px;
    margin-bottom: 20px;
    cursor: pointer;
    transition: border-color 0.3s, background-color 0.3s;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: rgba(51, 144, 236, 0.05);
}

.upload-area input {
    display: none;
}

.upload-area label {
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.upload-icon {
    font-size: 48px;
}

.upload-area span {
    font-weight: 500;
}

.upload-area small {
    color: var(--text-secondary);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 14px 28px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    max-width: 320px;
    margin: 8px auto;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

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

.btn-secondary:hover {
    background: var(--border-color);
}

/* Liveness Status */
.liveness-status {
    margin: 20px 0;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
}

.blink-counter {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

.liveness-indicator {
    font-size: 14px;
    color: var(--text-secondary);
}

.liveness-indicator.success {
    color: var(--success-color);
}

/* Result Card */
.result-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    margin: 20px auto;
    max-width: 320px;
    text-align: left;
}

.result-card h3 {
    margin-bottom: 16px;
    font-size: 16px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.result-item:last-child {
    border-bottom: none;
}

.result-item.total {
    font-weight: 600;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 2px solid var(--border-color);
}

.result-item .value {
    font-weight: 500;
}

.result-card.success {
    border: 2px solid var(--success-color);
}

.result-card.failure {
    border: 2px solid var(--error-color);
}

/* Loader */
.loader {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Toast Messages */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    animation: slideUp 0.3s ease;
}

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

/* Responsive */
@media (max-width: 400px) {
    .header h1 {
        font-size: 20px;
    }

    .steps {
        font-size: 10px;
    }

    .camera-container {
        max-width: 280px;
    }
}

/* Error States */
.error-message {
    background: var(--error-color);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    text-align: center;
    font-size: 14px;
}

.warning-message {
    background: var(--warning-color);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    text-align: center;
    font-size: 14px;
}

.success-message {
    background: var(--success-color);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    text-align: center;
    font-size: 14px;
}

/* Camera Permission */
.camera-permission {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
}

.camera-permission .icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.camera-permission p {
    margin-bottom: 20px;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--card-bg) 25%, var(--border-color) 50%, var(--card-bg) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Document Preview */
.document-preview {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
}

.document-preview img {
    width: 100%;
    display: block;
}

.document-preview .overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.document-preview:hover .overlay {
    opacity: 1;
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.pending {
    background: #fff3e0;
    color: #e65100;
}

.status-badge.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.error {
    background: #ffebee;
    color: #c62828;
}

.status-badge.processing {
    background: #e3f2fd;
    color: #1565c0;
}

/* Score Display */
.score-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 20px 0;
}

.score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    border: 4px solid var(--primary-color);
}

.score-circle.high {
    border-color: var(--success-color);
    color: var(--success-color);
}

.score-circle.medium {
    border-color: var(--warning-color);
    color: var(--warning-color);
}

.score-circle.low {
    border-color: var(--error-color);
    color: var(--error-color);
}

/* Instructions List */
.instructions {
    text-align: left;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 16px;
    margin: 16px 0;
}

.instructions h4 {
    margin-bottom: 12px;
    font-size: 14px;
}

.instructions ul {
    list-style: none;
    padding: 0;
}

.instructions li {
    padding: 8px 0;
    padding-left: 24px;
    position: relative;
    font-size: 14px;
    color: var(--text-secondary);
}

.instructions li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--success-color);
}

/* Mobile Enhancements */
@media (max-width: 360px) {
    #app {
        padding: 12px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 14px;
    }

    .camera-container {
        max-width: 100%;
        border-radius: 12px;
    }
}

/* Safe Area for notched phones */
@supports (padding-top: env(safe-area-inset-top)) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: calc(env(safe-area-inset-bottom) + 100px);
    }
}

/* Prevent text selection during camera use */
.camera-container * {
    user-select: none;
    -webkit-user-select: none;
}

/* Pulse animation for active recording */
.recording .face-guide {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { border-color: rgba(255, 255, 255, 0.6); }
    50% { border-color: rgba(49, 181, 69, 0.9); }
}

/* KYC Form */
.kyc-form {
    text-align: left;
    max-width: 400px;
    margin: 0 auto;
}

.kyc-form .form-group {
    margin-bottom: 20px;
}

.kyc-form .form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--text-color);
}

.kyc-form .form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    background: var(--bg-color);
    color: var(--text-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.kyc-form .form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(51, 144, 236, 0.1);
}

.kyc-form .form-input::placeholder {
    color: var(--text-secondary);
}

.kyc-form select.form-input {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

.kyc-form input[type="date"] {
    cursor: pointer;
}

.kyc-form .btn {
    margin-top: 10px;
}

/* Confirmation Dialog */
.dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.dialog-overlay.active {
    opacity: 1;
    visibility: visible;
}

.dialog {
    background: var(--bg-color);
    border-radius: 16px;
    padding: 24px;
    max-width: 320px;
    width: 90%;
    text-align: center;
}

.dialog h3 {
    margin-bottom: 12px;
}

.dialog p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.dialog-buttons {
    display: flex;
    gap: 12px;
}

.dialog-buttons .btn {
    flex: 1;
    margin: 0;
}
