/* Estilo do Dashboard - IP Cam Central */

/* --- Variáveis Globais (Design System) --- */
:root {
    --bg-main: #090d16;
    --bg-glass: rgba(17, 24, 39, 0.65);
    --bg-glass-hover: rgba(31, 41, 55, 0.8);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-hover: rgba(99, 102, 241, 0.3);
    
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --grad-primary: linear-gradient(135deg, #6366f1 0%, #3b82f6 100%);
    --grad-danger: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    
    --color-text-main: #f8fafc;
    --color-text-muted: #94a3b8;
    
    --color-success: #10b981;
    --color-danger: #f43f5e;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
    
    --font-family: 'Inter', sans-serif;
    --shadow-main: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.2);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition-fast: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Reset & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--color-text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* Fundo Abstrato com Brilho Dinâmico */
body::before {
    content: '';
    position: absolute;
    top: -10%;
    left: -10%;
    width: 60%;
    height: 60%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.15) 0%, rgba(99, 102, 241, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

body::after {
    content: '';
    position: absolute;
    bottom: -10%;
    right: -10%;
    width: 50%;
    height: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

/* --- Layout Estrutural --- */
.app-container {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    flex-grow: 1;
}

/* --- Header --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-main);
    margin-bottom: 32px;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 2.2rem;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(99, 102, 241, 0.3));
}

.logo-text h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

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

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

/* Badges de Status */
.status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
    transition: var(--transition-fast);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* Estados do Badge */
.status-checking {
    background: rgba(148, 163, 184, 0.1);
    color: var(--color-text-muted);
    border-color: rgba(148, 163, 184, 0.2);
}
.status-checking .status-dot {
    background: var(--color-text-muted);
    animation: pulse 1.5s infinite;
}

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

.status-offline {
    background: rgba(244, 63, 94, 0.1);
    color: var(--color-danger);
    border-color: rgba(244, 63, 94, 0.2);
}
.status-offline .status-dot {
    background: var(--color-danger);
}

/* --- Botões --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-primary {
    background: var(--grad-primary);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4), var(--shadow-glow);
}
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--color-text-main);
    border: 1px solid var(--border-glass);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
    background: var(--grad-danger);
    color: white;
}
.btn-danger:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
    border-radius: var(--radius-lg);
}

/* --- Grid de Câmeras --- */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.cameras-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
    gap: 28px;
    width: 100%;
}

/* --- Card de Câmera (Premium Glassmorphism) --- */
.camera-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-main);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
}

.camera-card:hover {
    transform: translateY(-6px);
    border-color: var(--border-glass-hover);
    box-shadow: var(--shadow-main), var(--shadow-glow);
}

/* Vídeo Wrapper (Aspect Ratio 16:9) */
.camera-video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background-color: #000;
    overflow: hidden;
}

.camera-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Estado de Erro ou Sem Vídeo */
.video-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: linear-gradient(135deg, #111827 0%, #030712 100%);
    color: var(--color-text-muted);
}
.video-placeholder i {
    font-size: 2.2rem;
    color: rgba(255, 255, 255, 0.25);
}
.video-placeholder p {
    font-size: 0.85rem;
}

/* Spinner de Carregamento */
.video-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(99, 102, 241, 0.2);
    border-top: 3px solid var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    pointer-events: none;
    z-index: 5;
}

/* Overlay de Ações no Card (Aparece ao passar o mouse) */
.camera-card-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.6) 100%);
    opacity: 0;
    transition: var(--transition-fast);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 16px;
    z-index: 3;
}

.camera-card:hover .camera-card-overlay {
    opacity: 1;
}

.overlay-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.camera-live-badge {
    background: var(--color-danger);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
    animation: glow-pulse 1.5s infinite alternate;
}

.overlay-actions-top {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-icon:hover {
    background: var(--color-primary);
    transform: scale(1.1);
}
.btn-icon-danger:hover {
    background: var(--color-danger);
}

.overlay-bottom {
    display: flex;
    justify-content: flex-end;
}

/* Informações da Câmera (Área de Texto abaixo do Vídeo) */
.camera-info {
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.camera-info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.camera-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--color-text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.camera-info-body {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}

.camera-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    line-height: 1.4;
    min-height: 20px;
    flex: 1;
}

/* Botões de Abertura de Portão (MQTT) */
.btn-gate {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--grad-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.2);
    white-space: nowrap;
}

.btn-gate:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(99, 102, 241, 0.4);
    filter: brightness(1.1);
}

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

.btn-gate:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Estado Vazio --- */
.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-grow: 1;
    min-height: 400px;
}

.empty-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(12px);
    padding: 48px;
    border-radius: var(--radius-lg);
    text-align: center;
    max-width: 500px;
    box-shadow: var(--shadow-main);
}

.empty-icon {
    font-size: 4rem;
    color: rgba(99, 102, 241, 0.2);
    margin-bottom: 24px;
}

.empty-card h2 {
    font-size: 1.4rem;
    margin-bottom: 12px;
}

.empty-card p {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 28px;
    line-height: 1.6;
}

/* --- Modais --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: var(--transition-fast);
}

.modal-container {
    background: #0f172a;
    border: 1px solid var(--border-glass-hover);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), var(--shadow-glow);
    width: 90%;
    max-width: 550px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
}
.btn-close:hover {
    color: white;
}

.modal-body {
    padding: 24px;
}

/* Formulários */
.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    color: white;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition-fast);
}
.form-group input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.2);
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
}

/* --- Fullscreen Simulado (Visualização Ampliada) --- */
.fullscreen-container {
    width: 95vw;
    height: 90vh;
    max-width: 1200px;
    background: #000;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-enter 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fullscreen-header {
    background: #090d16;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.fullscreen-video-wrapper {
    flex-grow: 1;
    position: relative;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fullscreen-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.fullscreen-overlay-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.75);
    padding: 10px 20px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.05);
    pointer-events: none;
}

/* --- Utilidades --- */
.hidden {
    display: none !important;
}

/* --- Footer --- */
.main-footer {
    text-align: center;
    padding: 24px 0 8px 0;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: auto;
}

/* --- Animações --- */
@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

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

@keyframes glow-pulse {
    from {
        box-shadow: 0 0 4px rgba(244, 63, 94, 0.5);
    }
    to {
        box-shadow: 0 0 12px rgba(244, 63, 94, 0.8);
    }
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* --- Histórico de Logs --- */
.logs-modal-container {
    max-width: 800px !important;
}

.table-responsive {
    max-height: 450px;
    overflow-y: auto;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
}

.logs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.logs-table th, 
.logs-table td {
    padding: 14px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.logs-table th {
    background-color: #0d1322;
    font-weight: 600;
    color: var(--color-text-muted);
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logs-table tr {
    transition: var(--transition-fast);
}

.logs-table tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.status-badge-log {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
}

.status-badge-log.success {
    background-color: rgba(16, 185, 129, 0.15);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge-log.failed {
    background-color: rgba(244, 63, 94, 0.15);
    color: var(--color-danger);
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.error-details {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ajustes específicos do Modal de Login */
#login-modal .modal-container {
    max-width: 420px;
}


