/* --- RESET & VARIABLES --- */
:root {
    --neon-cyan: #06b6d4;
    --neon-blue: #3b82f6;
    --neon-red: #ef4444;
    --neon-green: #22c55e;
    --neon-yellow: #eab308;
    --bg-dark: #050505;
    --bg-panel: #0a0a0a;
    --border-color: #1f2937;
    --text-main: #d1d5db;
    --text-dim: #6b7280;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
    overflow-x: hidden;
    line-height: 1.5;
}

/* --- UTILITIES --- */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.text-center { text-align: center; }
.uppercase { text-transform: uppercase; }
.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.absolute { position: absolute; }
.font-bold { font-weight: bold; }
.cursor-pointer { cursor: pointer; }

/* --- LAYOUT --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
}

/* --- COMPONENTS --- */

/* Scanlines */
.scanlines {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(255,255,255,0), rgba(255,255,255,0) 50%, rgba(0,0,0,0.1) 50%, rgba(0,0,0,0.1));
    background-size: 100% 4px;
    pointer-events: none;
    z-index: 100;
    opacity: 0.6;
}

/* Boot Screen */
#boot-screen {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.boot-icon {
    width: 64px;
    height: 64px;
    fill: var(--neon-cyan);
    margin-bottom: 1.5rem;
    animation: pulse 2s infinite;
}

.progress-container {
    width: 300px;
    height: 4px;
    background: #222;
    margin-top: 2rem;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--neon-cyan);
    width: 0%;
    transition: width 0.3s ease;
}

/* Header */
header {
    background: rgba(10, 10, 10, 0.95);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px -5px rgba(6, 182, 212, 0.1);
}

.header-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    gap: 1rem;
}

.logo {
    font-size: 1.5rem;
    font-style: italic;
    font-weight: 900;
    letter-spacing: -1px;
}

.logo span { color: var(--neon-cyan); }

.search-bar {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

@media (max-width: 600px) {
    .search-bar {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr auto auto;
        grid-template-areas: 
            "input input input"
            "select nfc barcode";
        gap: 0.5rem;
    }

    #search-input { grid-area: input; width: 100%; }
    #filter-select { grid-area: select; width: 100%; }
    #btn-nfc { grid-area: nfc; }
    #btn-barcode { grid-area: barcode; }
}

input[type="text"], select {
    background: rgba(30, 30, 30, 0.5);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    font-family: inherit;
    outline: none;
    text-transform: uppercase;
    font-size: 0.85rem;
}

input[type="text"]:focus, select:focus {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 8px rgba(6, 182, 212, 0.3);
}

.btn-scan {
    background: rgba(30, 30, 30, 0.5);
    border: 1px solid var(--border-color);
    color: var(--neon-cyan);
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-scan:hover {
    border-color: var(--neon-cyan);
    background: rgba(6, 182, 212, 0.1);
}

.btn-scan svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/* Stats Bar */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-box {
    background: rgba(15, 15, 15, 0.8);
    border: 1px solid var(--border-color);
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.stat-label { font-size: 0.7rem; color: var(--text-dim); letter-spacing: 2px; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.25rem; font-weight: bold; color: var(--neon-cyan); }

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%);
}

.card:hover {
    border-color: var(--neon-cyan);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -10px rgba(6, 182, 212, 0.2);
}

.card-corner {
    position: absolute;
    top: 0; right: 0;
    width: 30px;
    height: 30px;
    background: var(--border-color);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 0);
    transition: background 0.2s;
}

.card:hover .card-corner { background: var(--neon-cyan); }

.card-body { padding: 1.25rem; display: flex; gap: 1rem; }

.avatar-frame {
    width: 80px;
    height: 80px;
    border: 1px solid var(--border-color);
    background: #000;
    position: relative;
    flex-shrink: 0;
}

.avatar-img {
    width: 100%; height: 100%; object-fit: cover;
    filter: grayscale(100%) brightness(0.8);
    transition: all 0.3s;
}

.card:hover .avatar-img { filter: grayscale(0%) brightness(1); }

.info-col { flex: 1; min-width: 0; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 0.25rem;
}

.ripper-id { font-size: 0.75rem; color: var(--neon-cyan); letter-spacing: 1px; }

.status-badge {
    font-size: 0.65rem;
    padding: 2px 6px;
    border: 1px solid currentColor;
    letter-spacing: 1px;
}
.status-open { color: var(--neon-green); }
.status-busy { color: var(--neon-yellow); }
.status-closed { color: var(--neon-red); }

.ripper-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ripper-alias { font-size: 0.85rem; color: var(--text-dim); font-style: italic; margin-bottom: 0.75rem; }

.detail-row {
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 0.25rem;
}

.detail-row svg { width: 14px; height: 14px; margin-right: 6px; fill: currentColor; }

/* Card Decoration Footer */
.card-footer { height: 4px; display: flex; width: 100%; margin-top: auto; }
.deco-1 { width: 33%; background: #164e63; transition: background 0.2s; }
.card:hover .deco-1 { background: var(--neon-cyan); }
.deco-2 { width: 33%; background: #374151; }
.deco-3 { width: 34%; background: #1f2937; }

/* MODAL */
#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(4px);
    z-index: 150;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-panel);
    border: 2px solid var(--border-color);
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 50px rgba(0,0,0,0.8);
    animation: modalFadeIn 0.3s ease-out;
}

@media (min-width: 768px) {
    .modal-content { flex-direction: row; }
    .modal-left { width: 35%; border-right: 1px solid var(--border-color); border-bottom: none; }
    .modal-right { width: 65%; }
}

.modal-close {
    position: absolute;
    top: 1rem; right: 1rem;
    background: #000;
    border: 1px solid var(--neon-red);
    color: var(--neon-red);
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 10;
}
.modal-close:hover { background: var(--neon-red); color: #000; }

.modal-left {
    background: #000;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.modal-left img {
    width: 180px; height: 180px;
    border: 2px dashed var(--border-color);
    padding: 4px;
    margin-bottom: 1.5rem;
    filter: contrast(1.2) grayscale(0.5);
}

.modal-right {
    padding: 2rem;
    background: rgba(15, 15, 15, 0.95);
    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: 20px 20px;
}

.section-title {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #fff;
}
.section-marker { width: 8px; height: 24px; background: var(--neon-cyan); margin-right: 12px; }

/* Stats Grid in Modal */
.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 600px) { .modal-grid { grid-template-columns: 1fr; } }

.info-block {
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border-color);
    padding: 1rem;
}
.info-label { font-size: 0.7rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 0.5rem; }
.info-content { font-size: 0.9rem; color: #eee; }

.stat-big { font-size: 1.5rem; font-weight: bold; color: #fff; }
.text-green { color: var(--neon-green); }
.text-red { color: var(--neon-red); }

.list-clean { list-style: none; }
.list-clean li { 
    margin-bottom: 0.25rem; 
    font-size: 0.85rem;
    display: flex;
}
.bullet { color: var(--neon-cyan); margin-right: 0.5rem; }

/* Connect Button */
.btn-connect {
    width: 100%;
    padding: 1rem;
    background: rgba(6, 182, 212, 0.1);
    border: 1px solid var(--neon-cyan);
    color: var(--neon-cyan);
    font-family: inherit;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 2px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.btn-connect:hover { background: var(--neon-cyan); color: #000; }
.btn-connect:disabled { opacity: 0.7; cursor: not-allowed; }

/* Error Popup */
.error-popup {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #000;
    border: 2px solid var(--neon-red);
    padding: 2rem;
    text-align: center;
    z-index: 200;
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4);
    display: none;
    width: 80%;
    max-width: 400px;
}
.error-title { color: var(--neon-red); font-size: 1.5rem; font-weight: bold; margin-bottom: 1rem; }
.error-msg { color: #fff; font-size: 0.9rem; margin-bottom: 1.5rem; }
.btn-error {
    background: var(--neon-red); color: #000; border: none;
    padding: 0.5rem 1.5rem; font-family: inherit; font-weight: bold; cursor: pointer;
}

/* Animations */
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
@keyframes modalFadeIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.spinner {
    width: 16px; height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
