/* Main Styles for Perspect Dashboard */

* {
    font-family: 'Roboto Mono', monospace;
}

/* Tooltip Styles */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.tooltip-content {
    visibility: hidden;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #18181b;
    color: white;
    padding: 10px 14px;
    border-radius: 0;
    font-size: 11px;
    width: 220px;
    text-align: left;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
    transition: all 0.2s ease;
}

.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #18181b transparent transparent transparent;
}

.tooltip-container:hover .tooltip-content {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* REGOLA FERREA: NO Border Radius su NULLA */
.rounded,
.rounded-sm,
.rounded-md,
.rounded-lg,
.rounded-xl,
.rounded-2xl,
.rounded-3xl,
.rounded-full,
button,
.badge,
.btn,
span[class*="bg-"],
span[class*="px-"] {
    border-radius: 0 !important;
}

body {
    background: #e2e8f0;
    font-family: 'Roboto Mono', monospace;
}

/* Micro-animations */
@keyframes fadeSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes countUp {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Widget cards: visibili by default (no forced fade-in) */
.widget-card {
    opacity: 1;
    transform: none;
}

/* Metric values animation - triggered by JS */
.widget-metric-large,
.widget-metric-medium {
    opacity: 0;
    transform: scale(0.95);
}

.widget-metric-large.animate-in,
.widget-metric-medium.animate-in {
    animation: countUp 0.5s ease-out forwards;
    animation-delay: 0.3s;
}

/* AI Insight box animation */
.ai-insight-box {
    opacity: 0;
    transform: translateY(8px);
}

.ai-insight-box.animate-in {
    animation: fadeSlideIn 0.4s ease-out forwards;
    animation-delay: 0.2s;
}

/* Subtle hover lift for interactive elements */
.widget-card.animate-in {
    transform: translateY(0);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.widget-card.animate-in:hover {
    transform: translateY(-2px);
}

/* Badge pulse on hover */
.badge-ai {
    transition: all 0.2s ease;
}

.badge-ai:hover {
    transform: scale(1.05);
}

/* Table row slide highlight */
tbody tr {
    transition: all 0.15s ease;
}

tbody tr:hover {
    transform: translateX(4px);
}

/* Nav item indicator animation */
.nav-item {
    position: relative;
    overflow: hidden;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 2px;
    background: #8b5cf6;
    transform: scaleY(0);
    transition: transform 0.2s ease;
}

.nav-item:hover::before,
.nav-item.active::before {
    transform: scaleY(1);
}

/* Progress bar animation for debt bars */
.debt-bar-short,
.debt-bar-long-2023,
.debt-bar-short-2024,
.debt-bar-long-2024,
.debt-bar-short-2025,
.debt-bar-long-2025 {
    animation: fadeSlideIn 0.6s ease-out backwards;
}

/* Tooltip fade */
.tooltip-content {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
    transition: all 0.2s ease;
}

.tooltip-container:hover .tooltip-content {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Button/link subtle feedback */
.action-btn,
button {
    transition: all 0.15s ease;
}

.action-btn:active,
button:active {
    transform: scale(0.97);
}

/* Tooltip Styles */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.tooltip-content {
    visibility: hidden;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #18181b;
    color: white;
    padding: 10px 14px;
    border-radius: 0;
    font-size: 11px;
    width: 220px;
    text-align: left;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #18181b transparent transparent transparent;
}

.tooltip-container:hover .tooltip-content {
    visibility: visible;
}

/* Widget Styling - Corporate */
.widget-card {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.06) 0%, rgba(255, 255, 255, 0) 100%);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 0;
    transition: all 200ms ease;
    box-shadow: none;
}

.widget-card:hover {
    border-color: #8b5cf6;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.15);
}

/* Widget Gradient Backgrounds - Corporate */
.widget-positive {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
    border-color: rgba(5, 150, 105, 0.35);
}

.widget-positive:hover {
    border-color: #059669;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
}

.widget-negative {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
    border-color: rgba(220, 38, 38, 0.35);
}

.widget-negative:hover {
    border-color: #dc2626;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
}

.widget-purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.06) 0%, rgba(255, 255, 255, 0) 100%);
    border-color: rgba(139, 92, 246, 0.25);
}

.widget-purple:hover {
    border-color: #8b5cf6;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.22);
}

/* Sub-widget styles for Executive Summary */
.subwidget-neutral {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.06) 0%, rgba(255, 255, 255, 0) 100%);
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 0;
}

.subwidget-negative {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
    border: 1px solid rgba(220, 38, 38, 0.35);
    border-radius: 0;
}

/* AI Insight Widget - Corporate */
.widget-ai-insight {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.08) 0%, rgba(255, 255, 255, 0) 100%);
    border: 1px dashed rgba(139, 92, 246, 0.4);
}

.widget-ai-insight:hover {
    border-color: #7c3aed;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

/* AI Badge */
.badge-ai {
    background: #8b5cf6;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* AI Insight arrows */
.ai-insight-arrow::before {
    color: #8b5cf6;
}

/* Risk badges */
.risk-badge {
    background: #8b5cf6;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Table Styling */
th[data-sort] {
    cursor: pointer;
    user-select: none;
}

th[data-sort]:hover {
    background: rgba(139, 92, 246, 0.08);
}

th[data-sort]::after {
    content: ' ↕';
    opacity: 0.4;
    font-size: 11px;
    margin-left: 4px;
}

th[aria-sort="ascending"]::after {
    content: ' ↑';
    opacity: 1;
}

th[aria-sort="descending"]::after {
    content: ' ↓';
    opacity: 1;
}

tbody tr:hover {
    background: rgba(139, 92, 246, 0.06);
}

/* Archivio Documenti: hover e azioni */
#documentsTable tbody tr:hover {
    background: rgba(139, 92, 246, 0.08);
}

#documentsTable thead th:hover {
    background: rgba(139, 92, 246, 0.08);
}

#documentsTable .action-btn {
    color: #9ca3af;
    transition: color 150ms ease;
}

#documentsTable .action-btn:hover {
    color: #8b5cf6;
}

/* Common Widget Typography */
.widget-title {
    font-weight: 500;
    color: #09090b;
    font-size: 13px;
    margin-bottom: 12px;
}

.widget-text {
    font-size: 12px;
    line-height: 1.6;
    color: #27272a;
    font-weight: 400;
}

.widget-metric-large {
    font-size: 22px;
    font-weight: 600;
    color: #18181b;
}

.widget-metric-medium {
    font-size: 16px;
    font-weight: 600;
    color: #18181b;
}

.widget-metric-small {
    font-size: 13px;
    font-weight: 500;
    color: #18181b;
}

/* Responsive metric sizes */
@media (min-width: 640px) {
    .widget-metric-large {
        font-size: 28px;
    }
    .widget-metric-medium {
        font-size: 18px;
    }
    .widget-metric-small {
        font-size: 14px;
    }
}

.widget-label {
    font-size: 10px;
    color: #27272a;
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.08em;
}

.widget-label-medium {
    font-size: 11px;
    color: #27272a;
    font-weight: 500;
}

.widget-status-badge {
    font-size: 10px;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 0 !important;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.widget-change-positive {
    color: #22c55e;
    font-weight: 500;
    font-size: 10px;
}

.widget-change-negative {
    color: #ef4444;
    font-weight: 500;
    font-size: 10px;
}

.widget-change-neutral {
    color: #71717a;
    font-weight: 500;
    font-size: 10px;
}

/* Detail Widgets */
.widget-detail-label {
    font-size: 12px;
    color: #27272a;
    font-weight: 400;
}

.widget-detail-value {
    font-size: 12px;
    color: #09090b;
    font-weight: 500;
}

.widget-detail-header {
    font-size: 11px;
    font-weight: 500;
    color: #27272a;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 16px;
}

.widget-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #d1d5db;
}

.widget-detail-row:last-child {
    border-bottom: none;
}

.widget-detail-note {
    font-size: 11px;
    color: #3f3f46;
    line-height: 1.6;
    margin-top: 16px;
    padding: 12px 16px;
    background: rgba(139, 92, 246, 0.10);
    border: 1px dashed rgba(139, 92, 246, 0.5);
    border-radius: 0;
    transition: all 200ms ease;
}

.widget-detail-note:hover {
    border-color: #7c3aed;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

/* AI Insight inline widgets */
.ai-insight-box {
    margin-top: 16px;
    padding: 16px;
    background: rgba(139, 92, 246, 0.12);
    border: 1px dashed rgba(139, 92, 246, 0.5);
    font-size: 12px;
    color: #09090b;
    transition: all 200ms ease;
}

.ai-insight-box:hover {
    border-color: #7c3aed;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

/* Mobile responsive adjustments */
@media (max-width: 639px) {
    .ai-insight-box {
        padding: 12px;
        font-size: 11px;
    }

    .widget-title {
        font-size: 12px;
    }

    .widget-text {
        font-size: 11px;
    }

    .tooltip-content {
        width: 180px;
        font-size: 10px;
        padding: 8px 10px;
    }

    .widget-detail-row {
        padding: 8px 0;
    }

    .widget-detail-label,
    .widget-detail-value {
        font-size: 11px;
    }

    /* Better touch targets */
    .nav-item {
        padding: 10px 0;
    }

    tbody tr {
        min-height: 44px;
    }
}

/* Debt Bar Widths - Data-driven from JSON */
.debt-bar-short {
    width: 53%;
}

.debt-bar-long-2023 {
    width: 47%;
}

.debt-bar-short-2024 {
    width: 68%;
}

.debt-bar-long-2024 {
    width: 32%;
}

.debt-bar-short-2025 {
    width: 54%;
}

.debt-bar-long-2025 {
    width: 46%;
}

/* Dynamic width class for debt bars from JSON */
.debt-bar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 10px;
    font-weight: 500;
}

.debt-bar.short {
    background: #8b5cf6;
}

.debt-bar.long {
    background: #71717a;
}

/* Dark Mode Theme */
.dark-mode {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
}

.dark-mode body,
.dark-mode {
    background: var(--bg-primary) !important;
}

.dark-mode .bg-white,
.dark-mode .bg-gray-50 {
    background: var(--bg-secondary) !important;
}

.dark-mode .widget-card {
    background: var(--bg-card) !important;
    border-color: var(--border-color) !important;
}

.dark-mode .widget-purple {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(30, 41, 59, 0) 100%) !important;
    border-color: rgba(139, 92, 246, 0.4) !important;
}

.dark-mode .widget-positive {
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.15) 0%, rgba(30, 41, 59, 0) 100%) !important;
    border-color: rgba(5, 150, 105, 0.4) !important;
}

.dark-mode .widget-negative {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15) 0%, rgba(30, 41, 59, 0) 100%) !important;
    border-color: rgba(220, 38, 38, 0.4) !important;
}

.dark-mode .subwidget-neutral {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(30, 41, 59, 0) 100%) !important;
    border-color: rgba(139, 92, 246, 0.4) !important;
}

.dark-mode .subwidget-negative {
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15) 0%, rgba(30, 41, 59, 0) 100%) !important;
    border-color: rgba(220, 38, 38, 0.4) !important;
}

.dark-mode .widget-ai-insight {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.15) 0%, rgba(30, 41, 59, 0) 100%) !important;
    border-color: rgba(139, 92, 246, 0.5) !important;
}

.dark-mode .ai-insight-box {
    background: rgba(139, 92, 246, 0.2) !important;
    border-color: rgba(139, 92, 246, 0.5) !important;
}

.dark-mode .text-primary,
.dark-mode .text-gray-800,
.dark-mode .text-gray-700,
.dark-mode .widget-title,
.dark-mode .widget-metric-large,
.dark-mode .widget-metric-medium,
.dark-mode .widget-metric-small,
.dark-mode .widget-detail-value,
.dark-mode .widget-detail-header,
.dark-mode td,
.dark-mode th,
.dark-mode p,
.dark-mode span,
.dark-mode div {
    color: var(--text-primary);
}

.dark-mode .text-gray-600,
.dark-mode .text-gray-500,
.dark-mode .text-gray-400,
.dark-mode .widget-text,
.dark-mode .widget-label,
.dark-mode .widget-label-medium,
.dark-mode .widget-detail-label {
    color: var(--text-secondary) !important;
}

/* Preserve colored text in dark mode */
.dark-mode .text-purple,
.dark-mode .text-positive,
.dark-mode .text-negative,
.dark-mode .text-danger,
.dark-mode .text-success {
    color: inherit;
}

.dark-mode .border-gray-200,
.dark-mode .border-gray-100 {
    border-color: var(--border-color) !important;
}

.dark-mode table thead {
    background: var(--bg-primary) !important;
}

.dark-mode table tbody tr:hover {
    background: rgba(139, 92, 246, 0.1) !important;
}

.dark-mode .tooltip-content {
    background: #0f172a !important;
}

.dark-mode .tooltip-content::after {
    border-color: #0f172a transparent transparent transparent !important;
}

.dark-mode #sidebar {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

.dark-mode .nav-item {
    color: var(--text-secondary) !important;
}

.dark-mode .nav-item:hover,
.dark-mode .nav-item.active {
    color: #a78bfa !important;
}

.dark-mode h1,
.dark-mode h2 {
    color: var(--text-primary) !important;
}

.dark-mode .border-b {
    border-color: var(--border-color) !important;
}

.dark-mode input,
.dark-mode select {
    background: var(--bg-primary) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

/* Header in dark mode */
.dark-mode .h-\[60px\] {
    background: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

/* Fix specific text colors */
.dark-mode .text-\[11px\],
.dark-mode .text-\[10px\],
.dark-mode .text-\[12px\],
.dark-mode .text-\[13px\],
.dark-mode .text-xs,
.dark-mode .text-sm {
    color: var(--text-secondary);
}

.dark-mode strong {
    color: var(--text-primary) !important;
}

.dark-mode .font-semibold,
.dark-mode .font-medium,
.dark-mode .font-bold {
    color: var(--text-primary);
}

/* Table specific */
.dark-mode table {
    color: var(--text-primary);
}

.dark-mode thead th {
    color: var(--text-secondary) !important;
}

.dark-mode tbody td {
    color: var(--text-primary);
}

/* Badges and status */
.dark-mode .bg-gray-50 {
    background: var(--bg-primary) !important;
}

.dark-mode .bg-gray-100 {
    background: rgba(51, 65, 85, 0.5) !important;
}

/* Executive summary boxes */
.dark-mode .p-4.bg-gray-50 {
    background: var(--bg-primary) !important;
    border-color: var(--border-color) !important;
}

/* Ensure accent colors work */
.dark-mode .text-purple {
    color: #a78bfa !important;
}

.dark-mode .bg-purple {
    background: #8b5cf6 !important;
}

/* Canvas pattern adjustment for dark mode */
.dark-mode canvas {
    filter: saturate(1.1);
}

/* Dashed borders in dark mode */
.dark-mode .border-dashed {
    border-color: rgba(148, 163, 184, 0.3) !important;
}

.dark-mode .border-gray-300 {
    border-color: rgba(148, 163, 184, 0.4) !important;
}

/* Status badges */
.dark-mode .widget-status-badge {
    color: inherit;
}

.dark-mode .bg-positive\/10 {
    background: rgba(34, 197, 94, 0.2) !important;
}

.dark-mode .bg-negative\/10 {
    background: rgba(239, 68, 68, 0.2) !important;
}

/* Button Reset Styles */
.btn-reset {
    outline: none;
    -webkit-tap-highlight-color: transparent;
    border-radius: 0;
    border: none;
}

/* View Navigation */
.view {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.view.hidden {
    display: none !important;
}

/* Disabled Items */
.item-disabled {
    color: #cbd5e1;
    opacity: 0.6;
    cursor: not-allowed;
}

.item-disabled i {
    color: #cbd5e1;
}

/* Fix scrollbar orizzontale tabelle */
.overflow-x-auto {
    overflow-x: auto;
    overflow-y: visible;
}

/* Nasconde scrollbar se non necessaria */
@media (min-width: 768px) {
    .overflow-x-auto {
        overflow-x: visible;
    }
}

/* Su mobile mostra scrollbar solo se necessaria */
@media (max-width: 767px) {
    .overflow-x-auto::-webkit-scrollbar {
        height: 6px;
    }
    .overflow-x-auto::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    .overflow-x-auto::-webkit-scrollbar-thumb {
        background: #888;
        border-radius: 3px;
    }
    .overflow-x-auto::-webkit-scrollbar-thumb:hover {
        background: #555;
    }
}
