@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');

:root {
    --matrix-green: #00ff41;
    --matrix-dark-green: #003b00;
    --matrix-black: #0d0208;
    --alert-red: #ff003c;
}

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

body {
    background-color: var(--matrix-black);
    color: var(--matrix-green);
    font-family: 'Share Tech Mono', monospace;
    overflow-x: hidden;
}

/* Matrix Background Effect */
#matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0.15;
}

.container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 15px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    border-bottom: 2px solid var(--matrix-green);
    margin-bottom: 15px;
    padding-bottom: 10px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

h1, h2, h3 {
    text-transform: uppercase;
    letter-spacing: 2px;
    text-shadow: 0 0 5px var(--matrix-green);
}

header h1 {
    font-size: 1.5rem;
}

.btn {
    background: transparent;
    color: var(--matrix-green);
    border: 1px solid var(--matrix-green);
    padding: 12px 20px;
    cursor: pointer;
    text-transform: uppercase;
    font-family: inherit;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-size: 0.9rem;
}

.btn:hover {
    background: var(--matrix-green);
    color: var(--matrix-black);
    box-shadow: 0 0 15px var(--matrix-green);
}

.card {
    border: 1px solid var(--matrix-green);
    padding: 20px;
    background: rgba(0, 59, 0, 0.1);
    margin-bottom: 20px;
    position: relative;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
}

/* Detector Styles */
.detector-wrapper {
    position: relative;
    width: 100%;
    height: calc(100vh - 180px); /* Ocupar casi todo el alto */
    max-width: none;
    margin: 0;
    border: 3px solid var(--matrix-green);
    box-shadow: 0 0 20px var(--matrix-green);
    background: #000;
    overflow: hidden;
}

#webcam {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Llenar el contenedor */
    display: block;
}

/* Mini Map Styles */
.mini-map-container {
    height: 200px;
    width: 100%;
    border: 1px solid var(--matrix-green);
    position: relative;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s ease;
}

.mini-map-container:hover {
    box-shadow: 0 0 10px var(--matrix-green);
}

#mini-map {
    height: 100%;
    width: 100%;
    filter: brightness(0.6) invert(1) contrast(3) hue-rotate(100deg) saturate(0.5);
}

.map-overlay-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    z-index: 1000;
    background: rgba(0,0,0,0.7);
    color: var(--matrix-green);
    border: 1px solid var(--matrix-green);
    padding: 2px 5px;
    font-size: 0.6rem;
    pointer-events: none;
}

/* Fullscreen Map Modal */
.map-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    padding: 20px;
}

.map-modal.active {
    display: flex;
    flex-direction: column;
}

#full-map {
    flex-grow: 1;
    border: 2px solid var(--matrix-green);
    filter: brightness(0.6) invert(1) contrast(3) hue-rotate(100deg) saturate(0.5);
}

.close-modal {
    align-self: flex-end;
    margin-bottom: 10px;
}

#canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
}

.alert-active {
    border-color: var(--alert-red) !important;
    box-shadow: 0 0 30px var(--alert-red) !important;
    animation: pulse 0.5s infinite;
}

.marker-pulse {
    background: var(--alert-red);
    border-radius: 50%;
    height: 20px;
    width: 20px;
    position: absolute;
    left: -10px;
    top: -10px;
    animation: pulse-marker 1.5s ease-out infinite;
    pointer-events: none;
}

@keyframes pulse-marker {
    0% {
        transform: scale(0.1);
        opacity: 0.8;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

.marker-pulse-green {
    background: var(--matrix-green) !important;
}

/* Form Styles */
.form-group {
    margin-bottom: 15px;
}

input, select {
    width: 100%;
    background: var(--matrix-black);
    border: 1px solid var(--matrix-green);
    color: var(--matrix-green);
    padding: 12px;
    font-family: inherit;
}

input:focus, select:focus {
    outline: none;
    box-shadow: 0 0 5px var(--matrix-green);
}

/* History Table */
table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    border: 1px solid var(--matrix-green);
    padding: 12px;
    text-align: left;
}

th {
    background: var(--matrix-dark-green);
}

.status-atendida { color: var(--matrix-green); }
.status-pendiente { color: var(--alert-red); }

.thumb {
    width: 80px;
    height: auto;
    border: 1px solid var(--matrix-green);
    cursor: pointer;
    transition: transform 0.2s ease;
}
.thumb:hover {
    transform: scale(1.1);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    border: 1px solid var(--matrix-green);
    padding: 15px;
    text-align: center;
    background: rgba(0, 59, 0, 0.15);
}

.stat-card .value {
    font-size: 2.5em;
    display: block;
    margin-top: 5px;
}

.stat-card.alert {
    border-color: var(--alert-red);
    color: var(--alert-red);
}

.stat-card.alert .value {
    text-shadow: 0 0 10px var(--alert-red);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: var(--matrix-black);
}
::-webkit-scrollbar-thumb {
    background: var(--matrix-green);
    border-radius: 10px;
}

main {
    display: grid;
    grid-template-columns: 1fr 350px; /* Video principal y panel lateral */
    gap: 15px;
    flex-grow: 1;
}

aside {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.detector-footer {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

#console-logs {
    font-size: 0.8rem;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.4;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        flex-direction: column;
        text-align: center;
        gap: 20px;
    }

    header nav {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    header nav .btn {
        flex: 1 1 calc(50% - 10px);
        padding: 12px 5px;
        font-size: 0.8rem;
    }

    h1 { font-size: 1.2rem; }
    h2 { font-size: 1.1rem; }
    h3 { font-size: 1rem; }
    
    .detector-wrapper {
        border-width: 2px;
    }

    /* Stack grid layouts */
    main {
        grid-template-columns: 1fr;
    }

    aside {
        order: 2;
    }

    section {
        order: 1;
    }

    .detector-footer {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    /* Responsive tables */
    .card {
        padding: 15px;
    }

    .card-scrollable {
        overflow-x: auto;
    }

    table {
        font-size: 0.75rem;
        min-width: 600px;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .stat-card .value {
        font-size: 2em;
    }
}
