/*
 * EasyRefert - Global Styles
 * Modern, Responsive Design
 * Palette: #1d4f5e (Primary), #242424 (Dark), #ffffff (Light)
 */

:root {
    /* Palette principale */
    --primary-color: #1d4f5e;
    --primary-dark: #153d4a;
    --primary-light: #2a6273;
    --dark-color: #242424;
    --dark-light: #333333;
    --light-color: #ffffff;
    --gray-100: #f8f9fa;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;

    /* Colori funzionali */
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;

    /* Shadows & Borders */
    --shadow-sm: 0 2px 4px rgba(29, 79, 94, 0.1);
    --shadow-md: 0 4px 12px rgba(29, 79, 94, 0.15);
    --shadow-lg: 0 8px 24px rgba(29, 79, 94, 0.2);
    --shadow-xl: 0 12px 40px rgba(29, 79, 94, 0.25);

    --border-radius-sm: 6px;
    --border-radius-md: 10px;
    --border-radius-lg: 15px;
    --border-radius-xl: 20px;

    /* Transitions */
    --transition-fast: 0.15s ease-in-out;
    --transition-base: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-xxl: 3rem;
}

/* ========================================
   RESET & BASE STYLES
======================================== */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
    margin-bottom: var(--spacing-md);
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1rem; }

p {
    margin-bottom: var(--spacing-md);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: all var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: none;
}

/* ========================================
   BUTTONS
======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    height: 38px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
    white-space: nowrap;
    user-select: none;
    box-shadow: var(--shadow-sm);
}

.btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: var(--shadow-md);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Button Primary */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--light-color);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #0f2f38 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Button Dark */
.btn-dark {
    background: var(--dark-color);
    color: var(--light-color);
}

.btn-dark:hover {
    background: var(--dark-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Button Light/Secondary */
.btn-light, .btn-secondary {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-light:hover, .btn-secondary:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-light:active, .btn-secondary:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Button Success */
.btn-success {
    background: var(--success-color);
    color: var(--light-color);
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Button Danger */
.btn-danger {
    background: var(--danger-color);
    color: var(--light-color);
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Button Warning */
.btn-warning {
    background: var(--warning-color);
    color: var(--dark-color);
}

.btn-warning:hover {
    background: #e0a800;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Button Sizes */
.btn-sm {
    padding: 0.375rem 0.75rem;
    height: 32px;
    font-size: 0.8125rem;
}

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

/* Button Icon */
.btn i {
    font-size: 1.1em;
}

/* ========================================
   CARDS
======================================== */

.card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-fast);
    overflow: hidden;
    margin-bottom: var(--spacing-lg);
}

.card-header {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--light-color);
    border-bottom: none;
    font-weight: 600;
    font-size: 1.125rem;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* Card Variants */
.card.card-dark .card-header {
    background: var(--dark-color);
}

.card.card-success .card-header {
    background: var(--success-color);
}

.card.card-warning .card-header {
    background: var(--warning-color);
    color: var(--dark-color);
}

.card.card-danger .card-header {
    background: var(--danger-color);
}

/* ========================================
   MODALS
======================================== */

.modal-content {
    border: none;
    border-radius: var(--border-radius-xl);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--light-color);
    border-bottom: none;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
    transition: all var(--transition-fast);
}

.modal-header .btn-close:hover {
    opacity: 1;
    transform: rotate(90deg);
}

.modal-title {
    font-weight: 600;
    font-size: 1.375rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-title i {
    font-size: 1.5rem;
}

.modal-body {
    padding: 2rem;
}

.modal-footer {
    padding: 1.25rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

/* Modal Backdrop */
.modal-backdrop {
    background-color: rgba(29, 79, 94, 0.6);
    backdrop-filter: blur(4px);
}

/* Modal Animation */
.modal.fade .modal-dialog {
    transform: scale(0.8) translateY(-50px);
    opacity: 0;
    transition: all var(--transition-base);
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ========================================
   FORMS
======================================== */

.form-control, .form-select {
    padding: 0.625rem 0.875rem;
    height: 38px;
    font-size: 0.9rem;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    transition: all var(--transition-fast);
    background: var(--input-bg);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(29, 79, 94, 0.1);
    outline: none;
    background: var(--input-bg);
}

.form-control:hover, .form-select:hover {
    border-color: var(--primary-light);
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.form-floating > label {
    color: var(--text-muted);
}

.form-control:focus ~ .form-floating > label,
.form-floating > .form-control:focus ~ label {
    color: var(--primary-color);
}

/* Form Group */
.form-group {
    margin-bottom: var(--spacing-lg);
}

/* Input Groups */
.input-group-text {
    background: var(--bg-secondary);
    border: 2px solid var(--input-border);
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========================================
   NAVBAR
======================================== */

.navbar {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%) !important;
    padding: 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 56px;
    position: fixed;
    width: 100%;
    z-index: 99;
}
.main-content {
    padding-top: 3rem !Important;
}

.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
    color: var(--light-color) !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
    padding: 0.25rem 0;
}

.navbar-brand:hover {
    opacity: 0.9;
}

.navbar-brand i {
    font-size: 1.5rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.9) !important;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.4rem 0.875rem !important;
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
    color: var(--light-color) !important;
}

.nav-link:active {
    background: rgba(255, 255, 255, 0.2);
}

.dropdown-menu {
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.5rem;
    margin-top: 0.5rem;
}

.dropdown-item {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all var(--transition-fast);
    font-weight: 500;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.dropdown-item:active {
    background: var(--bg-tertiary);
}

.dropdown-divider {
    margin: 0.5rem 0;
    border-color: var(--border-color);
}

/* ========================================
   TABLES
======================================== */

.table {
    background: var(--card-bg);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.table thead th {
    background: var(--primary-color);
    color: var(--light-color);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8125rem;
    letter-spacing: 0.5px;
    padding: 1rem;
    border: none;
}

.table tbody tr {
    transition: all var(--transition-fast);
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--bg-secondary);
    transform: scale(1.01);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
}

.table tbody tr:last-child {
    border-bottom: none;
}

/* ========================================
   BADGES
======================================== */

.badge {
    padding: 0.375rem 0.75rem;
    font-weight: 500;
    font-size: 0.75rem;
    border-radius: var(--border-radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

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

/* ========================================
   ALERTS
======================================== */

.alert {
    border: none;
    border-radius: var(--border-radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert i {
    font-size: 1.25rem;
}

.alert-dismissible .btn-close {
    padding: 1rem;
}

/* ========================================
   UTILITIES
======================================== */

/* Shadows */
.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* Rounded corners */
.rounded { border-radius: var(--border-radius-md) !important; }
.rounded-lg { border-radius: var(--border-radius-lg) !important; }
.rounded-xl { border-radius: var(--border-radius-xl) !important; }

/* Background colors */
.bg-primary { background: var(--primary-color) !important; }
.bg-dark { background: var(--dark-color) !important; }

/* Text colors */
.text-primary { color: var(--primary-color) !important; }
.text-dark { color: var(--dark-color) !important; }

/* Hover effects */
.hover-lift {
    transition: all var(--transition-base);
}

.hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

/* Loading spinner */
.spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2em;
}

/* ========================================
   ANIMATIONS
======================================== */

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

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

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

.animate-fade-in {
    animation: fadeIn var(--transition-base);
}

.animate-slide-in {
    animation: slideInRight var(--transition-base);
}

/* ========================================
   RESPONSIVE
======================================== */

@media (max-width: 768px) {
    :root {
        font-size: 14px;
    }

    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }

    .card-body {
        padding: 1rem;
    }

    .modal-body {
        padding: 1.25rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    .card {
        border-radius: var(--border-radius-md);
    }

    .modal-content {
        border-radius: var(--border-radius-lg);
    }
}

/* ========================================
   ACCESSIBILITY
======================================== */

.visually-hidden-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
}

*:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ========================================
   FLOATING MESSAGES BUTTON - GLOBAL
======================================== */

.btn-floating-messages {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    z-index: 1000;
    transition: all var(--transition-fast);
    text-decoration: none;
    cursor: pointer;
}

.btn-floating-messages:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
    box-shadow: var(--shadow-xl);
    color: white;
}

.btn-floating-messages:active {
    transform: scale(0.95);
}

.btn-floating-messages .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    font-size: 0.625rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    padding: 0 0.375rem;
}

/* Hide on messaging page */
body.messaging-page .btn-floating-messages {
    display: none;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .btn-floating-messages {
        bottom: 5rem; /* Sopra la navbar mobile */
        right: 1rem;
        width: 52px;
        height: 52px;
        font-size: 1.375rem;
    }
}

@media (max-width: 576px) {
    .btn-floating-messages {
        width: 48px;
        height: 48px;
        font-size: 1.25rem;
        bottom: 4.5rem;
    }

    .btn-floating-messages .badge {
        min-width: 18px;
        height: 18px;
        font-size: 0.5625rem;
    }
}
