/* ===== VARIABLES ===== */
:root {
  --primary: #4361ee;
  --secondary: #3f37c9;
  --success: #4cc9f0;
  --light: #f8f9fa;
  --dark: #212529;
  --gray: #6c757d;
  --danger: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;
  
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s ease;
}

/* ===== BASE STYLES ===== */
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background-color: #f5f7fb;
  color: #495057;
  padding-top: 56px; /* Height of navbar */
  overflow-x: hidden;
}

/* ===== LAYOUT ===== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  background: linear-gradient(120deg, var(--primary), var(--secondary));
}

.sidebar {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  z-index: 1020;
  padding: 20px 0;
  background: white;
  box-shadow: var(--card-shadow);
  overflow-y: auto;
}

.sidebar .nav-link {
  font-weight: 500;
  color: #333;
  padding: 0.5rem 1rem;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
  color: var(--primary);
}

.sidebar-heading {
  font-size: .75rem;
  text-transform: uppercase;
}

main {
  margin-left: 280px;
  padding: 1rem 1.5rem;
}

/* ===== LOGIN PAGE ===== */
.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  height: calc(100vh - 56px);
  background-color: #f8f9fa;
  padding-top: 56px;
}

.login-container .card {
  width: 100%;
  max-width: 400px;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ===== CARDS ===== */
.card {
  border: none;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  transition: var(--transition);
  margin-bottom: 1.5rem;
}

.card:hover {
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.card-header {
  background: var(--light);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1.25rem 1.5rem;
  border-radius: 12px 12px 0 0 !important;
  font-weight: 600;
}

/* ===== TABLES ===== */
.table-responsive {
  overflow-x: auto;
  border-radius: 8px;
}

.table th {
  white-space: nowrap;
  border-top: none;
  font-weight: 600;
  color: var(--gray);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background-color: var(--light);
}

.table td {
  vertical-align: middle;
  border-color: #f1f3f6;
  padding: 1rem 0.75rem;
}

.table-hover tbody tr {
  transition: var(--transition);
}

.table-hover tbody tr:hover {
  background-color: rgba(67, 97, 238, 0.05);
}

/* ===== BUTTONS ===== */
.btn {
  border-radius: 8px;
  transition: var(--transition);
}

.btn-primary {
  background: linear-gradient(120deg, var(--primary), var(--secondary));
  border: none;
  padding: 0.5rem 1.25rem;
  font-weight: 500;
}

.btn-primary:hover {
  background: linear-gradient(120deg, var(--secondary), var(--primary));
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(67, 97, 238, 0.3);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 6px;
}

.btn-outline-primary {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-outline-primary:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.action-buttons .btn {
  padding: 0.4rem 0.65rem;
  margin: 0 0.15rem;
  border-radius: 6px;
}

/* ===== FORMS ===== */
.form-label {
  font-weight: 500;
}

.form-control, .form-select {
  border-radius: 8px;
  padding: 0.75rem 1rem;
  border: 1px solid #e2e8f0;
  transition: var(--transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.25rem rgba(67, 97, 238, 0.15);
}

.input-group-text {
  background-color: #f8f9fa;
  border-radius: 8px 0 0 8px;
}

/* ===== BADGES ===== */
.badge {
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
}

/* Status badges */
.badge-open, .badge-paid {
  background: rgba(40, 167, 69);
  color: #28a745;
}

.badge-closed, .badge-draft {
  background: rgba(108, 117, 125);
  color: var(--gray);
}

.badge-pending {
  background: rgba(255, 193, 7);
  color: var(--warning);
}

.badge-sent {
  background: rgba(0, 123, 255);
  color: #007bff;
}

.badge-overdue {
  background: rgba(220, 53, 69);
  color: var(--danger);
}

/* User role badges */
.badge-admin {
  background: rgba(220, 53, 69);
  color: var(--danger);
}

.badge-user {
  background: rgba(0, 123, 255);
  color: #007bff;
}

.badge-lawyer, .badge-staff {
  background: rgba(108, 117, 125);
  color: var(--gray);
}

.badge-paralegal {
  background: rgba(40, 167, 69);
  color: #28a745;
}

/* Task badges */
.task-priority-High {
  background: rgba(255, 193, 7);
  color: var(--warning);
}

.task-priority-Urgent {
  background: rgba(220, 53, 69);
  color: var(--danger);
}

.task-priority-Medium {
  background: rgba(0, 123, 255);
  color: #007bff;
}

.task-priority-Low {
  background: rgba(108, 117, 125);
  color: var(--gray);
}

.task-status-Completed {
  background: rgba(40, 167, 69);
  color: #28a745;
}

.task-status-In-Progress {
  background: rgba(23, 162, 184);
  color: var(--info);
}

.task-status-On-Hold, .task-status-Not-Started {
  background: rgba(108, 117, 125);
  color: var(--gray);
}

/* ===== MODALS ===== */
.modal {
  z-index: 1060;
}

.modal-backdrop {
  z-index: 1050;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  border: none;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
}

.modal-header {
  background: linear-gradient(120deg, #f8f9fa, #e9ecef);
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1.25rem 1.5rem;
  border-radius: 12px 12px 0 0;
}

.modal-title {
  font-weight: 600;
  color: var(--dark);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding: 1rem 1.5rem;
  border-radius: 0 0 12px 12px;
}

/* Delete confirmation modal */
.delete-confirmation-modal .modal-content {
  border: 2px solid rgba(220, 53, 69, 0.2);
}

.delete-confirmation-modal .modal-header {
  background: linear-gradient(120deg, rgba(220, 53, 69, 0.1), rgba(220, 53, 69, 0.05));
}

.delete-confirmation-icon {
  font-size: 3rem;
  color: #dc3545;
  margin-bottom: 1rem;
}

/* View details */
.view-detail-row, .case-detail-row {
  display: flex;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f3f6;
}

.view-detail-row:last-child, .case-detail-row:last-child {
  border-bottom: none;
}

.view-detail-label, .case-detail-label {
  width: 40%;
  font-weight: 600;
  color: var(--gray);
  padding-right: 1rem;
}

.view-detail-value, .case-detail-value {
  width: 60%;
  color: var(--dark);
  word-break: break-word;
}

/* ===== DATA TABLES ===== */
.dataTables_wrapper {
  padding: 0;
}

.dataTables_filter {
  display: none;
}

.dataTables_length {
  margin-bottom: 1rem;
  padding: 0 1.5rem;
}

.dataTables_length select {
  border-radius: 8px;
  padding: 0.4rem 1.5rem 0.4rem 0.5rem;
  border: 1px solid #e2e8f0;
  margin: 0 0.5rem;
}

.dataTables_info, .dataTables_paginate {
  padding: 1rem 1.5rem;
  color: var(--gray);
}

.page-item .page-link {
  border-radius: 8px;
  margin: 0 0.15rem;
  border: 1px solid #e2e8f0;
  color: var(--gray);
}

.page-item.active .page-link {
  background: linear-gradient(120deg, var(--primary), var(--secondary));
  border-color: var(--primary);
}

/* ===== UTILITY CLASSES ===== */
.min-w-100 {
  min-width: 100px;
}

.cursor-pointer {
  cursor: pointer;
}

.case-count {
  display: inline-block;
  background: rgba(76, 201, 240, 0.15);
  color: #138496;
  padding: 0.35rem 0.75rem;
  border-radius: 50px;
  font-weight: 500;
  font-size: 0.85rem;
}

/* ===== PAGE HEADER ===== */
.page-header {
  background: linear-gradient(120deg, #f5f7fb, #e6eef9);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.page-title {
  color: var(--dark);
  font-weight: 600;
  margin-bottom: 1.5rem;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--gray);
}

.empty-state i {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state p {
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

/* ===== SEARCH ===== */
.search-container {
  position: relative;
}

.search-container .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray);
  z-index: 4;
}

.search-container .form-control {
  padding-left: 40px;
  border-radius: 8px;
}

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

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-spinner {
  display: inline-block;
  width: 2rem;
  height: 2rem;
  border: 3px solid rgba(67, 97, 238, 0.1);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 767.98px) {
  .sidebar {
    position: static;
    height: auto;
    margin-top: 56px;
    padding: 0;
  }
  
  main {
    margin-left: 0;
    padding: 0 15px;
  }
  
  .card-header .row {
    flex-direction: column;
  }
  
  .card-header .float-end {
    float: none !important;
    margin-top: 1rem;
  }
  
  .action-buttons {
    display: flex;
    flex-wrap: nowrap;
  }
  
  .action-buttons .btn {
    padding: 0.35rem 0.5rem;
  }
  
  .view-detail-row, .case-detail-row {
    flex-direction: column;
  }
  
  .view-detail-label, .case-detail-label,
  .view-detail-value, .case-detail-value {
    width: 100%;
  }
  
  .view-detail-label, .case-detail-label {
    margin-bottom: 0.25rem;
  }
  
  .modal-dialog {
    margin: 0.5rem;
  }
  
  .modal-content {
    border-radius: 8px;
  }
  
  .modal-header, .modal-body, .modal-footer {
    padding: 1rem;
  }
}

/* ===== SPECIALIZED COMPONENTS ===== */
/* Invoice styles */
.invoice-box {
  max-width: 800px;
  margin: auto;
  padding: 30px;
  border: 1px solid #eee;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.15);
  font-size: 16px;
  line-height: 24px;
  font-family: 'Helvetica Neue', 'Helvetica', Arial, sans-serif;
  color: #555;
}

.invoice-box table {
  width: 100%;
  line-height: inherit;
  text-align: left;
}

.invoice-box table td {
  padding: 5px;
  vertical-align: top;
}

.invoice-box table tr td:nth-child(2) {
  text-align: right;
}

.invoice-box table tr.top table td {
  padding-bottom: 20px;
}

.invoice-box table tr.top table td.title {
  font-size: 45px;
  line-height: 45px;
  color: #333;
}

.invoice-box table tr.information table td {
  padding-bottom: 40px;
}

.invoice-box table tr.heading td {
  background: #eee;
  border-bottom: 1px solid #ddd;
  font-weight: bold;
}

.invoice-box table tr.details td {
  padding-bottom: 20px;
}

.invoice-box table tr.item td {
  border-bottom: 1px solid #eee;
}

.invoice-box table tr.item.last td {
  border-bottom: none;
}

.invoice-box table tr.total td:nth-child(2) {
  border-top: 2px solid #eee;
  font-weight: bold;
}

/* Document preview */
.document-preview {
  max-width: 100%;
  height: auto;
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
}

/* Task cards */
.task-card {
  border-left: 4px solid #dee2e6;
  transition: all 0.3s ease;
}

.task-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.task-card-urgent {
  border-left-color: var(--danger);
}

.task-card-high {
  border-left-color: var(--warning);
}

.task-card-medium {
  border-left-color: #007bff;
}

.task-card-low {
  border-left-color: var(--gray);
}

/* Timeline */
.task-timeline, .case-timeline {
  position: relative;
  padding-left: 2rem;
}

.task-timeline::before, .case-timeline::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: #dee2e6;
}

.task-timeline-item, .case-timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
}

.task-timeline-item::before, .case-timeline-item::before {
  content: '';
  position: absolute;
  left: -2rem;
  top: 0.5rem;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--primary);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary);
}

.case-timeline-date {
  font-size: 0.875rem;
  color: var(--gray);
  margin-bottom: 0.25rem;
}

.case-timeline-content {
  background-color: white;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}
.progress-chat {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    background-color: #f8f9fa;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column; /* Changed from column-reverse to column */
}
/* WhatsApp-style chat formatting */
.progress-chat {
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background-color: #f0f2f5;
    border-radius: 10px;
}

.chat-message {
    margin-bottom: 15px;
    max-width: 80%;
    clear: both;
}

.chat-message.system {
    margin: 0 auto;
    text-align: center;
    max-width: 90%;
}

.chat-message.system .chat-content {
    background-color: #e6e6e6;
    color: #666;
    padding: 8px 12px;
    border-radius: 18px;
    display: inline-block;
    font-size: 0.9em;
}

.chat-message.assigned-by {
    margin: 0 auto;
    text-align: center;
    max-width: 90%;
}

.chat-message.assigned-by .chat-content {
    background-color: #dcf8c6;
    color: #333;
    padding: 8px 12px;
    border-radius: 18px;
    display: inline-block;
    font-size: 0.9em;
}

.chat-message.admin {
    float: right;
}

.chat-message.lawyer {
    float: right;
}

.chat-message.staff {
    float: left;
}

.chat-header {
    margin-bottom: 5px;
    font-size: 0.8em;
    color: #666;
}

.chat-sender {
    font-weight: bold;
    margin-right: 8px;
}

.chat-timestamp {
    color: #999;
}

.chat-content {
    padding: 10px 15px;
    border-radius: 18px;
    word-wrap: break-word;
}

.chat-message.admin .chat-content {
    background-color: #dcf8c6;
    color: #333;
}

.chat-message.lawyer .chat-content {
    background-color: #dcf8c6;
    color: #333;
}

.chat-message.staff .chat-content {
    background-color: #ffffff;
    color: #333;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
}

.status-update {
    font-weight: bold;
    color: #25d366;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.empty-chat {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
}

/* Task priority and status badges */
.task-priority-High {
    background-color: #dc3545;
}

.task-priority-Medium {
    background-color: #fd7e14;
}

.task-priority-Low {
    background-color: #198754;
}

.task-status-Pending {
    background-color: #6c757d;
}

.task-status-In-Progress {
    background-color: #0d6efd;
}

.task-status-Completed {
    background-color: #198754;
}

.task-status-Overdue {
    background-color: #dc3545;
}
/* WhatsApp-style progress notes */
.progress-chat {
    max-height: 500px;
    overflow-y: auto;
    padding: 15px;
    background-color: #f0f2f5;
    display: flex;
    flex-direction: column;
}

.chat-message {
    margin-bottom: 15px;
    padding: 8px 12px;
    border-radius: 8px;
    position: relative;
    max-width: 85%;
}

.chat-message.system {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    max-width: 90%;
}

.chat-message.staff {
    background-color: #dcf8c6;
    margin-right: auto;
    border-radius: 8px 8px 8px 0;
}

.chat-message.admin,
.chat-message.lawyer,
.chat-message.assigned-by {
    background-color: #fff3e0;
    margin-left: auto;
    border-radius: 8px 8px 0 8px;
}

.chat-message.lawyer {
    background-color: #e6e6ff;
}

.chat-message.assigned-by {
    background-color: #ffe6cc;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.chat-sender {
    font-weight: 600;
    font-size: 0.85rem;
    color: #075e54;
}

.chat-timestamp {
    font-size: 0.7rem;
    color: #667781;
    margin-left: 8px;
}

.chat-content {
    margin: 0;
    line-height: 1.4;
    font-size: 0.9rem;
    color: #303030;
    text-align: left;
    word-wrap: break-word;
}

.chat-message.system .chat-sender {
    color: #1976d2;
}

.chat-message.system .chat-content {
    color: #666;
    font-style: italic;
}

.chat-message.staff .chat-sender {
    color: #128c7e;
}

.chat-message.admin .chat-sender {
    color: #f57c00;
}

.chat-message.lawyer .chat-sender {
    color: #7b1fa2;
}

.chat-message.assigned-by .chat-sender {
    color: #e65100;
}

.status-update {
    background: linear-gradient(135deg, #25d366, #128c7e);
    color: white;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    display: inline-block;
    margin-bottom: 5px;
}

/* Scrollbar styling */
.progress-chat::-webkit-scrollbar {
    width: 6px;
}

.progress-chat::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.progress-chat::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.progress-chat::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}
/* Alert animations */
.alert {
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.alert.fade {
    opacity: 0;
}

.alert-dismissible .btn-close {
    padding: 0.75rem 1.25rem;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
}

/* Progress bar for alerts */
.alert-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.alert-progress-bar {
    height: 100%;
    width: 100%;
    background-color: rgba(0, 0, 0, 0.2);
    animation: progressBar 5s linear forwards;
}

@keyframes progressBar {
    0% { width: 100%; }
    100% { width: 0%; }
}

/* Accessibility and contrast improvements */
body, .app-main, .card, .modal-content { color: #1f2937; }
.text-muted, .form-text, small, .table td, .table td *, .table tbody td { color: #475569 !important; }
.table td .btn i, .action-buttons .btn i { color: inherit !important; }
.table td strong, .table td .fw-semibold, .table td .fw-bold, .page-title, h1, h2, h3, h4, h5, h6 { color: #0f172a; }
.navbar, .app-navbar { background: linear-gradient(135deg, #0f172a, #1e3a8a) !important; }
.navbar .navbar-brand, .navbar .nav-link, .navbar .btn-link, .navbar .dropdown-toggle, .navbar .fas { color: #f8fafc !important; }
.sidebar .nav-link { color: #1e293b; }
.sidebar .nav-link.active, .sidebar .nav-link:hover { color: #1d4ed8; background: #eff6ff; border-radius: 10px; }
.badge { display: inline-flex; align-items: center; justify-content: center; min-width: 78px; }
.badge-draft { background: #e5e7eb; color: #374151; }
.badge-sent { background: #dbeafe; color: #1d4ed8; }
.badge-paid { background: #dcfce7; color: #166534; }
.badge-overdue { background: #fee2e2; color: #b91c1c; }
.badge-open { background: #dcfce7; color: #166534; }
.badge-closed { background: #e5e7eb; color: #374151; }
.badge-pending { background: #fef3c7; color: #92400e; }
.btn-outline-secondary { color: #334155; border-color: #94a3b8; }
.btn-outline-secondary:hover { color: #0f172a; background: #e2e8f0; }
.form-control::placeholder { color: #94a3b8; }
