/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #5D9C59;
    --primary-light: #8FD694;
    --secondary: #F9E795;
    --accent: #FF6B6B;
    --dark: #2C3E50;
    --light: #F8F9FA;
    --shadow: rgba(0, 0, 0, 0.15);
    --glass: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.3);
}

body {
    font-family: 'Quicksand', sans-serif;
    overflow: hidden;
    background: linear-gradient(135deg, #87CEEB 0%, #98D8C8 100%);
    color: var(--dark);
}

/* ===== Canvas Container ===== */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* ===== Loading Screen ===== */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #C1E1C1 0%, #98D8C8 50%, #87CEEB 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
}

.camera-loader {
    width: 80px;
    height: 80px;
    background: var(--glass);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    animation: pulse 1.5s ease-in-out infinite;
    box-shadow: 0 8px 32px var(--shadow);
}

.camera-loader i {
    font-size: 32px;
    color: var(--primary);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.loader-content p {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark);
}

/* ===== Camera Icon ===== */
#camera-icon {
    position: fixed;
    z-index: 100;
    cursor: grab;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: auto;
    transition: transform 0.1s ease;
}

#camera-icon:active {
    cursor: grabbing;
}

#camera-icon i {
    font-size: 48px;
    color: var(--dark);
    filter: drop-shadow(0 4px 8px var(--shadow));
    transition: transform 0.2s ease, color 0.2s ease;
}

#camera-icon:hover i {
    transform: scale(1.1);
    color: var(--primary);
}

#camera-icon .drag-hint {
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    background: var(--glass);
    padding: 4px 12px;
    border-radius: 20px;
    margin-top: 8px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

#camera-icon.dragging .drag-hint {
    opacity: 0;
}

/* ===== Target Indicator ===== */
#target-indicator {
    position: fixed;
    bottom: 140px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    border-radius: 25px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 2px solid var(--primary-light);
    transition: all 0.3s ease;
}

#target-indicator i {
    font-size: 18px;
    color: var(--primary);
    animation: targetPulse 1.5s ease-in-out infinite;
}

#target-indicator #target-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--dark);
}

#target-indicator.has-target {
    border-color: var(--primary);
    background: rgba(93, 156, 89, 0.15);
}

#target-indicator.has-target i {
    color: var(--accent);
}

@keyframes targetPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== Top Bar ===== */
#top-bar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 30px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    padding: 12px 24px;
    border-radius: 30px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--glass-border);
}

.title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.title i {
    font-size: 20px;
}

.photo-count {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    opacity: 0.8;
}

/* ===== Angle Controller ===== */
#angle-controller {
    position: fixed;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 50;
    background: var(--glass);
    backdrop-filter: blur(10px);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 4px 20px var(--shadow);
    border: 1px solid var(--glass-border);
    width: 200px;
}

.controller-header {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-light);
}

.controller-header i {
    color: var(--primary);
}

.slider-group {
    margin-bottom: 16px;
}

.slider-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 8px;
}

.slider-group label i {
    color: var(--primary);
    width: 16px;
}

.slider-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    appearance: none;
    outline: none;
    cursor: pointer;
}

.slider-group input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px var(--shadow);
    transition: transform 0.2s ease;
}

.slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-group span {
    display: block;
    text-align: right;
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    margin-top: 4px;
}

#reset-angle {
    width: 100%;
    margin-top: 10px;
}

/* ===== Buttons ===== */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-family: 'Quicksand', sans-serif;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

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

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-secondary {
    background: transparent;
    color: var(--dark);
    border: 2px solid var(--primary-light);
}

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

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

.btn-danger:hover {
    background: #ff5252;
    transform: translateY(-2px);
}

/* ===== Capture Area ===== */
#capture-area {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#capture-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: white;
    border: 4px solid var(--primary);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--shadow);
}

#capture-btn:hover {
    transform: scale(1.05);
    border-color: var(--primary-light);
}

#capture-btn:active {
    transform: scale(0.95);
}

#capture-btn .capture-ring {
    position: absolute;
    width: 90%;
    height: 90%;
    border: 3px solid var(--primary);
    border-radius: 50%;
    opacity: 0.5;
}

#capture-btn i {
    font-size: 28px;
    color: var(--primary);
    z-index: 1;
}

.capture-hint {
    font-size: 12px;
    font-weight: 600;
    color: var(--dark);
    background: var(--glass);
    padding: 6px 16px;
    border-radius: 20px;
    opacity: 0.8;
}

/* ===== Gallery Button ===== */
#gallery-btn {
    position: fixed;
    bottom: 40px;
    right: 30px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 30px;
    font-family: 'Quicksand', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px var(--shadow);
}

#gallery-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
}

#gallery-btn i {
    font-size: 18px;
}

/* ===== Flash Effect ===== */
#flash-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    opacity: 0;
    pointer-events: none;
    z-index: 200;
    transition: opacity 0.1s ease;
}

#flash-effect.active {
    opacity: 0.8;
}

/* ===== Capture Feedback ===== */
#capture-feedback {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    z-index: 150;
    background: var(--glass);
    backdrop-filter: blur(10px);
    padding: 20px 40px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
    box-shadow: 0 8px 32px var(--shadow);
}

#capture-feedback.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

#capture-feedback i {
    font-size: 24px;
    color: var(--primary);
}

#capture-feedback span {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
}

/* ===== Modal Base ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.close-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--light);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: var(--accent);
    color: white;
}

.close-btn i {
    font-size: 18px;
}

/* ===== Gallery Modal ===== */
.modal-content {
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    background: var(--light);
    border-radius: 24px;
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: var(--primary);
    color: white;
}

.modal-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
}

.modal-header .close-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.modal-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

#gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    padding: 24px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
}

.gallery-item {
    aspect-ratio: 4/3;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
}

.gallery-item:hover {
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#empty-gallery {
    text-align: center;
    padding: 60px 20px;
    color: var(--dark);
}

#empty-gallery i {
    font-size: 64px;
    color: var(--primary-light);
    margin-bottom: 20px;
}

#empty-gallery p {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}

#empty-gallery span {
    font-size: 14px;
    opacity: 0.7;
}

#empty-gallery.hidden {
    display: none;
}

/* ===== Preview Modal ===== */
.preview-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.preview-content .close-btn {
    position: absolute;
    top: -50px;
    right: 0;
    background: white;
}

#preview-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}

.preview-actions {
    display: flex;
    gap: 16px;
    margin-top: 24px;
}

.preview-message {
    margin-top: 16px;
    font-size: 16px;
    font-weight: 600;
    color: white;
    text-align: center;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    #angle-controller {
        left: 10px;
        width: 180px;
        padding: 16px;
    }
    
    #top-bar {
        padding: 10px 16px;
        gap: 16px;
    }
    
    .title span {
        display: none;
    }
    
    #gallery-btn span {
        display: none;
    }
    
    #gallery-btn {
        padding: 14px;
        border-radius: 50%;
    }
    
    #capture-btn {
        width: 70px;
        height: 70px;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}
