/* Theme Variables */
:root[data-theme="light"] {
  --primary-color: #2962ff;
  --secondary-color: #0039cb;
  --background-color: #f5f5f5;
  --surface-color: #ffffff;
  --text-primary: #212121;
  --text-secondary: #757575;
  --error-color: #f44336;
  --warning-color: #ff9800;
  --success-color: #4caf50;
  --chart-background: #ffffff;
  --terminal-background: #1e1e1e;
  --terminal-text: #ffffff;
}

:root[data-theme="dark"] {
  --primary-color: #82b1ff;
  --secondary-color: #448aff;
  --background-color: #121212;
  --surface-color: #1e1e1e;
  --text-primary: #ffffff;
  --text-secondary: #b0b0b0;
  --error-color: #ff5252;
  --warning-color: #ffab40;
  --success-color: #69f0ae;
  --chart-background: #2d2d2d;
  --terminal-background: #000000;
  --terminal-text: #00ff00;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: var(--background-color);
  color: var(--text-primary);
}

.app-container {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

/* Sidebar Styles */
.sidebar {
  background-color: var(--surface-color);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
  color: var(--primary-color);
  font-weight: 600;
  font-size: 1.2rem;
}

.nav-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-items li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.nav-items li:hover {
  background-color: rgba(41, 98, 255, 0.1);
}

.nav-items li.active {
  background-color: var(--primary-color);
  color: white;
}

.nav-items li:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.user-profile {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.avatar {
  width: 40px;
  height: 40px;
  background-color: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

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

.user-info .name {
  font-weight: 500;
}

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

/* Main Content Styles */
main {
  padding: 1.5rem;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--surface-color);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  width: 300px;
}

.search input {
  border: none;
  outline: none;
  background: none;
  width: 100%;
  font-size: 1rem;
}

.search input:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.notification-btn {
  background: none;
  border: none;
  cursor: pointer;
  position: relative;
}

.notification-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background-color: var(--error-color);
  color: white;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  min-width: 20px;
}

/* Dashboard Grid */
.metrics-grid {
  margin-top: 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: var(--surface-color);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.metric-card h3 {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.metric {
  font-size: 2rem;
  font-weight: 600;
  margin-bottom: 1rem;
}

.chart {
  height: 100px;
  max-height: 400px;
  background-color: var(--chart-background);
  display: block;
}

.chart:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Data Grid */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.integrations-list, .terminal-container {
  background-color: var(--surface-color);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

/* Terminal */
#terminal {
  background-color: var(--terminal-background);
  color: var(--terminal-text);
  padding: 1rem;
  border-radius: 8px;
  font-family: "Courier New", Courier, monospace;
  height: 300px;
  overflow-y: auto;
}

/* Notification Panel */
.notification-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 400px;
  height: 100vh;
  background-color: var(--surface-color);
  box-shadow: -2px 0 4px rgba(0, 0, 0, 0.1);
  padding: 1.5rem;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
}

.notification-panel.visible {
  transform: translateX(0);
}

.notification-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.close-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.notification-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.notification-item {
  padding: 1rem;
  border-radius: 8px;
  background-color: var(--background-color);
}

.remove-notification {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-secondary);
}

.remove-notification:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.hidden {
  display: none;
}

.login-portal,
.login-container,
.login-header,
.login-tabs,
.login-form {
  display: none;
}

/* Content Pages Styles */
.content-page {
  display: none;
  padding: 1.5rem;
}

.content-page.active {
  display: block;
}

/* Access Control Page */
.access-control-actions {
  margin-bottom: 1.5rem;
}

.add-user-btn,
.add-integration-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  transition: background-color 0.2s;
}

.add-user-btn:hover,
.add-integration-btn:hover {
  background-color: var(--secondary-color);
}

.add-user-btn:focus,
.add-integration-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

#usersTable {
  background: var(--surface-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.action-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 0.5rem;
  font-size: 0.875rem;
}

.action-btn.delete {
  background-color: var(--error-color);
}

.action-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  background-color: #e0e0e0;
}

.status-badge.active {
  background-color: var(--success-color);
  color: white;
}

.status-badge.inactive {
  background-color: var(--error-color);
  color: white;
}

/* Integrations Page */
.integration-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin-top: 1rem;
}

.integration-card {
  position: relative;
  padding: 1.5rem;
  background: var(--surface-color);
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.integration-card .status-indicator {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.integration-card .status-indicator.active {
  background-color: var(--success-color);
  box-shadow: 0 0 8px var(--success-color);
}

.integration-card .status-indicator.inactive {
  background-color: var(--error-color);
  box-shadow: 0 0 8px var(--error-color);
}

.integration-card .status-indicator.warning {
  background-color: var(--warning-color);
  box-shadow: 0 0 8px var(--warning-color);
}

.integration-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.stat-item {
  text-align: center;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 6px;
}

.stat-item .value {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
}

.stat-item .label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* Monitoring Page */
.monitoring-card {
  position: relative;
  padding: 1.5rem;
  background: var(--surface-color);
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  height: 300px;
}

.monitoring-card canvas {
  width: 100% !important;
  height: calc(100% - 3rem) !important;
}

.system-status {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.status-box {
  flex: 1;
  padding: 1rem;
  border-radius: 8px;
  background: var(--surface-color);
  text-align: center;
}

.status-box.healthy {
  border: 2px solid var(--success-color);
}

.status-box.warning {
  border: 2px solid var(--warning-color);
}

.status-box.error {
  border: 2px solid var(--error-color);
}

/* Terminal Page Styles */
.terminal-page .terminal-container {
  height: calc(100vh - 200px);
  background: var(--terminal-background);
  border-radius: 12px;
  padding: 1rem;
  overflow: hidden;
}

.terminal-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.terminal-actions {
  display: flex;
  gap: 0.5rem;
}

.terminal-btn {
  background: none;
  border: 1px solid var(--text-secondary);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.terminal-btn:hover {
  background: var(--text-secondary);
  color: var(--surface-color);
}

.terminal-btn:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

#terminalInput {
  width: 100%;
  background: var(--terminal-background);
  border: none;
  color: var(--terminal-text);
  padding: 0.5rem;
  font-family: 'Courier New', Courier, monospace;
  margin-top: 1rem;
}

#terminalInput:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Users Table */
.users-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  background: var(--surface-color);
  border-radius: 12px;
  overflow: hidden;
}

.users-table th,
.users-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid #eee;
}

/* Web Analytics Page Styles */
.analytics-summary {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 1.5rem;
  margin-bottom: 2rem;
  max-height: 300px;
}

.analytics-card {
  background: var(--surface-color);
  padding: 1.25rem;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  max-height: 300px;
  margin-bottom: 12rem;
}

.analytics-value {
  font-size: 2rem;
  font-weight: 600;
  margin: 0.5rem 0;
  max-height: auto;
}

.trend {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  max-height: auto;
}

.trend.positive {
  background-color: rgba(76, 175, 80, 0.1);
  color: var(--success-color);
  max-height: auto;
}

.trend.negative {
  background-color: rgba(244, 67, 54, 0.1);
  color: var(--error-color);
  max-height: auto;
}

.analytics-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.detail-card {
  background: var(--surface-color);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  max-height: 400px;
}

.top-pages-list {
  margin-top: 1rem;
}

.page-item {
  padding: 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-item:last-child {
  border-bottom: none;
}

.page-info {
  display: flex;
  flex-direction: column;
}

.page-path {
  font-weight: 500;
  margin-bottom: 0.25rem;
}

.page-views {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.page-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
}

.avg-time, .bounce-rate {
  color: var(--text-secondary);
}

/* Theme Toggle Styles */
.theme-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface-color);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 1000;
  border: none;
  color: var(--text-primary);
}

.theme-toggle:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
}

.theme-menu {
  position: fixed;
  bottom: 80px;
  right: 20px;
  background: var(--surface-color);
  border-radius: 12px;
  padding: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  display: none;
  z-index: 1000;
}

.theme-menu.visible {
  display: block;
}

.theme-option {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--text-primary);
}

.theme-option:hover {
  background: rgba(0,0,0,0.05);
}

.theme-option:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.theme-option.active {
  background: var(--primary-color);
  color: white;
}

/* Profile Card Styles */
.profile-section {
  margin-bottom: 2rem;
  display: flex;
  justify-content: center;
}

.profile-section .card {
  width: 320px;
  background: var(--surface-color);
  border-radius: 12px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.8s ease-out forwards;
}

.profile-section .avatar-container {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 1rem;
}

.profile-section .cloud {
  position: absolute;
  top: 0;
  left: 0;
  width: 120px;
  height: 120px;
  animation: cloudIn 1s ease-out forwards;
  background: var(--primary-color);
  opacity: 0.1;
  border-radius: 50%;
}

.profile-section .avatar {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  border: 3px solid var(--primary-color);
  object-fit: cover;
}

.profile-section .card-title {
  font-size: 1.5rem;
  margin: 0.5rem 0;
  opacity: 0;
  animation: textFadeIn 0.6s ease-out 0.8s forwards;
  color: var(--text-primary);
}

.profile-section .card-description {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  opacity: 0;
  animation: textFadeIn 0.6s ease-out 1s forwards;
}

.profile-section .social-icons {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.profile-section .social-icons a {
  opacity: 0;
  transform: translateY(10px);
  animation: iconFadeIn 0.5s ease-out forwards;
}

.profile-section .social-icons a:nth-child(1) { animation-delay: 1.2s; }
.profile-section .social-icons a:nth-child(2) { animation-delay: 1.3s; }
.profile-section .social-icons a:nth-child(3) { animation-delay: 1.4s; }

.profile-section .social-icons a:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

.profile-section .social-icons svg {
  width: 24px;
  height: 24px;
  fill: var(--primary-color);
  transition: all 0.3s ease;
}

.profile-section .social-icons a:hover svg {
  fill: var(--surface-color);
  background: var(--primary-color);
  border-radius: 50%;
  padding: 4px;
}

/* Accessibility Focus Styles */
button:focus,
input:focus,
a:focus,
canvas:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Animations */
@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cloudIn {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 0.1;
    transform: scale(1);
  }
}

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

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