/* ============================================
   Pollster - Sistema de Encuestas
   Global Styles
   ============================================ */

:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a1d2e;
    --sidebar-hover: #252840;
    --sidebar-active: #3b3f5c;
    --sidebar-text: #a3a6b7;
    --sidebar-text-active: #ffffff;
    --topbar-height: 56px;
    --primary: #4361ee;
    --primary-hover: #3a56d4;
    --body-bg: #f0f2f5;
    --card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--body-bg);
    color: #333;
}

/* ============================================
   Auth Pages (Login / Registro)
   ============================================ */

.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1d2e 0%, #2d3154 50%, #4361ee 100%);
    padding: 20px;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 40px 32px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: white;
    font-size: 28px;
}

.auth-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a1d2e;
    margin-bottom: 4px;
}

.auth-header p {
    font-size: 0.875rem;
    color: #6c757d;
}

.auth-btn {
    padding: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.4);
    background: linear-gradient(135deg, var(--primary-hover), #6d28d9);
}

.auth-btn:disabled {
    opacity: 0.7;
    transform: none;
    box-shadow: none;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.875rem;
    color: #6c757d;
}

.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.auth-page .form-control {
    padding: 10px 14px;
    border-radius: 10px;
    border: 1.5px solid #e2e5ea;
    font-size: 0.9rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-page .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.auth-page .form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #4a5568;
}

/* ============================================
   Sidebar
   ============================================ */

#wrapper {
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    min-height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 20px 20px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
    color: #ffffff;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
}

.sidebar-brand i {
    color: var(--primary);
    font-size: 1.4rem;
}

.sidebar-user {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    font-size: 2rem;
    color: var(--primary);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-name {
    color: #ffffff;
    font-weight: 600;
    font-size: 0.9rem;
    line-height: 1.2;
}

.user-role {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 4px;
    width: fit-content;
}

.sidebar-nav {
    list-style: none;
    padding: 8px 0;
    margin: 0;
}

.sidebar-nav .nav-section {
    padding: 16px 20px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #5a5e7a;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.sidebar-nav li a.active {
    background: var(--sidebar-active);
    color: var(--sidebar-text-active);
    border-left-color: var(--primary);
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.sidebar-nav li a.nav-logout {
    color: #ef4444;
}

.sidebar-nav li a.nav-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ============================================
   Page Content
   ============================================ */

.page-content {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.main-content {
    padding: 24px;
    min-height: calc(100vh - var(--topbar-height));
}

/* ============================================
   Topbar (mobile)
   ============================================ */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--topbar-height);
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.topbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: #1a1d2e;
}

.sidebar-toggle {
    font-size: 1.3rem;
    color: #333;
    padding: 4px 8px;
}

/* ============================================
   Connection Status Indicator (inside sidebar)
   ============================================ */

.connection-status {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.65rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.3s ease;
    margin-top: 4px;
}

.connection-status.online {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.connection-status.offline {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.connection-status.syncing {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

.connection-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.connection-status.syncing .connection-dot {
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============================================
   Overlay for mobile sidebar
   ============================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   Cards
   ============================================ */

.card {
    border-radius: 12px;
    box-shadow: var(--card-shadow);
    border: none;
}

.card-title {
    color: #1a1d2e;
}

.stat-card {
    background: #ffffff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1a1d2e;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: #6c757d;
    font-weight: 500;
}

/* ============================================
   Encuesta Cards
   ============================================ */

.encuesta-card {
    border-radius: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
    border: none;
    box-shadow: var(--card-shadow);
}

.encuesta-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

.encuesta-card .card-img-top {
    height: 140px;
    object-fit: cover;
    border-radius: 12px 12px 0 0;
}

.encuesta-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

.encuesta-meta i {
    width: 16px;
    text-align: center;
}

/* ============================================
   Camera Preview
   ============================================ */

.camera-container {
    border-radius: 12px;
    overflow: hidden;
    background: #000;
    position: relative;
}

.camera-container video {
    width: 100%;
    border-radius: 12px;
}

.camera-preview {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    border-radius: 12px;
    border: 2px solid #e2e5ea;
}

.camera-placeholder {
    background: #f8f9fa;
    border-radius: 12px;
    border: 2px dashed #dee2e6;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

/* ============================================
   Listado thumbnails
   ============================================ */

.listado-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    border: 1px solid #e2e5ea;
}

/* ============================================
   Tables
   ============================================ */

.table th {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    font-size: 0.875rem;
}

/* ============================================
   Badges
   ============================================ */

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

/* ============================================
   Alerts
   ============================================ */

.alert {
    border-radius: 10px;
    font-size: 0.875rem;
    border: none;
}

/* ============================================
   Toggle password
   ============================================ */

.toggle-password {
    border-radius: 0 10px 10px 0;
    border-color: #e2e5ea;
}

.toggle-password:hover {
    background-color: #f3f4f6;
}

/* ============================================
   Form validation
   ============================================ */

.form-control.is-invalid {
    border-color: #dc3545;
}

.form-control.is-valid {
    border-color: #198754;
}

/* ============================================
   Scrollbar
   ============================================ */

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* ============================================
   Pending sync badge
   ============================================ */

.sync-badge {
    position: relative;
}

.sync-badge::after {
    content: attr(data-count);
    position: absolute;
    top: -6px;
    right: -8px;
    background: var(--danger);
    color: white;
    font-size: 0.6rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.sync-badge[data-count="0"]::after {
    display: none;
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .page-content {
        margin-left: 0;
        width: 100%;
    }

    .main-content {
        padding: 16px;
    }

}

@media (min-width: 992px) {
    .topbar {
        display: none !important;
    }
}
