/* AR Measure Page Styles */
.ar-measure-page {
    overflow: hidden;
    touch-action: none;
}

.ar-measure-main {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
}

.ar-container {
    position: relative;
    flex: 1;
    background: #000;
    overflow: hidden;
}

.ar-container canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
}

.crosshair {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 0 4px rgba(0,0,0,0.5);
    margin-bottom: auto;
    margin-top: 20vh;
}

.instruction {
    position: absolute;
    top: 20px;
    left: 16px;
    right: 16px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    text-align: center;
    line-height: 1.4;
    backdrop-filter: blur(4px);
}

.accuracy-warning {
    position: absolute;
    bottom: 16px;
    left: 16px;
    right: 16px;
    background: rgba(254, 243, 199, 0.95);
    color: #92400e;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    font-weight: 500;
}

/* Loading screen */
.ar-loading,
.ar-permission,
.ar-unsupported {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #1a1a1a;
    color: white;
    text-align: center;
    padding: 32px;
    z-index: 20;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: var(--primary, #C75B39);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

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

.permission-icon {
    font-size: 3rem;
    margin-bottom: 16px;
}

.ar-permission h2,
.ar-unsupported h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
}

.ar-permission p,
.ar-unsupported p {
    color: #ccc;
    max-width: 400px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.ar-unsupported ul {
    text-align: left;
    max-width: 400px;
    margin-bottom: 24px;
    color: #ccc;
    line-height: 1.6;
}

.ar-unsupported a {
    color: var(--primary-light, #E08E6D);
}

.permission-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.permission-help {
    font-size: 0.85rem;
    color: #999;
}

/* Bottom controls */
.ar-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.95), rgba(0,0,0,0.7));
    padding: 20px 16px 24px;
    display: none;
    flex-direction: column;
    gap: 16px;
    z-index: 15;
}

.measurement-display {
    background: rgba(255,255,255,0.95);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.measurement-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
}

.measurement-label {
    color: #666;
    font-weight: 500;
}

.measurement-status {
    color: #999;
    font-weight: 600;
}

.measurement-status.set {
    color: #16a34a;
}

.distance-row {
    border-top: 1px solid #eee;
    padding-top: 10px;
    margin-top: 4px;
}

.distance-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary, #C75B39);
}

.control-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-ar {
    padding: 16px 12px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-start {
    background: #22c55e;
    color: white;
}

.btn-end {
    background: #ef4444;
    color: white;
}

.btn-end:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
}

.btn-reset {
    background: #6b7280;
    color: white;
}

.btn-save {
    background: var(--primary, #C75B39);
    color: white;
}

.btn-save:disabled {
    background: #555;
    color: #999;
    cursor: not-allowed;
}

/* Measurement history sidebar */
.measurement-history {
    position: absolute;
    top: 80px;
    right: 16px;
    width: 280px;
    max-height: 60vh;
    background: rgba(255,255,255,0.98);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 12;
    overflow-y: auto;
    display: none;
}

.measurement-history h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    color: var(--text, #1a1a1a);
}

.measurement-history ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.measurement-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
}

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

.measurement-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.measurement-type-label {
    font-size: 0.85rem;
    color: #666;
}

.measurement-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text, #1a1a1a);
}

.no-measurements {
    color: #999;
    font-size: 0.9rem;
    padding: 12px 0;
    text-align: center;
}

.delete-measurement {
    background: none;
    border: none;
    color: #ef4444;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 4px;
}

.area-summary {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 2px solid var(--primary, #C75B39);
}

.area-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.area-row.total {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary, #C75B39);
    margin: 12px 0;
}

.area-summary .btn-primary {
    width: 100%;
    margin-top: 12px;
    text-align: center;
}

/* Save Modal */
.save-modal-content {
    max-width: 420px;
}

.distance-preview {
    font-size: 1.2rem;
    color: var(--primary, #C75B39);
    font-weight: 700;
    margin-bottom: 20px;
    text-align: center;
}

.measurement-types {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 2px solid var(--border, #e5e5e5);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-option:hover {
    border-color: var(--primary, #C75B39);
}

.radio-option input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary, #C75B39);
}

.form-actions {
    display: flex;
    gap: 12px;
}

.form-actions button {
    flex: 1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .ar-measure-main {
        top: 56px;
    }

    .instruction {
        font-size: 0.85rem;
        top: 12px;
        left: 12px;
        right: 12px;
    }

    .crosshair {
        margin-top: 18vh;
    }

    .accuracy-warning {
        font-size: 0.75rem;
        bottom: 12px;
        left: 12px;
        right: 12px;
    }

    .ar-controls {
        padding: 16px 12px 20px;
    }

    .btn-ar {
        padding: 14px 10px;
        font-size: 0.9rem;
    }

    .measurement-history {
        width: calc(100% - 32px);
        right: 16px;
        left: 16px;
        top: 70px;
        max-height: 50vh;
    }

    .permission-actions {
        flex-direction: column;
        width: 100%;
        max-width: 280px;
    }
}

/* Show measurement history on desktop */
@media (min-width: 769px) {
    .measurement-history {
        display: block;
    }
}

/* Show measurement history on mobile when toggled */
.measurement-history.active {
    display: block;
}
