@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: rgba(17, 24, 39, 0.7);
  --bg-card: rgba(31, 41, 55, 0.4);
  --bg-input: rgba(17, 24, 39, 0.5);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --primary: #6366f1; /* Indigo */
  --primary-hover: #4f46e5;
  --success: #10b981; /* Emerald */
  --danger: #ef4444; /* Rose */
  --warning: #f59e0b; /* Amber */
  --border-color: rgba(75, 85, 99, 0.3);
  
  --glass-bg: rgba(17, 24, 39, 0.75);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ==========================================
   SCROLLBAR BEAUTIFIER
   ========================================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ==========================================
   LOGIN PAGE STYLES
   ========================================== */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  border-radius: 16px;
  width: 100%;
  max-width: 440px;
  padding: 40px;
  animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo {
  text-align: center;
  margin-bottom: 30px;
}

.login-logo h1 {
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  background: linear-gradient(to right, #6366f1, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}

.login-logo p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 5px;
}

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

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

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

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition-fast);
  gap: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.85rem;
  border-radius: 6px;
}

.btn-full {
  width: 100%;
}

/* ==========================================
   APP LAYOUT (DASHBOARD)
   ========================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-right: 1px solid var(--glass-border);
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 100;
  transition: var(--transition-normal);
}

.sidebar-logo {
  margin-bottom: 40px;
  padding-left: 10px;
}

.sidebar-logo h2 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.05em;
  background: linear-gradient(to right, #6366f1, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-nav {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item a {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 0.95rem;
  transition: var(--transition-fast);
  gap: 12px;
}

.nav-item a:hover, .nav-item.active a {
  color: var(--text-primary);
  background: rgba(99, 102, 241, 0.15);
  border-left: 3px solid var(--primary);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 10px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 1rem;
}

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

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
}

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

/* Main Content Area */
.main-content {
  margin-left: 260px;
  flex-grow: 1;
  padding: 40px;
  transition: var(--transition-normal);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 20px;
}

.header-title h1 {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.header-title p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* ==========================================
   CARDS & GRID
   ========================================= */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 40px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition-fast);
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(99, 102, 241, 0.4);
}

.metric-info h3 {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.metric-info .value {
  font-size: 1.8rem;
  font-weight: 700;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--primary);
}

.metric-card.success .metric-icon {
  color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

/* Content Container Card */
.content-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
}

.content-card h2 {
  font-size: 1.25rem;
  margin-bottom: 20px;
  font-weight: 600;
}

/* ==========================================
   TABLES
   ========================================= */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

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

.custom-table th {
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.custom-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.custom-table tr:last-child td {
  border-bottom: none;
}

.custom-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 12px;
  gap: 4px;
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.badge-info {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

/* ==========================================
   STREAM / LIVE CARDS
   ========================================= */
.cameras-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 25px;
}

.camera-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition-fast);
}

.camera-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99, 102, 241, 0.4);
}

.camera-preview {
  height: 180px;
  background: #1f2937;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.camera-preview .placeholder {
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.camera-preview .placeholder i {
  font-size: 3rem;
}

.camera-status-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 10;
}

.camera-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-grow: 1;
}

.camera-info h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.camera-info p.company {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.camera-details {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.camera-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

/* ==========================================
   MODAL DIALOG
   ========================================= */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
  padding: 20px;
}

.modal.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-content.modal-lg {
  max-width: 900px;
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================
   VIDEO PLAYER DESIGN
   ========================================= */
.video-wrapper {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  height: 0;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.video-wrapper iframe, .video-wrapper video {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* ==========================================
   ANIMATIONS & RESPONSIVE
   ========================================= */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Hamburguer menu for mobile */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.5rem;
  cursor: pointer;
}

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
    padding: 20px;
  }
  
  .menu-toggle {
    display: block;
  }
}

@media (max-width: 640px) {
  .login-card {
    padding: 24px;
  }
  .header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  .header-actions {
    width: 100%;
  }
  .header-actions .btn {
    flex-grow: 1;
  }
}

/* ==========================================
   LINHA DO TEMPO DVR (24 HORAS)
   ========================================= */
.dvr-timeline-wrapper {
  margin-top: 20px;
  margin-bottom: 20px;
}

.dvr-timeline-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.dvr-timeline-container {
  position: relative;
  width: 100%;
  height: 45px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  overflow: hidden;
  cursor: pointer;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.5);
  margin-bottom: 5px;
}

.dvr-timeline-segment {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(46, 213, 115, 0.35); /* Verde translúcido para gravação ativa */
  border-left: 1px solid rgba(46, 213, 115, 0.7);
  border-right: 1px solid rgba(46, 213, 115, 0.7);
  transition: background var(--transition-fast);
}

.dvr-timeline-segment:hover {
  background: rgba(46, 213, 115, 0.55);
}

.dvr-timeline-playhead {
  position: absolute;
  top: 0;
  width: 3px;
  height: 100%;
  background: #ff4757; /* Linha de cursor vermelha */
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(255, 71, 87, 0.9);
}

.dvr-timeline-ticks {
  display: flex;
  justify-content: space-between;
  padding: 0 5px;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: monospace;
  pointer-events: none;
}
