/**
 * Avatar Cropper & Front Camera Capture Styles
 * Designed for mobile-first experience
 */

/* Source Selection Bottom Sheet Modal */
.avatar-action-sheet-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 10050;
    display: none;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.avatar-action-sheet-backdrop.active {
    display: flex;
    opacity: 1;
}

.avatar-action-sheet {
    background: #ffffff;
    width: 100%;
    max-width: 480px;
    border-radius: 24px 24px 0 0;
    padding: 20px 20px 30px;
    box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.avatar-action-sheet-backdrop.active .avatar-action-sheet {
    transform: translateY(0);
}

.avatar-sheet-handle {
    width: 40px;
    height: 5px;
    background: #cbd5e1;
    border-radius: 4px;
    margin: 0 auto 16px;
}

.avatar-sheet-title {
    font-size: 17px;
    font-weight: 700;
    color: #1e293b;
    text-align: center;
    margin-bottom: 6px;
}

.avatar-sheet-subtitle {
    font-size: 13px;
    color: #64748b;
    text-align: center;
    margin-bottom: 20px;
}

.avatar-sheet-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.avatar-option-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    padding: 18px 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    color: #1e293b;
}

.avatar-option-btn:hover,
.avatar-option-btn:active {
    background: #eff6ff;
    border-color: #3b82f6;
    color: #1d4ed8;
    transform: translateY(-2px);
}

.avatar-option-icon {
    font-size: 32px;
    margin-bottom: 8px;
    line-height: 1;
}

.avatar-option-label {
    font-size: 14px;
    font-weight: 600;
}

.avatar-sheet-cancel {
    width: 100%;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    background: #f1f5f9;
    color: #475569;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.avatar-sheet-cancel:hover {
    background: #e2e8f0;
}

/* =========================================================
   Live Front Camera Modal
   ========================================================= */
.camera-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000000;
    z-index: 10060;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    box-sizing: border-box;
}

.camera-modal-backdrop.active {
    display: flex;
}

.camera-header {
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    color: #ffffff;
}

.camera-title {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.camera-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.camera-viewport {
    position: relative;
    width: 100%;
    max-width: 420px;
    height: 60vh;
    max-height: 520px;
    border-radius: 20px;
    overflow: hidden;
    background: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
}

#cameraVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#cameraVideo.mirror-mode {
    transform: scaleX(-1);
}

.camera-face-guide {
    position: absolute;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    border: 2px dashed rgba(255, 255, 255, 0.85);
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.45);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-face-guide::after {
    content: "चेहरा यहाँ रखें (Keep face inside)";
    position: absolute;
    bottom: 15px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 11px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 8px;
    border-radius: 12px;
}

.camera-controls {
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 10;
    padding: 10px 0;
}

.camera-switch-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #ffffff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.camera-shutter-btn {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: #ffffff;
    border: 4px solid rgba(255, 255, 255, 0.5);
    outline: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.camera-shutter-btn:active {
    transform: scale(0.92);
}

.camera-shutter-inner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #e11d48;
}

/* =========================================================
   Circular Crop & Adjust Modal
   ========================================================= */
.cropper-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 15, 29, 0.95);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 10070;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    box-sizing: border-box;
    overflow-y: auto;
}

.cropper-modal-backdrop.active {
    display: flex;
}

.cropper-header {
    width: 100%;
    max-width: 480px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #ffffff;
    margin-bottom: 12px;
}

.cropper-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.cropper-sub-hint {
    font-size: 12px;
    color: #94a3b8;
    text-align: center;
    margin-bottom: 10px;
}

/* Interactive Crop Area */
.cropper-viewport-container {
    position: relative;
    width: 100%;
    max-width: 340px;
    height: 340px;
    margin: 0 auto;
    border-radius: 20px;
    overflow: hidden;
    background: #0f172a;
    touch-action: none; /* Prevents page scroll when dragging photo */
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
}

.cropper-viewport-container:active {
    cursor: grabbing;
}

.cropper-image-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Circular Mask Overlay */
.cropper-circle-mask {
    position: absolute;
    width: 260px;
    height: 260px;
    border-radius: 50%;
    border: 2.5px solid #38bdf8;
    box-shadow: 0 0 0 9999px rgba(15, 23, 42, 0.75), 0 0 15px rgba(56, 189, 248, 0.4);
    pointer-events: none;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

.cropper-circle-mask::after {
    content: "↕ ↔ Drag & Pinch to adjust";
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    font-weight: 500;
}

/* Controls Toolbars */
.cropper-controls-wrapper {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 15px;
}

.cropper-zoom-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.08);
    padding: 8px 16px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.cropper-zoom-icon {
    font-size: 16px;
    color: #94a3b8;
    user-select: none;
}

.cropper-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: #334155;
    outline: none;
}

.cropper-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #38bdf8;
    cursor: pointer;
    box-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
}

.cropper-tool-buttons {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.cropper-tool-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e2e8f0;
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.cropper-tool-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.cropper-actions-bar {
    width: 100%;
    max-width: 440px;
    display: grid;
    grid-template-columns: 1fr 1.5fr;
    gap: 12px;
    margin-top: 10px;
}

.cropper-btn-cancel {
    padding: 13px;
    border-radius: 14px;
    border: 1px solid #475569;
    background: rgba(30, 41, 59, 0.8);
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.cropper-btn-cancel:hover {
    background: #334155;
    color: #fff;
}

.cropper-btn-save {
    padding: 13px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #0ea5e9, #0284c7);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.cropper-btn-save:hover {
    background: linear-gradient(135deg, #0284c7, #0369a1);
    box-shadow: 0 6px 16px rgba(14, 165, 233, 0.6);
}

.cropper-btn-save:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Avatar Badge Styling */
.avatar-badge-btn {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #0ea5e9;
    border: 2px solid #ffffff;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    transition: transform 0.2s;
}

.avatar-badge-btn:hover {
    transform: scale(1.1);
}
