/* 
 * PTI AI Call Analysis Platform - Responsive & Dark Mode CSS
 * Supports mobile devices and dark mode toggle
 */

/* CSS Variables for Theme Management */
:root {
  /* PTI Brand Colors */
  --pti-primary-blue: #005cba;
  --pti-highlight-green: #00aa71;
  --pti-secondary-blue: #0780e2;
  --pti-grey: #626569;
  --pti-alert-red: #ef4b54;

  /* Light Theme Colors */
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --bg-tertiary: #e9ecef;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-tertiary: #adb5bd;
  --border-color: #dee2e6;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --card-bg: #ffffff;
  --input-bg: #ffffff;
  --hover-bg: #f8f9fa;

  /* Component specific */
  --navbar-bg: var(--pti-primary-blue);
  --navbar-text: #ffffff;
  --sidebar-bg: #f8f9fa;
  --sidebar-text: #212529;
  --footer-bg: var(--pti-grey);
  --footer-text: #ffffff;

  /* Transitions */
  --transition-speed: 0.3s;
}

/* Dark Theme */
[data-theme='dark'] {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2d2d2d;
  --bg-tertiary: #3a3a3a;
  --text-primary: #e0e0e0;
  --text-secondary: #b0b0b0;
  --text-tertiary: #808080;
  --border-color: #404040;
  --shadow-color: rgba(0, 0, 0, 0.3);
  --card-bg: #2d2d2d;
  --input-bg: #3a3a3a;
  --hover-bg: #3a3a3a;

  /* Adjusted component colors for dark mode */
  --navbar-bg: #001f3f;
  --sidebar-bg: #2d2d2d;
  --sidebar-text: #e0e0e0;
  --footer-bg: #1a1a1a;
}

/* Base Styles */
* {
  box-sizing: border-box;
  transition:
    background-color var(--transition-speed) ease,
    color var(--transition-speed) ease,
    border-color var(--transition-speed) ease;
}

body {
  margin: 0;
  padding: 0;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Container System */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

@media (min-width: 576px) {
  .container {
    padding: 0 20px;
  }
}

@media (min-width: 768px) {
  .container {
    padding: 0 30px;
  }
}

@media (min-width: 1200px) {
  .container {
    padding: 0 40px;
  }
}

/* Grid System */
.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -15px;
}

.col {
  flex: 1;
  padding: 0 15px;
}

/* Responsive columns */
.col-12 {
  flex: 0 0 100%;
  max-width: 100%;
}
.col-md-6 {
  flex: 0 0 100%;
  max-width: 100%;
}
.col-md-4 {
  flex: 0 0 100%;
  max-width: 100%;
}
.col-md-3 {
  flex: 0 0 100%;
  max-width: 100%;
}
.col-lg-8 {
  flex: 0 0 100%;
  max-width: 100%;
}
.col-lg-4 {
  flex: 0 0 100%;
  max-width: 100%;
}

@media (min-width: 768px) {
  .col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }
  .col-md-4 {
    flex: 0 0 33.333333%;
    max-width: 33.333333%;
  }
  .col-md-3 {
    flex: 0 0 25%;
    max-width: 25%;
  }
}

@media (min-width: 992px) {
  .col-lg-8 {
    flex: 0 0 66.666667%;
    max-width: 66.666667%;
  }
  .col-lg-4 {
    flex: 0 0 33.333333%;
    max-width: 33.333333%;
  }
}

/* Navigation Bar */
.navbar {
  background-color: var(--navbar-bg);
  color: var(--navbar-text);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 4px var(--shadow-color);
}

.navbar-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.navbar-brand {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--navbar-text);
  text-decoration: none;
}

.navbar-nav {
  display: none;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 1.5rem;
}

.navbar-nav.active {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin-top: 1rem;
}

.navbar-nav a {
  color: var(--navbar-text);
  text-decoration: none;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background-color var(--transition-speed);
}

.navbar-nav a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: block;
  background: none;
  border: none;
  color: var(--navbar-text);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

@media (min-width: 768px) {
  .navbar-nav {
    display: flex;
    flex-direction: row;
    width: auto;
    margin-top: 0;
  }

  .mobile-menu-toggle {
    display: none;
  }
}

/* Cards */
.card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 4px var(--shadow-color);
  transition:
    transform var(--transition-speed),
    box-shadow var(--transition-speed);
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px var(--shadow-color);
}

.card-header {
  font-size: 1.25rem;
  font-weight: bold;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.card-body {
  color: var(--text-secondary);
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--input-bg);
  color: var(--text-primary);
  transition: border-color var(--transition-speed);
}

.form-control:focus {
  outline: none;
  border-color: var(--pti-secondary-blue);
  box-shadow: 0 0 0 3px rgba(7, 128, 226, 0.1);
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all var(--transition-speed);
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background-color: var(--pti-primary-blue);
  color: white;
}

.btn-primary:hover {
  background-color: #004a96;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--pti-secondary-blue);
  color: white;
}

.btn-secondary:hover {
  background-color: #0668c0;
}

.btn-success {
  background-color: var(--pti-highlight-green);
  color: white;
}

.btn-success:hover {
  background-color: #00885a;
}

.btn-danger {
  background-color: var(--pti-alert-red);
  color: white;
}

.btn-danger:hover {
  background-color: #d93d45;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 6px var(--shadow-color);
  transition: all var(--transition-speed);
  z-index: 1000;
}

.dark-mode-toggle:hover {
  transform: scale(1.1);
}

.dark-mode-toggle i {
  font-size: 1.25rem;
  color: var(--text-primary);
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--card-bg);
}

.table th,
.table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.table th {
  font-weight: 600;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

.table tr:hover {
  background-color: var(--hover-bg);
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 576px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .dashboard-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Metric Cards */
.metric-card {
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
}

.metric-value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--pti-primary-blue);
  margin-bottom: 0.5rem;
}

[data-theme='dark'] .metric-value {
  color: var(--pti-secondary-blue);
}

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

/* Sidebar */
.sidebar {
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  height: 100vh;
  position: fixed;
  left: -250px;
  top: 0;
  width: 250px;
  transition: left var(--transition-speed);
  z-index: 999;
  overflow-y: auto;
}

.sidebar.active {
  left: 0;
}

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

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

@media (min-width: 992px) {
  .sidebar {
    position: relative;
    left: 0;
    height: auto;
    min-height: calc(100vh - 60px);
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* Alerts */
.alert {
  padding: 1rem;
  margin-bottom: 1rem;
  border-radius: 4px;
  border: 1px solid transparent;
}

.alert-info {
  background-color: rgba(7, 128, 226, 0.1);
  border-color: var(--pti-secondary-blue);
  color: var(--pti-secondary-blue);
}

.alert-success {
  background-color: rgba(0, 170, 113, 0.1);
  border-color: var(--pti-highlight-green);
  color: var(--pti-highlight-green);
}

.alert-warning {
  background-color: rgba(255, 193, 7, 0.1);
  border-color: #ffc107;
  color: #856404;
}

.alert-danger {
  background-color: rgba(239, 75, 84, 0.1);
  border-color: var(--pti-alert-red);
  color: var(--pti-alert-red);
}

[data-theme='dark'] .alert-warning {
  color: #ffc107;
}

/* Loading Spinner */
.spinner {
  border: 3px solid var(--bg-tertiary);
  border-top: 3px solid var(--pti-primary-blue);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 2rem auto;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Chat Interface */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  max-height: 600px;
  background-color: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  background-color: var(--bg-secondary);
}

.chat-message {
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-bubble {
  max-width: 70%;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  background-color: var(--card-bg);
  box-shadow: 0 1px 2px var(--shadow-color);
}

.chat-message.user .chat-bubble {
  background-color: var(--pti-primary-blue);
  color: white;
}

.chat-input-container {
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.75rem;
}

.chat-input {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--input-bg);
  color: var(--text-primary);
}

/* Footer */
.footer {
  background-color: var(--footer-bg);
  color: var(--footer-text);
  padding: 2rem 0;
  margin-top: 3rem;
  text-align: center;
}

.footer a {
  color: var(--footer-text);
  text-decoration: none;
}

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

/* Utility Classes */
.text-center {
  text-align: center;
}
.text-left {
  text-align: left;
}
.text-right {
  text-align: right;
}

.mt-1 {
  margin-top: 0.5rem;
}
.mt-2 {
  margin-top: 1rem;
}
.mt-3 {
  margin-top: 1.5rem;
}
.mt-4 {
  margin-top: 2rem;
}
.mt-5 {
  margin-top: 3rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}
.mb-2 {
  margin-bottom: 1rem;
}
.mb-3 {
  margin-bottom: 1.5rem;
}
.mb-4 {
  margin-bottom: 2rem;
}
.mb-5 {
  margin-bottom: 3rem;
}

.p-1 {
  padding: 0.5rem;
}
.p-2 {
  padding: 1rem;
}
.p-3 {
  padding: 1.5rem;
}
.p-4 {
  padding: 2rem;
}
.p-5 {
  padding: 3rem;
}

.d-none {
  display: none;
}
.d-block {
  display: block;
}
.d-flex {
  display: flex;
}
.d-grid {
  display: grid;
}

/* Mobile Specific Adjustments */
@media (max-width: 576px) {
  .navbar-brand {
    font-size: 1.25rem;
  }

  .metric-value {
    font-size: 1.5rem;
  }

  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }

  .chat-bubble {
    max-width: 85%;
  }

  .dark-mode-toggle {
    bottom: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
  }
}

/* Print Styles */
@media print {
  .navbar,
  .sidebar,
  .footer,
  .dark-mode-toggle,
  .mobile-menu-toggle {
    display: none !important;
  }

  body {
    color: #000;
    background: #fff;
  }

  .card {
    break-inside: avoid;
  }
}

/* Accessibility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Focus Styles */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--pti-secondary-blue);
  outline-offset: 2px;
}

/* Smooth Scrolling */
html {
  scroll-behavior: smooth;
}

/* Selection Color */
::selection {
  background-color: var(--pti-secondary-blue);
  color: white;
}

::-moz-selection {
  background-color: var(--pti-secondary-blue);
  color: white;
}
