/* =============================================
   PROGETTO POSA BACKOFFICE - APP THEME
   ============================================= */

/* 1. ROOT VARIABLES & FOUNDATIONS */
:root {
    /* Primary Color Palette - Purple Brand */
    --pp-purple: #7B3F99;
    --pp-purple-dark: #5B2F79;
    --pp-purple-light: #9B5FB9;
    --pp-purple-accent: #8E4DA6;

    /* Secondary Colors */
    --pp-gray-dark: #2C2C2C;
    --pp-gray: #6C757D;
    --pp-gray-light: #F8F9FA;
    --pp-white: #FFFFFF;

    /* Functional Colors */
    --pp-success: #28A745;
    --pp-danger: #DC3545;
    --pp-warning: #FFC107;
    --pp-info: #17A2B8;

    /* Gradient Colors */
    --pp-gradient-start: #9B5FB9;
    --pp-gradient-end: #E8D4F2;
    --pp-pink-light: #F5E6FA;

    /* Bootstrap Variable Overrides */
    --bs-primary: var(--pp-purple);
    --bs-primary-rgb: 123, 63, 153;
    --bs-secondary: var(--pp-gray);
    --bs-success: var(--pp-success);
    --bs-danger: var(--pp-danger);
    --bs-warning: var(--pp-warning);
    --bs-info: var(--pp-info);
}

/* Typography - Consistent Font Family */
html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    color: var(--pp-gray-dark);
    background-color: #FAFAFA;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-weight: 600;
}

/* 2. GLOBAL LAYOUT */

/* Navbar */
.navbar {
    background: linear-gradient(135deg, var(--pp-purple) 0%, var(--pp-purple-dark) 100%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 1.25rem;
    color: var(--pp-gray-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.navbar-brand img {
    height: 35px;
    width: auto;
}

/* Sidebar - Improved without !important */
.sidebar {
    background: #F5F5F5;
    box-shadow: 2px 0 6px rgba(0,0,0,0.08);
    color: #333;
}

.sidebar .top-row {
    background-color: white;
    border-bottom: 3px solid var(--pp-purple);
    height: 3.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-bottom: 0;
}

.sidebar .nav-item {
    font-family: 'Roboto', sans-serif;
    font-size: 0.85rem;
    margin-bottom: 0.1rem;
    display: block;
    visibility: visible;
    opacity: 1;
}

.sidebar .nav-item a,
.sidebar .nav-link {
    color: #606060;
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    text-decoration: none;
    margin: 0 0.5rem;
}

.sidebar .nav-item a:hover,
.sidebar .nav-link:hover {
    background-color: rgba(123, 63, 153, 0.08);
    color: var(--pp-purple);
}

.sidebar .nav-item a.active,
.sidebar .nav-link.active {
    background-color: rgba(123, 63, 153, 0.15);
    color: var(--pp-purple);
    font-weight: 500;
}

.sidebar .nav-item .bi,
.sidebar .nav-item .fas,
.sidebar .nav-link i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
    color: var(--pp-purple);
    margin-right: 0.5rem;
    display: inline-block;
}

.sidebar hr.sidebar-divider {
    border-color: rgba(123, 63, 153, 0.2);
    margin: 0.5rem 1rem;
}

/* Force sidebar visibility */
.sidebar * {
    visibility: visible;
    opacity: 1;
}

/* Desktop sidebar responsive behavior */
@media (min-width: 641px) {
    .sidebar .collapse {
        display: block;
    }

    .sidebar .nav-scrollable {
        display: block;
        height: calc(100vh - 3.5rem);
        overflow-y: auto;
    }
}

/* Main content area */
.content {
    padding-top: 1.1rem;
}

/* 3. BOOTSTRAP COMPONENT OVERRIDES */

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--pp-purple) 0%, var(--pp-purple-dark) 100%);
    border: none;
    color: white;
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(123, 63, 153, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--pp-purple-light) 0%, var(--pp-purple) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(123, 63, 153, 0.4);
}

.btn-secondary {
    background-color: white;
    border: 2px solid var(--pp-purple);
    color: var(--pp-purple);
    font-weight: 500;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background-color: var(--pp-purple);
    color: white;
}

.btn:disabled,
.form-control:disabled {
    opacity: 0.65;
    background-color: #e9ecef;
    color: #6c757d;
}

/* Cards */
.card {
    border: none;
    border-radius: 15px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
    background: white;
}

.card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: translateY(-2px);
}

.card-header {
    background: linear-gradient(135deg, var(--pp-purple) 0%, var(--pp-purple-light) 100%);
    color: white;
    border-radius: 15px 15px 0 0;
    font-weight: 500;
    padding: 1rem 1.5rem;
    position: relative;
    overflow: hidden;
}

.card-header,
.card-header *,
.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6 {
    color: white;
    margin: 0;
}

.card-header span,
.card-header small,
.card-header .text-muted,
.card-header .product-code,
.card-header code {
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
}

.card-body {
    padding: 1rem;
}

.card-body .text-muted {
    color: #495057;
}

/* Tables */
.table {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.table thead {
    background: #f8f9fa;
    color: var(--pp-gray-dark);
    border-bottom: 2px solid var(--pp-purple);
}

.table thead th {
    border: none;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--pp-gray-dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table thead *,
thead.bg-purple *,
.bg-purple th {
    color: var(--pp-gray-dark);
}

.table tbody tr {
    transition: all 0.2s ease;
}

.table tbody tr:hover {
    background-color: var(--pp-pink-light);
}

.table td {
    padding: 0.5rem 0.75rem;
    vertical-align: middle;
    border-color: #E9ECEF;
    font-size: 0.9rem;
}

.table-sm td, .table-sm th {
    padding: 0.25rem 0.5rem;
}

/* Form Controls */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #D1D5DB;
    padding: 0.625rem 1rem;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: var(--pp-purple);
    box-shadow: 0 0 0 0.2rem rgba(123, 63, 153, 0.25);
}

.form-label,
label {
    color: var(--pp-gray-dark);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* Input validation */
.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid red;
}

.validation-message {
    color: red;
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
}

.alert-info {
    background-color: var(--pp-pink-light);
    color: var(--pp-purple);
    border-left: 4px solid var(--pp-purple);
}

/* Badges */
.badge {
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
    font-weight: 500;
}

.badge.bg-primary {
    background: linear-gradient(135deg, var(--pp-purple) 0%, var(--pp-purple-light) 100%);
}

.badge.bg-success {
    background-color: #28a745;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.badge.bg-info {
    background-color: #17a2b8;
    color: #ffffff;
}

/* Modal */
.modal-content {
    border-radius: 15px;
    border: none;
}

.modal-header {
    background: linear-gradient(135deg, var(--pp-purple) 0%, var(--pp-purple-light) 100%);
    color: white;
    border-radius: 15px 15px 0 0;
}

.modal-header * {
    color: white;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

/* Navigation Tabs */
.nav-tabs {
    margin-left: 1rem;
    padding-left: 0.5rem;
}

.nav-tabs .nav-item {
    margin-bottom: 0;
}

.nav-tabs .nav-link {
    color: var(--pp-gray);
    border-radius: 8px 8px 0 0;
    font-weight: 500;
    padding: 0.75rem 1.5rem;
    background: white;
    border: 1px solid #dee2e6;
    margin-right: 0.25rem;
}

.nav-tabs .nav-link.active {
    background: linear-gradient(135deg, var(--pp-purple) 0%, var(--pp-purple-light) 100%);
    color: white;
    border: 1px solid var(--pp-purple);
    font-weight: 600;
    text-shadow: none;
}

.nav-tabs .nav-link.active,
.nav-tabs .nav-link.active * {
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.nav-tabs .nav-link .badge {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-left: 0.5rem;
    font-weight: 500;
}

.nav-tabs .nav-link:not(.active) .badge {
    background-color: #6c757d;
    color: white;
    border: none;
}

/* Breadcrumb */
.breadcrumb {
    background-color: transparent;
    padding: 0;
    margin-bottom: 1.5rem;
}

.breadcrumb-item a {
    color: var(--pp-purple);
    text-decoration: none;
}

.breadcrumb-item.active {
    color: var(--pp-gray);
}

/* 4. UTILITIES & ACCESSIBILITY */

/* Focus states */
button:focus,
.btn:focus,
.form-control:focus,
.form-select:focus {
    box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.25);
    outline: none;
}

*:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Helper classes */
.row {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 0.75rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 0.75rem;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #F1F1F1;
}

::-webkit-scrollbar-thumb {
    background: var(--pp-purple);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--pp-purple-dark);
}

/* 5. SPECIFIC COMPONENTS */

/* Special Cards */
.points-card {
    background: linear-gradient(135deg, var(--pp-purple) 0%, var(--pp-purple-light) 100%);
    border-radius: 20px;
    padding: 1.5rem;
    color: white;
    box-shadow: 0 4px 12px rgba(123, 63, 153, 0.3);
    margin-bottom: 1.5rem;
}

.points-card * {
    color: white;
}

.points-card h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

.points-card .label {
    font-size: 0.9rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.info-card {
    background: var(--pp-pink-light);
    border-radius: 15px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--pp-purple);
}

.info-card h5 {
    color: var(--pp-purple);
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.info-card p {
    color: var(--pp-gray-dark);
    margin: 0;
}

/* Page headers */
.page-header {
    padding: 0 0 0.75rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #E9ECEF;
}

.page-header h1,
h1.page-title {
    color: var(--pp-purple);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 2rem;
    margin: 0;
    margin-bottom: 0.25rem;
}

.page-header p {
    color: var(--pp-gray);
    font-family: 'Quicksand', sans-serif;
    font-size: 0.95rem;
    margin: 0;
}

/* Footer */
footer {
    background: linear-gradient(135deg, var(--pp-purple-dark) 0%, var(--pp-purple) 100%);
    color: white;
    padding: 1.5rem 0;
    margin-top: 3rem;
}

/* Blazor Error UI */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Matrix Editor Styles - TODO: Extract to separate component file */
.matrix-container {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.matrix-view-toggle {
    display: inline-flex;
    background: #f8f9fa;
    border-radius: 6px;
    padding: 2px;
    gap: 2px;
}

.matrix-view-toggle .btn {
    border: none;
    background: transparent;
    color: #6c757d;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.matrix-view-toggle .btn.active {
    background: white;
    color: #0078d4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.matrix-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-size: 0.875rem;
}

.matrix-table th {
    background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    padding: 10px 8px;
    font-weight: 600;
    color: #495057;
    text-align: center;
    position: sticky;
    z-index: 10;
}

.matrix-table th.corner-header {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    left: 0;
    top: 0;
    z-index: 12;
}

.matrix-table th.width-header {
    top: 0;
    min-width: 80px;
}

.matrix-table th.height-header {
    left: 0;
    min-width: 100px;
}

.matrix-cell {
    position: relative;
    border: 1px solid #e9ecef;
    padding: 0;
    background: white;
    transition: all 0.2s ease;
    min-width: 80px;
    height: 40px;
}

.matrix-cell:hover {
    background-color: #f0f8ff;
    border-color: #b3d9ff;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 120, 212, 0.1);
}

.matrix-cell.selected {
    background-color: #e3f2fd;
    border-color: #2196f3;
    box-shadow: inset 0 0 0 1px #2196f3;
}

.matrix-cell.modified {
    background-color: #fff8e1;
    border-color: #ffc107;
}

.cell-value {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #212529;
}

.cell-value.empty {
    color: #adb5bd;
    font-style: italic;
    font-size: 0.75rem;
}

.cell-editor {
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    background: white;
    border: 2px solid #0078d4;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    padding: 8px;
    min-width: 120px;
    animation: slideIn 0.2s ease;
}

.cell-editor-input {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 0.875rem;
    margin-bottom: 6px;
}

.cell-editor-input:focus {
    outline: none;
    border-color: #0078d4;
    box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.1);
}

.cell-editor-buttons {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

.cell-editor-buttons .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
    border-radius: 3px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        background: #F5F5F5;
    }

    .points-card h2 {
        font-size: 2rem;
    }

    .btn-primary, .btn-secondary {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    .bg-purple,
    .product-header,
    .card-header.bg-gradient {
        background: #000000;
        border: 2px solid #ffffff;
    }

    *:focus {
        outline: 3px solid #ffff00;
    }
}

/* Global Purple Background Text Fix */
.bg-purple,
.bg-purple *,
.bg-gradient,
.bg-gradient *,
[style*="background: linear-gradient"] *,
[style*="background-color: #7B3F99"] *,
[style*="background-color: #8e44ad"] *,
[style*="background-color: #9b59b6"] * {
    color: white;
}

.product-header,
.product-header *,
.product-card,
.product-card * {
    color: white;
}

.bg-purple .text-muted,
.bg-gradient .text-muted,
.card-header .text-muted,
.product-header .text-muted {
    color: rgba(255, 255, 255, 0.85);
}

.product-code,
.bg-purple .product-code,
.bg-gradient .product-code,
.card-header .product-code {
    color: rgba(255, 255, 255, 0.9);
    opacity: 1;
}

.bg-purple .badge,
.bg-gradient .badge,
.card-header .badge {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.bg-purple a,
.bg-gradient a,
.card-header a {
    color: white;
    text-decoration: underline;
}

.bg-purple a:hover,
.bg-gradient a:hover,
.card-header a:hover {
    color: rgba(255, 255, 255, 0.8);
}

/* 6. TIMELINE COMPONENT STYLES */

/* Timeline Container */
.timeline-container {
    margin: 1rem 0;
}

/* Syncfusion Timeline Customizations */
.e-timeline .e-timeline-item .e-timeline-content {
    padding: 0.75rem 0;
}

/* Timeline Content */
.timeline-content {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid var(--pp-purple-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.timeline-content:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    border-left-color: var(--pp-purple);
}

/* Timeline Icon Styling */
.timeline-icon {
    min-width: 32px;
    min-height: 32px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.timeline-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Status Text */
.timeline-content h6 {
    font-weight: 600;
    color: var(--pp-gray-dark);
    margin-bottom: 0.25rem;
}

/* User and Notes Text */
.timeline-content small {
    line-height: 1.4;
}

/* Transition Type Badges */
.timeline-content .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* Timeline Responsive */
@media (max-width: 768px) {
    .timeline-content {
        margin-left: 0.5rem;
        padding: 0.75rem;
    }

    .timeline-icon {
        width: 28px !important;
        height: 28px !important;
    }

    .timeline-icon i {
        font-size: 12px !important;
    }
}

/* Syncfusion Timeline Override for Better Visual */
.e-timeline .e-timeline-item:before {
    background-color: var(--pp-purple-light) !important;
    border-color: var(--pp-purple) !important;
}

.e-timeline .e-timeline-item.e-timeline-item-active:before {
    background-color: var(--pp-purple) !important;
}

.e-timeline .e-timeline-line {
    border-left-color: var(--pp-purple-light) !important;
}

/* 7. DARK THEME SUPPORT */

/* Force light background and dark text for select dropdowns in dark theme */
@media (prefers-color-scheme: dark) {
    select.form-select,
    select.form-select option {
        background-color: #ffffff !important;
        color: #212529 !important;
    }

    select.form-select:focus {
        background-color: #ffffff !important;
        color: #212529 !important;
    }
}