/* ============================================================
   URBANIZACIÓN SEGURA - CSS Global Responsive
   Compatible con móviles, tablets y escritorio
   ============================================================ */

/* ===== VARIABLES ===== */
:root {
    --primary:       #0A2472;
    --primary-dark:  #071a5a;
    --primary-light: #1e40af;
    --secondary:     #2e4057;
    --accent:        #2563eb;
    --danger:        #dc2626;
    --danger-dark:   #b91c1c;
    --success:       #16a34a;
    --warning:       #ca8a04;
    --info:          #0891b2;

    --text-dark:     #111827;
    --text-body:     #374151;
    --text-muted:    #6b7280;
    --text-light:    #9ca3af;

    --bg:            #f0f2f5;
    --bg-card:       #ffffff;
    --bg-light:      #f8fafc;
    --border:        #e5e7eb;
    --border-focus:  #0A2472;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
    --shadow-md:  0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg:  0 10px 25px rgba(0,0,0,0.12);
    --shadow-xl:  0 24px 48px rgba(0,0,0,0.16);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 28px;

    --transition: all 0.2s ease;
}

/* ===== RESET BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--text-body);
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    overflow-x: hidden;
}

/* ===== TYPOGRAPHY ===== */
h1 { font-size: clamp(1.5rem, 4vw, 2rem); font-weight: 800; color: var(--text-dark); line-height: 1.2; }
h2 { font-size: clamp(1.1rem, 3vw, 1.4rem); font-weight: 700; color: var(--text-dark); }
h3 { font-size: clamp(1rem, 2.5vw, 1.2rem); font-weight: 600; color: var(--text-dark); }
p  { color: var(--text-muted); line-height: 1.6; }
a  { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-light); }

/* ===== LAYOUT ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}
@media (min-width: 640px)  { .container { padding: 0 1.5rem; } }
@media (min-width: 1024px) { .container { padding: 0 2rem; } }

.page-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 16px 120px;
}
@media (min-width: 640px) { .page-wrapper { padding: 32px 24px 80px; } }

/* ===== SECURITY BAR ===== */
.security-bar {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200;
    background: linear-gradient(90deg, var(--danger), var(--accent), var(--danger));
    background-size: 200% 100%;
    animation: moveBar 3s linear infinite;
}
@keyframes moveBar { 0% { background-position: 0%; } 100% { background-position: 200%; } }

/* ===== NAVBAR ===== */
.navbar {
    background: var(--secondary);
    color: white;
    padding: 0 1rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 3px;
    z-index: 100;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.navbar-brand {
    display: flex; align-items: center; gap: 8px;
    font-size: 1.05rem; font-weight: 700;
    white-space: nowrap; overflow: hidden;
}

.navbar-actions {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

/* ===== CARDS ===== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    padding: 24px;
    transition: var(--transition);
}

.card:hover { box-shadow: var(--shadow-lg); }
.card-sm { padding: 16px; }
.card-lg { padding: 32px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(10,36,114,0.3);
}
.btn-primary:hover { background: var(--primary-dark); color: white; transform: translateY(-1px); }

.btn-secondary {
    background: var(--secondary);
    color: white;
    box-shadow: 0 4px 12px rgba(46,64,87,0.3);
}
.btn-secondary:hover { background: #1f2c3a; color: white; transform: translateY(-1px); }

.btn-danger {
    background: var(--danger);
    color: white;
    box-shadow: 0 4px 12px rgba(220,38,38,0.3);
}
.btn-danger:hover { background: var(--danger-dark); color: white; transform: translateY(-1px); }

.btn-success {
    background: var(--success);
    color: white;
    box-shadow: 0 4px 12px rgba(22,163,74,0.3);
}
.btn-success:hover { background: #15803d; color: white; transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-light); color: var(--text-dark); }

.btn-sm { padding: 7px 14px; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-lg { padding: 14px 24px; font-size: 1rem; border-radius: var(--radius-lg); }
.btn-full { width: 100%; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block; font-size: 0.85rem; font-weight: 600;
    color: var(--text-dark); margin-bottom: 6px;
}
.form-group label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--text-dark);
    background: var(--bg-light);
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    -webkit-appearance: none; appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(10,36,114,0.1);
    background: white;
}

.form-control::placeholder { color: var(--text-light); }

textarea.form-control { resize: vertical; min-height: 100px; }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
    cursor: pointer;
}

.form-hint { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }
.form-error { font-size: 0.78rem; color: var(--danger); margin-top: 4px; }

/* Input with icon */
.input-group { position: relative; }
.input-group .form-control { padding-left: 44px; }
.input-group-icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    color: var(--text-light); width: 18px; height: 18px; pointer-events: none;
}

/* ===== ALERTS / MESSAGES ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.875rem;
    line-height: 1.5;
    margin-bottom: 16px;
}
.alert-icon { flex-shrink: 0; font-size: 1.1rem; }
.alert-success { background: #f0fdf4; border-left: 4px solid var(--success); color: #15803d; }
.alert-error   { background: #fef2f2; border-left: 4px solid var(--danger);  color: var(--danger-dark); }
.alert-warning { background: #fffbeb; border-left: 4px solid #f59e0b; color: #92400e; }
.alert-info    { background: #eff6ff; border-left: 4px solid var(--accent);   color: #1d4ed8; }

/* ===== BADGES ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 600;
    white-space: nowrap;
}
.badge-primary { background: #dbeafe; color: var(--primary); }
.badge-success { background: #dcfce7; color: var(--success); }
.badge-danger  { background: #fee2e2; color: var(--danger); }
.badge-warning { background: #fef9c3; color: var(--warning); }
.badge-gray    { background: #f1f5f9; color: #475569; }
.badge-info    { background: #cffafe; color: #0e7490; }

/* ===== TABLES ===== */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    min-width: 480px;
}

.table thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-body);
    vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--bg-light); }

/* ===== GRID UTILITIES ===== */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 768px) {
    .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

/* ===== STAT CARDS ===== */
.stat-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 26px; height: 26px; }

.stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-icon.green  { background: #dcfce7; color: var(--success); }
.stat-icon.yellow { background: #fef9c3; color: var(--warning); }
.stat-icon.red    { background: #fee2e2; color: var(--danger); }
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }
.stat-icon.cyan   { background: #cffafe; color: #0891b2; }

.stat-value { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}
.empty-state svg {
    width: 56px; height: 56px;
    margin: 0 auto 12px;
    opacity: 0.4;
    display: block;
}
.empty-state p { margin-bottom: 8px; font-size: 0.9rem; }

/* ===== LOADING ===== */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== SCANNER (Vigilante) ===== */
.scanner-container {
    background: white;
    border-radius: var(--radius-2xl);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 20px;
}

.camera-placeholder {
    width: 100%;
    aspect-ratio: 1;
    max-height: 320px;
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
    border-radius: var(--radius-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-light);
}

.camera-placeholder svg { width: 60px; height: 60px; opacity: 0.4; }
.camera-placeholder p { font-size: 0.9rem; }

.result-card {
    margin-top: 16px;
    border-radius: var(--radius-xl);
    padding: 20px;
    border: 2px solid;
    transition: var(--transition);
}
.result-card.valid   { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.result-card.invalid { background: #fef2f2; border-color: #fecaca; color: var(--danger-dark); }
.result-card.info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

.camera-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 12px;
    font-size: 0.875rem;
    color: var(--danger-dark);
}

/* ===== MOBILE SPECIFIC ===== */
@media (max-width: 640px) {
    .navbar-brand span.name { display: none; }
    .stat-card { padding: 14px; }
    .stat-icon { width: 44px; height: 44px; }
    .stat-value { font-size: 1.5rem; }
    .table thead th, .table tbody td { padding: 10px 12px; }
    .hide-mobile { display: none !important; }
    .card { padding: 18px; }
    .btn { padding: 9px 14px; }
}

@media (min-width: 641px) {
    .show-mobile-only { display: none !important; }
}

/* ===== PRINT ===== */
@media print {
    .navbar, .panic-fab, .btn-logout, .security-bar { display: none !important; }
    body { background: white !important; }
    .card { box-shadow: none !important; border: 1px solid #e5e7eb; }
}

/* ===== UTILS ===== */
.hidden   { display: none !important; }
.sr-only  { position: absolute; width: 1px; height: 1px; clip: rect(0,0,0,0); overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.w-full { width: 100%; }
