:root {
    --primary-color: #2196F3;
    --secondary-color: #1976D2;
    --success-color: #4CAF50;
    --warning-color: #FFC107;
    --error-color: #F44336;
    --text-color: #333;
    --background-color: #f5f5f5;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 20px;
}

h1 {
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 2rem;
}

h2, h3 {
    color: var(--secondary-color);
    margin: 1rem 0;
}

.instructions, .tips {
    background-color: white;
    padding: 1.5rem;
    margin: 1rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.instructions ol, .tips ul {
    padding-left: 1.5rem;
    margin: 0.5rem 0;
}

.instructions li, .tips li {
    margin: 0.5rem 0;
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    margin: 2rem auto;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
}

video {
    width: 100%;
    height: auto;
    display: block;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.reference-guide {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 1px solid rgba(255,255,255,1);
    box-shadow: 
        0 0 0 1px rgba(0,0,0,1),
        0 0 5px rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.2);
    width: 8%;  /* Back to original size */
    height: 4.6%;  /* Maintains 1.75:1 aspect ratio (3.5:2) */
    z-index: 2;
    pointer-events: none;
}

.edge-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    cursor: crosshair;
}

.edge-highlight {
    position: absolute;
    background: rgba(33, 150, 243, 0.3);
    border: 2px solid rgba(33, 150, 243, 0.8);
    pointer-events: none;
    z-index: 4;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.drawing-active {
    cursor: grabbing !important;
}

.controls-expanded {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.control-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.control-slider {
    width: 100px;
    margin: 0 0.5rem;
}

.camera-height-control {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
    color: var(--text-color);
}

.camera-height-control label {
    margin-right: 10px;
    font-weight: 500;
}

.camera-height-control select {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--primary-color);
    background: white;
    font-size: 1rem;
    cursor: pointer;
}

.camera-height-control select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.2);
}

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 1.5rem 0;
}

.primary-btn {
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background-color: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.primary-btn:active {
    transform: scale(0.98);
}

.primary-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.results {
    background-color: white;
    padding: 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

#areaResult {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--success-color);
    margin: 1rem 0;
}

.status-text {
    color: #666;
    font-style: italic;
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .primary-btn {
        width: 100%;
        margin: 0.5rem 0;
    }

    .controls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .instructions, .tips, .results {
        padding: 1rem;
    }
}

/* Error message styles */
.error-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--error-color);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 15px;
    max-width: 90%;
    animation: slideDown 0.3s ease-out;
}

.error-message p {
    margin: 0;
    flex-grow: 1;
}

.error-message button {
    background: transparent;
    border: 1px solid white;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.error-message button:hover {
    background: rgba(255, 255, 255, 0.1);
}

@keyframes slideDown {
    from {
        transform: translate(-50%, -100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

.status-text.error {
    color: var(--error-color);
    font-weight: bold;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-overlay p {
    color: white;
    font-size: 1.2rem;
    text-align: center;
    margin: 0;
    padding: 0 20px;
}

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