:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --success: #22c55e;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.main-workspace {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 1.5rem;
    align-items: stretch;
}

@media (max-width: 900px) {
    .main-workspace {
        grid-template-columns: 1fr;
    }
}

header {
    text-align: center;
    margin-bottom: 1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 0.5rem;
}

.card {
    background: var(--bg-card);
    border-radius: 1.5rem;
    padding: 1.5rem;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.camera-card {
    flex-grow: 1;
}

.video-section {
    position: relative;
    display: flex;
    justify-content: center;
    background: #000;
    border-radius: 1rem;
    overflow: hidden;
    aspect-ratio: 16/9;
}

#camera-video, #visualization-canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#visualization-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
}

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

button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

.btn-record.recording {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.cam-toggle-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    padding: 0.4rem;
    border-radius: 0.6rem;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cam-toggle-btn:hover {
    background: var(--bg-dark);
    color: white;
    border-color: var(--primary);
}

.top-stats-bar {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 2rem;
    background: rgba(15, 23, 42, 0.4);
    padding: 0.75rem 2rem;
    border-radius: 3rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    align-self: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: white;
}

.stat-divider {
    width: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.instructions-card {
    padding: 1.5rem 2rem;
}

.instructions-content {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 2rem;
    align-items: center;
}

.text-info h3 {
    margin-bottom: 1rem;
    color: var(--primary);
}

.text-info ul {
    list-style: none;
    padding-left: 0;
}

.text-info li {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    font-size: 0.9rem;
}

.point {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 800;
    flex-shrink: 0;
    color: white;
}

.position-image-container {
    background: rgba(0,0,0,0.2);
    border-radius: 1rem;
    overflow: hidden;
    height: 200px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.position-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 1;
}

.target-sign-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    text-align: center;
    background: linear-gradient(135deg, var(--bg-card), #1e1b4b);
    border-left: 6px solid var(--primary);
}

#current-target-name {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(to right, #6366f1, #a855f7);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: block;
    min-width: 250px;
}

.target-sign-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
    transform: scale(1.1);
}

.target-sign-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.5rem 0;
}

.target-image-container {
    width: 200px;
    height: 200px;
    background: #000;
    border-radius: 1.5rem;
    overflow: hidden;
    border: 3px solid var(--primary);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
}

.target-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.status-pill {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.1);
}

.status-live { color: var(--success); border: 1px solid var(--success); }
.status-rec { color: var(--danger); border: 1px solid var(--danger); }

/* Gallery Styles */
.gallery-card { margin-top: 2rem; }
.gallery-container { display: flex; flex-direction: column; gap: 2.5rem; }
.sign-group { border-top: 1px solid rgba(255, 255, 255, 0.05); padding-top: 1.5rem; }
.sign-group:first-child { border-top: none; padding-top: 0; }
.sign-group h3 { margin-bottom: 1.25rem; font-size: 1.1rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.05em; }
.captures-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; }
.capture-item { background: rgba(15, 23, 42, 0.6); border-radius: 1rem; padding: 0.75rem; display: flex; flex-direction: column; align-items: center; border: 1px solid rgba(255, 255, 255, 0.05); cursor: pointer; transition: all 0.2s ease; }
.capture-item:hover { transform: translateY(-5px); border-color: var(--primary); background: rgba(99, 102, 241, 0.1); box-shadow: 0 10px 20px -10px rgba(99, 102, 241, 0.4); }
.capture-thumb { width:100%; aspect-ratio: 1/1; background: #000; border-radius: 0.75rem; display: block; }
.capture-time { font-size: 0.7rem; color: var(--text-dim); margin-top: 0.75rem; opacity: 0.7; }

.preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    display: none;
}

.preview-overlay.active {
    display: flex;
}

#replay-canvas {
    height: 240px;
    width: 240px;
    background: #000;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.confirm-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
}
/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 2.5rem;
    border-radius: 2rem;
    width: 600px;
    max-width: 90vw;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 2.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0.5rem;
}

.modal-close:hover {
    color: white;
}

#modal-replay-canvas {
    width: 500px;
    height: 500px;
    max-width: 100%;
    background: #000;
    border-radius: 1.5rem;
    margin-bottom: 2rem;
    border: 2px solid var(--primary);
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3);
}

.modal-controls {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    justify-content: center;
}

.modal-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

/* Enhancements for capture items */
.capture-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.capture-item::after {
    content: '▶ Ver Animación';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

.capture-item:hover::after {
    opacity: 1;
    transform: translate(-50%, -60%);
}

/* Toast System */
.toast-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    pointer-events: none;
}

.toast {
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    min-width: 280px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    font-size: 0.9rem;
    pointer-events: auto;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

.toast.removing {
    animation: slideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100%); }
}

.toast-success { border-left: 5px solid var(--success); }
.toast-error { border-left: 5px solid var(--danger); }
.toast-warning { border-left: 5px solid #f59e0b; }
.toast-loading { border-left: 5px solid var(--primary); }

.spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
