@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #080c14;
    --card-bg: rgba(15, 23, 42, 0.65);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    
    /* Accents */
    --accent-teal: #00f2fe;
    --accent-teal-glow: rgba(0, 242, 254, 0.4);
    --accent-green: #00e676;
    --accent-green-glow: rgba(0, 230, 118, 0.4);
    --accent-amber: #ffb300;
    --accent-amber-glow: rgba(255, 179, 0, 0.4);
    --accent-red: #ff1744;
    --accent-red-glow: rgba(255, 23, 68, 0.4);
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(0, 242, 254, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 230, 118, 0.05) 0%, transparent 40%);
    background-attachment: fixed;
}

/* App Layout Grid */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    grid-template-rows: 70px 1fr 180px;
    grid-template-areas: 
        "header header"
        "sidebar main"
        "gallery gallery";
    height: 100vh;
    gap: 1px;
    background-color: rgba(255, 255, 255, 0.05);
}

/* Header */
.app-header {
    grid-area: header;
    background: rgba(10, 15, 30, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 10;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--accent-teal), #4facfe);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #000;
    box-shadow: 0 0 15px var(--accent-teal-glow);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #fff, #a5f3fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-left: 8px;
    border-left: 1px solid var(--card-border);
    padding-left: 8px;
}

/* Sidebar */
.app-sidebar {
    grid-area: sidebar;
    background: rgba(8, 12, 24, 0.6);
    backdrop-filter: blur(8px);
    border-right: 1px solid var(--card-border);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
}

.section-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 600;
}

/* Checklist Poses */
.pose-checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pose-item {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.pose-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
    transition: background 0.3s;
}

.pose-item.active {
    background: rgba(0, 242, 254, 0.08);
    border-color: rgba(0, 242, 254, 0.3);
    box-shadow: 0 4px 20px rgba(0, 242, 254, 0.05);
}

.pose-item.active::before {
    background: var(--accent-teal);
}

.pose-item.completed {
    background: rgba(0, 230, 118, 0.05);
    border-color: rgba(0, 230, 118, 0.2);
}

.pose-item.completed::before {
    background: var(--accent-green);
}

.pose-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.pose-item.active .pose-icon {
    border-color: var(--accent-teal);
    color: var(--accent-teal);
    background: rgba(0, 242, 254, 0.1);
    box-shadow: 0 0 8px var(--accent-teal-glow);
}

.pose-item.completed .pose-icon {
    border-color: var(--accent-green);
    color: #000;
    background: var(--accent-green);
}

.pose-info {
    flex: 1;
}

.pose-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pose-item.completed .pose-name {
    color: var(--text-secondary);
    text-decoration: line-through;
}

.pose-status {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.pose-item.active .pose-status {
    color: var(--accent-teal);
}

.pose-item.completed .pose-status {
    color: var(--accent-green);
}

/* Main Workspace */
.app-main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    padding: 24px;
    gap: 20px;
    overflow-y: auto;
    align-items: center;
    justify-content: center;
}

/* Camera Frame Container */
.capture-box {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--card-border);
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.capture-box.active-teal {
    border-color: rgba(0, 242, 254, 0.4);
    box-shadow: 0 0 30px rgba(0, 242, 254, 0.15);
}

.capture-box.active-green {
    border-color: rgba(0, 230, 118, 0.4);
    box-shadow: 0 0 30px rgba(0, 230, 118, 0.15);
}

.capture-box.active-amber {
    border-color: rgba(255, 179, 0, 0.4);
    box-shadow: 0 0 30px rgba(255, 179, 0, 0.15);
}

/* Video & Canvas overlays */
#webcam {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Flipped initially for selfie view */
}

#webcam.no-mirror {
    transform: scaleX(1);
}

#overlay-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    pointer-events: none;
}

/* HUD Overlay Elements */
.hud-coaching-container {
    position: absolute;
    bottom: 24px;
    left: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 5;
}

.hud-alert-card {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s;
}

.hud-alert-card.ok {
    border-color: rgba(0, 230, 118, 0.3);
    box-shadow: 0 4px 20px rgba(0, 230, 118, 0.1);
}

.hud-alert-card.warning {
    border-color: rgba(255, 179, 0, 0.3);
    box-shadow: 0 4px 20px rgba(255, 179, 0, 0.1);
}

.instruction-text {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.status-badge.red {
    background: rgba(255, 23, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(255, 23, 68, 0.3);
}

.status-badge.amber {
    background: rgba(255, 179, 0, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(255, 179, 0, 0.3);
}

.status-badge.green {
    background: rgba(0, 230, 118, 0.15);
    color: var(--accent-green);
    border: 1px solid rgba(0, 230, 118, 0.3);
}

/* Picture in Picture Crop Preview */
.pip-preview-box {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 140px;
    aspect-ratio: 4/3;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--accent-teal);
    z-index: 5;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.pip-header {
    background: var(--accent-teal);
    color: #000;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    padding: 3px 0;
    letter-spacing: 0.5px;
}

#pip-canvas {
    flex: 1;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Overlay loading state */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(8, 12, 20, 0.95);
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity 0.5s;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(0, 242, 254, 0.1);
    border-top: 3px solid var(--accent-teal);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    letter-spacing: 1px;
}

/* Bottom Controls */
.controls-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    width: 100%;
    max-width: 800px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Switch Styles */
.switch-container {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.switch-label {
    cursor: pointer;
}

.switch-element {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch-element input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .3s;
    border-radius: 24px;
    border: 1px solid var(--card-border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent-teal);
}

input:checked + .slider:before {
    transform: translateX(20px);
}

/* Buttons */
.btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 10px 18px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-teal), #02b3e4);
    color: #000;
    border: none;
    font-weight: 600;
    box-shadow: 0 4px 15px var(--accent-teal-glow);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #00f2fe, #20c2e4);
    box-shadow: 0 4px 20px rgba(0, 242, 254, 0.6);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: rgba(255,255,255,0.05);
    color: var(--text-secondary);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-green), #00c853);
    color: #000;
    border: none;
    font-weight: 600;
    box-shadow: 0 4px 15px var(--accent-green-glow);
}

.btn-success:hover {
    box-shadow: 0 4px 20px rgba(0, 230, 118, 0.6);
    transform: translateY(-1px);
}

/* Live Stats Overlay */
.live-stats {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(8px);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 8px 12px;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 5;
}

.stat-item span {
    color: var(--text-primary);
    font-weight: bold;
}

/* Bottom Gallery */
.app-gallery {
    grid-area: gallery;
    background: rgba(6, 9, 17, 0.9);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--card-border);
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow-x: auto;
}

.gallery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.gallery-title {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-secondary);
    font-weight: 600;
}

.gallery-grid {
    display: flex;
    gap: 16px;
    height: 100px;
    align-items: center;
}

.gallery-slot {
    width: 120px;
    height: 90px;
    background: rgba(30, 41, 59, 0.2);
    border: 2px dashed rgba(255,255,255,0.08);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.65rem;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
    transition: all 0.3s;
}

.gallery-slot.filled {
    border: 1px solid rgba(255,255,255,0.15);
    background: #000;
}

.gallery-slot.filled:hover .delete-crop-btn {
    opacity: 1;
}

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

.gallery-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
    text-align: center;
    padding: 3px 0;
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--text-primary);
}

.delete-crop-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: rgba(255, 23, 68, 0.8);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    font-size: 0.75rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 3;
}

.delete-crop-btn:hover {
    background: var(--accent-red);
}

/* Flash effect */
.flash-effect {
    position: absolute;
    inset: 0;
    background: #fff;
    opacity: 0;
    z-index: 9;
    pointer-events: none;
}

.flash-animation {
    animation: flashPlay 0.5s ease-out;
}

@keyframes flashPlay {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.01);
}

::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.2);
}
