/* ============================================
   CONTROL DE PRODUCCIÓN PRO
   Diseño 3D + Glassmorphism + Animaciones
   ============================================ */

:root {
    --primary: #8B0000;
    --primary-light: #B22222;
    --secondary: #1A1A2E;
    --accent: #FFD700;
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --shadow-3d: 0 10px 40px rgba(0, 0, 0, 0.4);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #0a0a0f;
    min-height: 100vh;
    color: var(--text-primary);
    overflow-x: hidden;
}

/* ============================================
   FONDO ANIMADO
   ============================================ */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
}

.bg-gradient {
    position: absolute;
    width: 150%;
    height: 150%;
    top: -25%;
    left: -25%;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(139, 0, 0, 0.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(26, 26, 46, 0.5) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(15, 52, 96, 0.3) 0%, transparent 60%);
    animation: gradientMove 15s ease-in-out infinite;
}

.bg-grid {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 50px 50px;
    animation: gridMove 20s linear infinite;
}

@keyframes gradientMove {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    50% { transform: translate(-5%, -5%) rotate(3deg); }
}

@keyframes gridMove {
    0% { transform: translateY(0); }
    100% { transform: translateY(50px); }
}

/* ============================================
   CONTAINER
   ============================================ */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: 15px;
    min-height: 100vh;
}

/* ============================================
   HEADER PRO
   ============================================ */
.header-pro {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 20px 0;
}

.logo-3d {
    perspective: 500px;
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    box-shadow: 
        0 8px 25px rgba(139, 0, 0, 0.4),
        inset 0 1px 0 rgba(255,255,255,0.2);
    transform: rotateX(10deg) rotateY(-10deg);
    transition: transform 0.3s ease;
}

.logo-icon:hover {
    transform: rotateX(0) rotateY(0) scale(1.1);
}

.header-text {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-text h1 {
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.badge-pro {
    background: linear-gradient(135deg, var(--accent) 0%, #FFA500 100%);
    color: #000;
    font-size: 0.65rem;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 5px;
    letter-spacing: 1px;
}

/* ============================================
   SELECTOR DE LOCAL - CARDS 3D
   ============================================ */
.local-selector {
    margin-bottom: 20px;
}

.section-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.local-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
}

.local-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    font-family: inherit;
    color: var(--text-primary);
    font-size: 0.65rem;
    font-weight: 600;
    position: relative;
    overflow: hidden;
}

.local-card i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.local-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, transparent 0%, rgba(255,255,255,0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.local-card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}

.local-card:hover::before {
    opacity: 1;
}

.local-card:hover i {
    transform: scale(1.2);
}

.local-card.active {
    background: var(--primary);
    border-color: var(--primary-light);
    box-shadow: 
        0 0 20px rgba(139, 0, 0, 0.5),
        0 10px 30px rgba(139, 0, 0, 0.3);
    transform: translateY(-3px);
}

.local-card.active i {
    color: var(--accent);
}

/* ============================================
   GLASS CARD (Formulario)
   ============================================ */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 20px;
    box-shadow: var(--shadow-3d);
}

.form-pro {
    margin-bottom: 15px;
}

/* ============================================
   INPUTS Y SELECTS
   ============================================ */
.form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.input-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
}

.input-group label i {
    font-size: 0.75rem;
    color: var(--primary-light);
}

.select-editable {
    display: flex;
    gap: 5px;
}

.select-editable select {
    flex: 1;
}

.input-group select,
.input-group input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
    color: white;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.3s ease;
    width: 100%;
}

.input-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23fff' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.input-group select:focus,
.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.5);
}

.input-group input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.input-group.compact input {
    padding: 10px;
    text-align: center;
}

/* Botón agregar opción */
.btn-add-option {
    width: 36px;
    height: 36px;
    min-width: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: 10px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn-add-option:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(139, 0, 0, 0.4);
}

/* ============================================
   INDICADORES
   ============================================ */
.indicators-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 15px;
}

.indicator-box {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.indicator-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.indicator-box.merma .indicator-icon {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
}

.indicator-box.rendimiento .indicator-icon {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.indicator-content {
    display: flex;
    flex-direction: column;
}

.indicator-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 1px;
}

.indicator-value {
    font-size: 1.3rem;
    font-weight: 800;
    color: white;
}

/* ============================================
   BOTÓN GUARDAR 3D
   ============================================ */
.btn-submit-3d {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    border-radius: 15px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 
        0 8px 25px rgba(139, 0, 0, 0.4),
        0 3px 0 #5a0000,
        inset 0 1px 0 rgba(255,255,255,0.2);
    transform: translateY(0);
}

.btn-submit-3d:hover {
    transform: translateY(-3px);
    box-shadow: 
        0 12px 35px rgba(139, 0, 0, 0.5),
        0 6px 0 #5a0000,
        inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-submit-3d:active {
    transform: translateY(2px);
    box-shadow: 
        0 4px 15px rgba(139, 0, 0, 0.4),
        0 1px 0 #5a0000,
        inset 0 1px 0 rgba(255,255,255,0.2);
}

.btn-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: white;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    position: relative;
    z-index: 1;
}

.btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.5s ease;
}

.btn-submit-3d:hover .btn-shine {
    left: 100%;
}

/* ============================================
   QUICK ACTIONS
   ============================================ */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.btn-action {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-family: inherit;
}

.btn-action i {
    font-size: 1.2rem;
    color: var(--primary-light);
}

.btn-action span {
    font-size: 0.7rem;
    font-weight: 600;
}

.btn-action:hover {
    transform: translateY(-3px);
    background: rgba(139, 0, 0, 0.2);
    border-color: var(--primary);
}

/* ============================================
   FOOTER
   ============================================ */
.footer-mini {
    text-align: center;
    padding: 15px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* ============================================
   MODALES
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

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

.modal-content {
    width: 100%;
    max-width: 400px;
    animation: modalIn 0.3s ease;
}

.modal-large {
    max-width: 450px;
    max-height: 80vh;
    overflow-y: auto;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.modal-header h3 {
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(220, 53, 69, 0.5);
}

.modal-body input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 12px 15px;
    color: white;
    font-size: 1rem;
    font-family: inherit;
}

.modal-body input:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-modal {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.btn-cancel:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-confirm {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-confirm:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(139, 0, 0, 0.4);
}

/* Config sections */
.config-section {
    margin-bottom: 20px;
}

.config-section h4 {
    font-size: 0.85rem;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
}

.config-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.config-item {
    background: rgba(0, 0, 0, 0.3);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-item .btn-remove {
    background: none;
    border: none;
    color: #dc3545;
    cursor: pointer;
    padding: 0;
    font-size: 0.7rem;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.config-item .btn-remove:hover {
    opacity: 1;
}

.config-note {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================
   LOADING 3D
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

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

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

.loading-spinner-3d {
    width: 80px;
    height: 80px;
    position: relative;
    margin: 0 auto 20px;
}

.spinner-ring {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid transparent;
}

.spinner-ring:nth-child(1) {
    border-top-color: var(--primary);
    animation: spin3d 1s ease-in-out infinite;
}

.spinner-ring:nth-child(2) {
    border-right-color: var(--accent);
    animation: spin3d 1s ease-in-out infinite 0.2s;
}

.spinner-ring:nth-child(3) {
    border-bottom-color: #20B2AA;
    animation: spin3d 1s ease-in-out infinite 0.4s;
}

@keyframes spin3d {
    0% { transform: rotateX(30deg) rotateY(0); }
    100% { transform: rotateX(30deg) rotateY(360deg); }
}

.loading-content p {
    font-size: 1rem;
    color: var(--text-secondary);
}

/* ============================================
   TOASTS
   ============================================ */
#toastContainer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: toastIn 0.3s ease;
    box-shadow: var(--shadow-3d);
    min-width: 280px;
}

.toast.success {
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left: 4px solid #dc3545;
}

.toast i {
    font-size: 1.2rem;
}

.toast.success i {
    color: #28a745;
}

.toast.error i {
    color: #dc3545;
}

.toast span {
    font-size: 0.9rem;
    font-weight: 500;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .app-container {
        padding: 10px;
    }
    
    .header-text h1 {
        font-size: 1.1rem;
    }
    
    .local-cards {
        grid-template-columns: repeat(5, 1fr);
        gap: 5px;
    }
    
    .local-card {
        padding: 10px 3px;
        font-size: 0.55rem;
    }
    
    .local-card i {
        font-size: 1rem;
    }
    
    .form-row-2 {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .form-row-3 {
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
    }
    
    .btn-content {
        font-size: 0.9rem;
    }
}

/* ============================================
   HISTORIAL PAGE
   ============================================ */
.historial-header {
    text-align: center;
    padding: 20px 0;
}

.historial-header h1 {
    font-size: 1.3rem;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    color: white;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.btn-back:hover {
    background: rgba(139, 0, 0, 0.3);
    border-color: var(--primary);
}

.historial-filters {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.historial-filters select {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 15px;
    color: white;
    font-family: inherit;
    cursor: pointer;
}

.historial-table-container {
    overflow-x: auto;
}

.historial-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.historial-table th {
    background: rgba(139, 0, 0, 0.3);
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 2px solid var(--primary);
}

.historial-table td {
    padding: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.historial-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.historial-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Stats en modal */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

.stat-box .stat-value {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-light);
}

.stat-box .stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-top: 5px;
}
