/***************************************************************
* site.css
* Custom styles for AISSURE.Pilot application
***************************************************************/

/* Base styles */
html {
  font-size: 14px;
  scroll-behavior: smooth;
  position: relative;
  min-height: 100%;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f8f9fc;
  color: #5a5c69;
  margin-bottom: 60px;
  line-height: 1.6;
}

/* Focus styles */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #5f9d90;
}

/* Layout */
.content-wrapper {
  padding: 1rem;
  border-radius: 0.5rem;
}

/* Custom color palette */
:root {
  --aissure-primary: #5f9d90;
  --aissure-primary-dark: #345750;
  --aissure-secondary: #858796;
  --aissure-success: #1cc88a;
  --aissure-success-dark: #169b6b;
  --aissure-info: #36b9cc;
  --aissure-info-dark: #2c9faf;
  --aissure-warning: #f6c23e;
  --aissure-warning-dark: #dda20a;
  --aissure-danger: #e74a3b;
  --aissure-danger-dark: #be2617;
  --aissure-light: #f8f9fc;
  --aissure-dark: #5a5c69;
  --aissure-gray-100: #f8f9fc;
  --aissure-gray-200: #eaecf4;
  --aissure-gray-300: #dddfeb;
  --aissure-gray-400: #d1d3e2;
  --aissure-gray-500: #b7b9cc;
  --aissure-gray-600: #858796;
  --aissure-gray-700: #6e707e;
  --aissure-gray-800: #5a5c69;
  --aissure-gray-900: #3a3b45;
}

/* Cards */
.card {
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
  border: 1px solid #e3e6f0;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}

.card-header {
  background-color: #f8f9fc;
  border-bottom: 1px solid #e3e6f0;
  padding: 1rem 1.25rem;
  font-weight: 600;
  border-top-left-radius: 0.5rem;
  border-top-right-radius: 0.5rem;
}

.card-body {
  padding: 1.5rem;
}

/* Buttons */
.btn {
  border-radius: 0.5rem;
  font-weight: 500;
  text-transform: none;
  font-size: 0.875rem;
  line-height: 1.5;
  border-width: 1px;
  padding: 0.5rem 1.25rem;
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-sm {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
}

.btn-primary {
  background-color: var(--aissure-primary);
  border-color: var(--aissure-primary);
  box-shadow: 0 2px 6px rgba(95, 157, 144, 0.25);
}

.btn-primary:hover {
  background-color: #4c8a7e;
  border-color: var(--aissure-primary-dark);
  box-shadow: 0 4px 12px rgba(95, 157, 144, 0.35);
  transform: translateY(-1px);
}

.btn-success {
  background-color: var(--aissure-success);
  border-color: var(--aissure-success);
  box-shadow: 0 2px 6px rgba(28, 200, 138, 0.25);
}

.btn-success:hover {
  background-color: #17a673;
  border-color: #169b6b;
  box-shadow: 0 4px 12px rgba(28, 200, 138, 0.35);
  transform: translateY(-1px);
}

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

.btn-outline-primary:hover {
  background-color: var(--aissure-primary);
  color: white;
  box-shadow: 0 4px 12px rgba(95, 157, 144, 0.25);
  transform: translateY(-1px);
}

/* Forms */
.form-control {
  border: 1px solid #d1d3e2;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  padding: 0.6rem 1rem;
  transition: all 0.2s;
}

.form-control:focus {
  border-color: #a3c9c0;
  box-shadow: 0 0 0 0.2rem rgba(95, 157, 144, 0.25);
  transform: translateY(-1px);
}

.form-select {
  border-radius: 0.5rem;
  border: 1px solid #d1d3e2;
  padding: 0.6rem 1rem;
  font-size: 0.875rem;
  background-position: right 1rem center;
}

.form-select:focus {
  border-color: #a3c9c0;
  box-shadow: 0 0 0 0.2rem rgba(95, 157, 144, 0.25);
}

.input-group-text {
  background-color: #eaecf4;
  border-color: #d1d3e2;
  color: var(--aissure-gray-600);
  border-radius: 0.5rem;
  padding: 0.6rem 1rem;
}

.form-label {
  font-weight: 500;
  color: var(--aissure-gray-700);
  margin-bottom: 0.5rem;
}

.form-section {
  background-color: white;
  border-radius: 0.5rem;
  padding: 1.75rem;
  margin-bottom: 1.75rem;
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.form-section-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--aissure-gray-800);
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e3e6f0;
}

/* Navigation */
.navbar-brand {
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: 0.5px;
}

.navbar-nav .nav-link {
  font-weight: 500;
  color: rgba(255, 255, 255, 0.85) !important;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
}

.navbar-nav .nav-link:hover {
  color: rgba(255, 255, 255, 1) !important;
  background-color: rgba(163, 201, 192, 0.3);
}

.navbar-dark.bg-gradient-primary {
  background: linear-gradient(135deg, #5f9d90 0%, #345750 100%);
}

.dropdown-menu {
  border: 0;
  box-shadow: 0 0.5rem 2rem 0 rgba(58, 59, 69, 0.2);
  border-radius: 0.5rem;
  padding: 0.75rem 0;
  margin-top: 0.5rem;
  min-width: 12rem;
}

.dropdown-item {
  padding: 0.6rem 1.5rem;
  font-weight: 400;
  transition: all 0.2s;
}

.dropdown-item:hover {
  background-color: rgba(163, 201, 192, 0.3);
}

.dropdown-item i {
  color: var(--aissure-primary);
}

/* Tables */
.table {
  color: var(--aissure-gray-800);
  border-radius: 0.5rem;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table th {
  border-top: none;
  border-bottom: 1px solid #e3e6f0;
  font-weight: 600;
  color: var(--aissure-gray-700);
  background-color: #f8f9fc;
  padding: 1rem;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
}

.table td {
  border-top: 1px solid #e3e6f0;
  padding: 1rem;
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background-color: rgba(95, 157, 144, 0.05);
}

.table-responsive {
  border-radius: 0.5rem;
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

/* Alerts */
.alert {
  border: 0;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 0.125rem 0.25rem rgba(58, 59, 69, 0.1);
  border-left: 4px solid transparent;
}

.alert-success {
  background-color: #d4edda;
  color: #0f5132;
  border-left-color: var(--aissure-success);
}

.alert-danger {
  background-color: #f8d7da;
  color: #721c24;
  border-left-color: var(--aissure-danger);
}

.alert-warning {
  background-color: #fff3cd;
  color: #664d03;
  border-left-color: var(--aissure-warning);
}

.alert-info {
  background-color: #d1ecf1;
  color: #055160;
  border-left-color: var(--aissure-info);
}

.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  max-width: 350px;
}

.notification-container .alert {
  margin-bottom: 0.75rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
  animation: slideInRight 0.3s ease-out forwards;
}

/* Badges */
.badge {
  font-weight: 600;
  font-size: 0.75rem;
  border-radius: 0.35rem;
  padding: 0.4em 0.8em;
  letter-spacing: 0.5px;
}

.badge.bg-success {
  background-color: var(--aissure-success) !important;
}

.badge.bg-primary {
  background-color: var(--aissure-primary) !important;
}

.badge.bg-warning {
  background-color: var(--aissure-warning) !important;
}

.badge.bg-danger {
  background-color: var(--aissure-danger) !important;
}

.badge.bg-info {
  background-color: var(--aissure-info) !important;
}

/* Progress bars */
.progress {
  height: 1rem;
  border-radius: 0.5rem;
  background-color: #eaecf4;
}

.progress-bar {
  border-radius: 0.5rem;
}

/* Custom utility classes */
.text-xs {
  font-size: 0.7rem;
}

.text-lg {
  font-size: 1.125rem;
}

.text-xl {
  font-size: 1.25rem;
}

.font-weight-bold {
  font-weight: 700 !important;
}

.text-gray-100 { color: var(--aissure-gray-100) !important; }
.text-gray-200 { color: var(--aissure-gray-200) !important; }
.text-gray-300 { color: var(--aissure-gray-300) !important; }
.text-gray-400 { color: var(--aissure-gray-400) !important; }
.text-gray-500 { color: var(--aissure-gray-500) !important; }
.text-gray-600 { color: var(--aissure-gray-600) !important; }
.text-gray-700 { color: var(--aissure-gray-700) !important; }
.text-gray-800 { color: var(--aissure-gray-800) !important; }
.text-gray-900 { color: var(--aissure-gray-900) !important; }

/* Border utilities */
.border-left-primary {
  border-left: 0.25rem solid var(--aissure-primary) !important;
  border-radius: 0.5rem;
}

.border-left-success {
  border-left: 0.25rem solid var(--aissure-success) !important;
  border-radius: 0.5rem;
}

.border-left-info {
  border-left: 0.25rem solid var(--aissure-info) !important;
  border-radius: 0.5rem;
}

.border-left-warning {
  border-left: 0.25rem solid var(--aissure-warning) !important;
  border-radius: 0.5rem;
}

.border-left-danger {
  border-left: 0.25rem solid var(--aissure-danger) !important;
  border-radius: 0.5rem;
}

/* Shadow utilities */
.shadow {
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
}

.shadow-sm {
  box-shadow: 0 0.125rem 0.25rem 0 rgba(58, 59, 69, 0.2) !important;
}

.shadow-lg {
  box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175) !important;
}

/* Chart containers */
.chart-area {
  position: relative;
  height: 300px;
  width: 100%!important;
  margin-bottom: 1rem;
}

.chart-pie {
  position: relative;
  height: 300px;
  width: 100%;
  margin-bottom: 1rem;
}

.chart-bar {
  position: relative;
  height: 300px;
  width: 100%;
  margin-bottom: 1rem;
}

/* KPI Cards */
.kpi-card {
  transition: all 0.3s;
  border-radius: 0.75rem;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 0.5rem 2.5rem 0 rgba(58, 59, 69, 0.25);
}

.kpi-value {
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--aissure-gray-800);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.kpi-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  color: var(--aissure-gray-600);
}

/* Loading states */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  border-radius: 0.5rem;
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .card-body {
    padding: 1rem;
  }

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

  .chart-area,
  .chart-pie,
  .chart-bar {
    height: 250px;
  }
}

/* Print styles */
@media print {
  .no-print {
    display: none !important;
  }

  .card {
    box-shadow: none;
    border: 1px solid #dee2e6;
  }

  .btn {
    display: none;
  }
}

/* Animation utilities */
.fade-in {
  animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.slide-in-right {
  animation: slideInRight 0.5s ease-out;
}

@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Footer */
footer {
  background-color: white;
  border-top: 1px solid #e3e6f0;
}

/* DataTables customization */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #d1d3e2;
  border-radius: 0.5rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: 0.5rem;
  margin: 0 2px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--aissure-primary) !important;
  border-color: var(--aissure-primary) !important;
  color: white !important;
}

/* Accessibility improvements */
.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 indicators */
.btn:focus,
.form-control:focus,
.form-select:focus {
  outline: 2px solid var(--aissure-primary);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border: 2px solid #000;
  }

  .btn {
    border: 2px solid;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .fade-in,
  .slide-in-right {
    animation: none;
  }

  .kpi-card {
    transition: none;
  }
}

/* Alert styles for dashboard */
.alert-sm {
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

/* AI Assistant Floating Action Button */
.ai-assistant-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--aissure-primary) 0%, var(--aissure-primary-dark) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(95, 157, 144, 0.4);
  text-decoration: none;
  transition: all 0.3s ease;
  z-index: 1000;
  cursor: pointer;
}

.ai-assistant-fab:hover {
  transform: translateY(-5px) scale(1.1);
  box-shadow: 0 8px 20px rgba(95, 157, 144, 0.5);
  color: white;
}

.ai-assistant-fab i {
  animation: pulse 2s ease-in-out infinite;
}

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

/* Responsive adjustments for FAB */
@media (max-width: 768px) {
  .ai-assistant-fab {
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    font-size: 1.25rem;
  }
}

/* ========== AI Assistant Modal Chat ========== */
#assistenteChatModal .modal-dialog {
    max-width: 90vw;
    margin: 2.5vh auto;
}

#assistenteChatModal .modal-content {
    height: 85vh;
    overflow: hidden;
}

#assistenteChatModal .modal-body {
    overflow: hidden;
}

.mchat-body {
    height: calc(85vh - 45px);
}

.mchat-container {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.mchat-sidebar {
    max-height: calc(85vh - 45px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mchat-messages {
    flex: 1;
    overflow-y: auto;
    background: #f8f9fa;
}

.mchat-input {
    flex-shrink: 0;
}

/* Message styles */
.mchat-message {
    display: flex;
    margin-bottom: 1rem;
    animation: mchatFadeIn 0.3s;
}

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

.mchat-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.mchat-assistant-message .mchat-message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin-right: 0.75rem;
}

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

.mchat-user-message .mchat-message-avatar {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    margin-left: 0.75rem;
}

.mchat-message-content {
    max-width: 75%;
}

.mchat-user-message .mchat-message-content {
    text-align: right;
}

.mchat-message-text {
    background: white;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-size: 0.9rem;
    line-height: 1.5;
}

.mchat-message-text p:last-child {
    margin-bottom: 0;
}

.mchat-user-message .mchat-message-text {
    background: #e3f2fd;
}

.mchat-message-time {
    font-size: 0.7rem;
    color: #6c757d;
    margin-top: 0.2rem;
}

/* Typing indicator */
.mchat-typing-indicator {
    display: none;
    padding: 0.75rem;
    background: white;
    border-radius: 1rem;
    width: fit-content;
}

.mchat-typing-indicator.active {
    display: block;
}

.mchat-typing-indicator span {
    height: 7px;
    width: 7px;
    background: #667eea;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: mchatTyping 1.4s infinite;
}

.mchat-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.mchat-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mchatTyping {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-8px); }
}

/* Multi-bilancio dropdown */
.mchat-bilancio-item {
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

.mchat-bilancio-item:hover {
    background-color: #e7f1ff;
}

/* Suggested questions */
.mchat-suggested-question {
    cursor: pointer;
    padding: 6px 12px !important;
}

.mchat-suggested-question:hover {
    background-color: #e7f1ff;
}

/* Cronologia items */
.mchat-cronologia-item {
    cursor: pointer;
    padding: 8px 12px !important;
}

.mchat-cronologia-item:hover {
    background-color: #e7f1ff;
}

/* Tables and charts inside modal */
#assistenteChatModal .table-responsive {
    font-size: 0.85rem;
}

#assistenteChatModal .chart-container {
    max-height: 350px;
}

/* Responsive: mobile fullscreen */
@media (max-width: 768px) {
    #assistenteChatModal .modal-dialog {
        max-width: 100vw;
        height: 100vh;
        margin: 0;
    }

    #assistenteChatModal .modal-content {
        height: 100vh;
        border-radius: 0;
    }

    .mchat-body {
        height: calc(100vh - 45px);
    }
}
