/* ============== VARIABLES ============== */
:root {
    --primary-gold: #FFB31A;
    --primary-gold-dark: #E09D00;
    --primary-gold-light: #FFD066;
    --dark-bg: #0D1117;
    --dark-surface: #161B22;
    --dark-border: #30363D;
    --text-primary: #F0F6FC;
    --text-secondary: #8B949E;
    --text-muted: #6E7681;
    --success: #3FB950;
    --error: #F85149;
    --warning: #D29922;
    --sidebar-width: 260px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--dark-bg);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
}

a {
    color: var(--primary-gold);
    text-decoration: none;
}

a:hover {
    color: var(--primary-gold-light);
}

/* ============== SIDEBAR ============== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-surface);
    border-right: 1px solid var(--dark-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--dark-border);
}

.logo img {
    height: 36px;
    width: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 179, 26, 0.1);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(255, 179, 26, 0.15);
    color: var(--primary-gold);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--dark-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.user-avatar, .user-avatar-small {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--primary-gold-dark) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--dark-bg);
    flex-shrink: 0;
}

.user-avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 0.875rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 500;
    font-size: 0.875rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.logout-btn {
    padding: 8px;
    border-radius: 8px;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background: rgba(248, 81, 73, 0.1);
    color: var(--error);
}

.logout-btn svg {
    width: 20px;
    height: 20px;
}

/* ============== MAIN CONTENT ============== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px;
    min-height: 100vh;
}

.main-content.no-sidebar {
    margin-left: 0;
}

.page-header {
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.page-header p {
    color: var(--text-secondary);
}

/* ============== CARDS ============== */
.card {
    background: var(--dark-surface);
    border: 1px solid var(--dark-border);
    border-radius: 12px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--dark-border);
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

/* ============== DASHBOARD GRID ============== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

/* ============== STATUS CARD ============== */
.status-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-label {
    color: var(--text-secondary);
}

.status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-ok {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.status-warning {
    background: rgba(210, 153, 34, 0.15);
    color: var(--warning);
}

.status-error {
    background: rgba(248, 81, 73, 0.15);
    color: var(--error);
}

/* ============== NFC READER ============== */
.nfc-reader {
    text-align: center;
    padding: 40px 20px;
}

.nfc-reader.active .nfc-icon {
    animation: pulse 2s ease-in-out infinite;
}

.nfc-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    background: rgba(255, 179, 26, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nfc-icon svg {
    width: 40px;
    height: 40px;
    color: var(--primary-gold);
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.nfc-message {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ============== RESULT CARD ============== */
.result-card.result-allowed {
    border-color: var(--success);
}

.result-card.result-denied {
    border-color: var(--error);
}

.result-content {
    text-align: center;
    padding: 20px;
}

.result-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-icon.allowed {
    background: rgba(63, 185, 80, 0.15);
    color: var(--success);
}

.result-icon.denied {
    background: rgba(248, 81, 73, 0.15);
    color: var(--error);
}

.result-icon svg {
    width: 32px;
    height: 32px;
}

.result-title {
    font-size: 1.25rem;
    margin-bottom: 8px;
}

.result-message {
    color: var(--text-secondary);
}

.result-user {
    margin-top: 12px;
    font-size: 1.1rem;
}

.result-uid {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-family: monospace;
}

.fade-out {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ============== HISTORY ============== */
.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--dark-bg);
    border-radius: 8px;
    border-left: 3px solid var(--dark-border);
}

.history-item.allowed {
    border-left-color: var(--success);
}

.history-item.denied {
    border-left-color: var(--error);
}

.history-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.history-uid {
    flex: 1;
    font-family: monospace;
    font-size: 0.875rem;
}

.history-status {
    font-weight: 600;
}

.history-item.allowed .history-status {
    color: var(--success);
}

.history-item.denied .history-status {
    color: var(--error);
}

.empty-message {
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

/* ============== FORMS ============== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--dark-bg);
    border: 1px solid var(--dark-border);
    border-radius: 8px;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-gold);
    box-shadow: 0 0 0 3px rgba(255, 179, 26, 0.15);
}

.form-input:read-only {
    background: var(--dark-surface);
    color: var(--text-muted);
}

.form-help {
    display: block;
    margin-top: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--dark-border);
}

.form-card {
    max-width: 600px;
}

/* ============== BUTTONS ============== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--primary-gold-dark) 100%);
    color: var(--dark-bg);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 179, 26, 0.3);
}

.btn-secondary {
    background: var(--dark-bg);
    color: var(--text-primary);
    border: 1px solid var(--dark-border);
}

.btn-secondary:hover {
    border-color: var(--primary-gold);
}

.btn-danger {
    background: rgba(248, 81, 73, 0.15);
    color: var(--error);
}

.btn-danger:hover {
    background: rgba(248, 81, 73, 0.25);
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.875rem;
}

.btn-sm svg {
    width: 16px;
    height: 16px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============== TABLE ============== */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--dark-border);
}

.table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.role-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.role-admin {
    background: rgba(255, 179, 26, 0.15);
    color: var(--primary-gold);
}

.role-operator {
    background: rgba(139, 148, 158, 0.15);
    color: var(--text-secondary);
}

.action-buttons {
    display: flex;
    gap: 8px;
}

.inline-form {
    display: inline;
}

/* ============== FLASH MESSAGES ============== */
.flash-messages {
    margin-bottom: 24px;
}

.flash-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flash-success {
    background: rgba(63, 185, 80, 0.15);
    border: 1px solid rgba(63, 185, 80, 0.3);
    color: var(--success);
}

.flash-danger {
    background: rgba(248, 81, 73, 0.15);
    border: 1px solid rgba(248, 81, 73, 0.3);
    color: var(--error);
}

.flash-warning {
    background: rgba(210, 153, 34, 0.15);
    border: 1px solid rgba(210, 153, 34, 0.3);
    color: var(--warning);
}

.flash-info {
    background: rgba(139, 148, 158, 0.15);
    border: 1px solid rgba(139, 148, 158, 0.3);
    color: var(--text-secondary);
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
}

.flash-close:hover {
    opacity: 1;
}

/* ============== ERROR PAGE ============== */
.error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

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

.error-code {
    font-size: 6rem;
    font-weight: 700;
    color: var(--primary-gold);
    line-height: 1;
    margin-bottom: 16px;
}

.error-message {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

/* ============== LOGIN PAGE ============== */
.login-page {
    display: flex;
}

.login-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.brand-panel {
    flex: 1;
    background: linear-gradient(135deg, var(--dark-bg) 0%, #1A1F2E 50%, var(--dark-surface) 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px;
    position: relative;
    overflow: hidden;
}

.brand-panel::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 70%, rgba(255, 179, 26, 0.08) 0%, transparent 50%);
    animation: pulse-bg 8s ease-in-out infinite;
}

@keyframes pulse-bg {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.brand-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 500px;
}

.brand-logo {
    margin-bottom: 40px;
}

.brand-logo img {
    width: 200px;
    height: auto;
}

.brand-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--primary-gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.brand-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 40px;
}

.feature-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    text-align: left;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(255, 179, 26, 0.05);
    border: 1px solid rgba(255, 179, 26, 0.1);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.feature-item:hover {
    background: rgba(255, 179, 26, 0.1);
    border-color: rgba(255, 179, 26, 0.2);
    transform: translateX(5px);
}

.feature-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--primary-gold-dark) 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.feature-icon svg {
    width: 24px;
    height: 24px;
    stroke: var(--dark-bg);
}

.feature-text h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.feature-text p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-bar {
    position: absolute;
    bottom: 30px;
    left: 60px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.status-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.login-panel {
    width: 480px;
    background: var(--dark-surface);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 60px;
    border-left: 1px solid var(--dark-border);
}

.login-header {
    margin-bottom: 32px;
}

.login-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-form .input-wrapper {
    position: relative;
}

.login-form .input-wrapper svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    stroke: var(--text-muted);
    transition: stroke 0.3s ease;
    pointer-events: none;
}

.login-form .form-input {
    padding-left: 48px;
}

.login-form .input-wrapper:focus-within svg {
    stroke: var(--primary-gold);
}

.password-toggle {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.password-toggle svg {
    position: static !important;
    transform: none !important;
    pointer-events: auto !important;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.remember-me input {
    display: none;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--dark-border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.checkbox-custom svg {
    width: 12px;
    height: 12px;
    stroke: var(--dark-bg);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.remember-me input:checked + .checkbox-custom {
    background: var(--primary-gold);
    border-color: var(--primary-gold);
}

.remember-me input:checked + .checkbox-custom svg {
    opacity: 1;
}

.remember-me span {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.login-btn {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--primary-gold-dark) 100%);
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--dark-bg);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: inherit;
    margin-top: 8px;
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 179, 26, 0.3);
}

.login-btn:active {
    transform: translateY(0);
}

.login-btn svg {
    width: 20px;
    height: 20px;
    stroke: var(--dark-bg);
    fill: none;
}

.login-footer {
    margin-top: 32px;
    text-align: center;
}

.login-footer p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Logo móvil (solo visible en responsive) */
.mobile-logo {
    display: none;
    text-align: center;
    margin-bottom: 32px;
}

.mobile-logo img {
    width: 160px;
    height: auto;
}

.mobile-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 16px;
    background: linear-gradient(135deg, var(--primary-gold) 0%, var(--primary-gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 1024px) {
    .brand-panel {
        display: none;
    }
    
    .login-panel {
        width: 100%;
        max-width: 480px;
        margin: 0 auto;
        border-left: none;
    }
    
    .mobile-logo {
        display: block;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 20px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        gap: 16px;
    }
}

@media (max-width: 520px) {
    .login-panel {
        padding: 40px 24px;
    }

    .brand-title {
        font-size: 2rem;
    }
}
