/* ====================================
   Al Cespuglio - Gestionale Fiorista
   Custom Styles
   ==================================== */

/* === Font Family === */
body {
    font-family: 'Poppins', sans-serif;
    background-color: #F9FAFB;
    color: #374151;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* === Colori Primary === */
:root {
    --primary: #3b7b42;
    --primary-dark: #2e6034;
    --primary-light: #e8f5e9;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-700: #374151;
    --gray-800: #1F2937;
}

/* === Override Bootstrap Primary === */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

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

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

.border-primary {
    border-color: var(--primary) !important;
}

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

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

/* === Animazioni === */
@keyframes fadeInUp {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

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

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

.animate-fade-in-up {
    animation: fadeInUp 0.5s cubic-bezier(0.390, 0.575, 0.565, 1.000) both;
}

.animate-fade-in {
    animation: fadeIn 0.4s ease-in-out forwards;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* === Custom Scrollbar === */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* === Sidebar === */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 256px;
    background-color: white;
    border-right: 1px solid var(--gray-200);
    overflow-y: auto;
    z-index: 1000;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.sidebar-logo {
    height: 40px;
    object-fit: contain;
}

.sidebar-nav {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.625rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--gray-500);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    position: relative;
}

.nav-link i {
    width: 2rem;
    text-align: center;
    font-size: 1rem;
}

.nav-link:hover {
    background-color: var(--gray-100);
    color: var(--gray-800);
}

.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
}

.nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 4px;
    background-color: var(--primary);
    border-radius: 0 4px 4px 0;
}

.nav-submenu {
    padding-left: 2.75rem;
    list-style: none;
}

.nav-submenu .nav-item {
    list-style: none;
}

.nav-submenu .nav-link {
    padding-left: 0.5rem;
}

/* === Main Content === */
.main-content {
    margin-left: 256px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(16px);
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-200);
}

.main-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.header-actions button {
    background: none;
    border: none;
    color: var(--gray-500);
    font-size: 1.25rem;
    cursor: pointer;
    transition: color 0.2s;
}

.header-actions button:hover {
    color: var(--gray-800);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.875rem;
}

.main-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* === Cards === */
.stat-card {
    background: white;
    padding: 0.875rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
    min-height: 80px;
    gap: 0.75rem;
}

.stat-card:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
    cursor: pointer;
}

.stat-card-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.stat-card-content h6 {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-content .stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--gray-800);
    margin-bottom: 0.125rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-content .stat-subtitle {
    font-size: 0.7rem;
    color: var(--gray-400);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card-icon {
    padding: 0.625rem;
    border-radius: 0.375rem;
    flex-shrink: 0;
}

.stat-card-icon i {
    font-size: 1rem;
}

/* Responsive per schermi medi */
@media (max-width: 991px) {
    .stat-card {
        padding: 0.75rem 0.875rem;
        gap: 0.5rem;
    }
    
    .stat-card-content h6 {
        font-size: 0.7rem;
        letter-spacing: 0.3px;
    }
    
    .stat-card-content .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-card-content .stat-subtitle {
        font-size: 0.65rem;
    }
    
    .stat-card-icon {
        padding: 0.5rem;
    }
    
    .stat-card-icon i {
        font-size: 0.875rem;
    }
}

/* Responsive per schermi piccoli (tablet/mobile) */
@media (max-width: 767px) {
    .stat-card {
        padding: 0.75rem;
        min-height: 70px;
    }
    
    .stat-card-content h6 {
        font-size: 0.65rem;
        margin-bottom: 0.2rem;
    }
    
    .stat-card-content .stat-value {
        font-size: 1.125rem;
    }
    
    .stat-card-content .stat-subtitle {
        font-size: 0.6rem;
    }
}

/* Responsive per schermi molto piccoli */
@media (max-width: 575px) {
    .stat-card {
        padding: 0.625rem 0.75rem;
        min-height: 65px;
    }
    
    .stat-card-content h6 {
        font-size: 0.625rem;
    }
    
    .stat-card-content .stat-value {
        font-size: 1rem;
    }
    
    .stat-card-content .stat-subtitle {
        font-size: 0.575rem;
    }
    
    .stat-card-icon {
        padding: 0.4rem;
    }
    
    .stat-card-icon i {
        font-size: 0.75rem;
    }
}

/* === Tables === */
.table-container {
    background: white;
    border-radius: 0.75rem;
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.table {
    margin-bottom: 0;
}

.table thead {
    background-color: var(--gray-50);
}

.table thead th {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

.table tbody td {
    padding: 0.75rem 1rem;
    vertical-align: middle;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.table tbody tr {
    border-bottom: 1px solid var(--gray-200);
}

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

.table tbody tr:hover {
    background-color: var(--gray-50);
}

/* === Badges === */
.badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 0.375rem;
}

.badge-success {
    background-color: var(--primary-light);
    color: var(--primary-dark);
}

.badge-warning {
    background-color: #FEF3C7;
    color: #92400E;
}

.badge-info {
    background-color: #DBEAFE;
    color: #1E40AF;
}

.badge-danger {
    background-color: #FEE2E2;
    color: #991B1B;
}

.badge-secondary {
    background-color: var(--gray-100);
    color: var(--gray-700);
}

.badge-cliente {
    background-color: #E9D5FF;
    color: #6B21A8;
}

/* === Forms === */
.form-control,
.form-select {
    border: 1px solid var(--gray-300);
    border-radius: 0.5rem;
    padding: 0.75rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

/* === Buttons === */
.btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.btn i {
    margin-right: 0.5rem;
}

/* === Modal === */
.modal-content {
    border-radius: 0.75rem;
    border: none;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 1.25rem 1.5rem;
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid var(--gray-200);
    padding: 1rem 1.5rem;
}

/* === Login Page === */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--gray-50);
    padding: 1rem;
}

.login-card {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    height: 64px;
    object-fit: contain;
    margin-bottom: 1.5rem;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--gray-500);
    margin-bottom: 2rem;
}

.login-button {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.25rem;
    background: white;
    border: 2px solid var(--gray-200);
    color: var(--gray-700);
    font-weight: 600;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    transition: all 0.3s;
    margin-bottom: 1rem;
    cursor: pointer;
}

.login-button:hover {
    background-color: var(--gray-100);
    border-color: var(--primary);
    transform: scale(1.05);
}

.login-button i {
    margin-right: 0.75rem;
}

/* === Menu Burger Mobile === */
.burger-menu {
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1100;
    display: none;
    width: 44px;
    height: 44px;
    background-color: white;
    border: 1px solid var(--gray-200);
    border-radius: 0.5rem;
    color: var(--gray-700);
    font-size: 1.25rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
}

.burger-menu:hover {
    background-color: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.sidebar-close {
    display: none;
    position: absolute;
    top: 1.5rem;
    right: 1rem;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    color: var(--gray-500);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.sidebar-close:hover {
    color: var(--gray-800);
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* === Responsive === */
@media (max-width: 768px) {
    .burger-menu {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-close {
        display: block;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 1000;
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }
}

/* === Utilities === */
.cursor-pointer {
    cursor: pointer;
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Loading Spinner === */
.spinner-border-primary {
    color: var(--primary);
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state i {
    font-size: 4rem;
    color: var(--gray-300);
    margin-bottom: 1rem;
}

.empty-state h5 {
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-500);
}

/* === Catalog Grid === */
.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.catalog-item {
    background: white;
    border-radius: 0.75rem;
    border: 1px solid var(--gray-200);
    overflow: hidden;
    transition: all 0.3s;
}

.catalog-item:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

.catalog-item-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.catalog-item-content {
    padding: 1rem;
}

.catalog-item-title {
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 0.5rem;
}

.catalog-item-price {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary);
}

/* === Inventory Action Buttons === */
.table tbody tr .btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 0.375rem;
    transition: all 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.table tbody tr .btn-sm:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
}

.table tbody tr .btn-sm:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);
}

/* Pulsante Modifica */
.table tbody tr .btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

.table tbody tr .btn-primary:hover {
    background: linear-gradient(135deg, #5568d3 0%, #66408a 100%);
}

/* Pulsante Elimina */
.table tbody tr .btn-danger {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border: none;
    color: white;
}

.table tbody tr .btn-danger:hover {
    background: linear-gradient(135deg, #e082ea 0%, #e44657 100%);
}

/* Tooltip personalizzato */
.tooltip {
    font-size: 0.875rem;
}

.tooltip-inner {
    background-color: var(--gray-800);
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
}

/* Immagine prodotto nella tabella */
.table tbody tr td img {
    transition: transform 0.2s ease-in-out;
}

.table tbody tr td img:hover {
    transform: scale(1.1);
}

/* ====================================
   Autocomplete Customization
   ==================================== */

/* Wrapper per l'autocomplete */
.autocomplete-wrapper {
    position: relative;
}

/* Container dei suggerimenti */
.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    display: none;
    max-height: 300px;
    overflow-y: auto;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    margin-top: 4px;
    animation: slideDown 0.2s ease-out;
}

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

/* Singolo suggerimento */
.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease, padding-left 0.15s ease;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: var(--primary-light);
    padding-left: 1.25rem;
}

.suggestion-item strong {
    color: var(--gray-800);
    display: block;
    margin-bottom: 0.25rem;
}

.suggestion-item small {
    color: var(--gray-500);
    font-size: 0.875rem;
}

/* Messaggio quando non ci sono risultati */
.suggestion-item.no-results {
    color: var(--gray-500);
    font-style: italic;
    text-align: center;
    cursor: default;
}

.suggestion-item.no-results:hover {
    background-color: transparent;
    padding-left: 1rem;
}

/* Scrollbar personalizzata per i suggerimenti */
.autocomplete-suggestions::-webkit-scrollbar {
    width: 8px;
}

.autocomplete-suggestions::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 0 0.375rem 0.375rem 0;
}

.autocomplete-suggestions::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

.autocomplete-suggestions::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* Focus sull'input */
.autocomplete-wrapper input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(59, 123, 66, 0.25);
}

/* ====================================
   Order Summary / Riepilogo Ordine
   ==================================== */

#order-items-container .card-header {
    background: linear-gradient(135deg, var(--primary-light) 0%, #fff 100%);
    border-bottom: 2px solid var(--primary);
}

#order-items-container .card-header h6 {
    color: var(--primary);
    font-weight: 600;
}

#order-items-container tbody tr {
    transition: background-color 0.2s ease;
}

#order-items-container tbody tr:hover {
    background-color: var(--gray-50);
}

#order-items-container tfoot tr {
    background-color: var(--primary-light) !important;
    border-top: 3px solid var(--primary);
}

#order-items-container tfoot strong {
    font-size: 1.1rem;
}

#order-summary-total {
    color: var(--primary) !important;
    font-size: 1.25rem !important;
    font-weight: 700 !important;
}

/* Badge quantità */
#order-items-container .badge {
    font-size: 0.9rem;
    padding: 0.35em 0.65em;
}

/* Icona fiore */
#order-items-container .fa-flower {
    opacity: 0.7;
}

/* ====================================
   Order Table - Expandable Rows
   ==================================== */

/* Riga principale ordine */
.order-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.order-row:hover {
    background-color: var(--gray-50);
}

/* Icona espansione */
.expand-icon {
    color: var(--primary);
    font-size: 0.875rem;
    transition: transform 0.3s ease, color 0.2s ease;
}

.expand-icon:hover {
    color: var(--primary-dark);
}

/* Riga dettagli espandibile */
.order-details-row {
    background-color: #f8f9fa;
    border-top: none !important;
}

.order-details-row td {
    padding: 0 !important;
    border-top: none !important;
}

.order-details-content {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-left: 4px solid var(--primary);
    border-radius: 0.375rem;
    margin: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    animation: slideDown 0.3s ease-out;
}

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

/* Tabella articoli dentro i dettagli */
.order-details-content .table {
    margin-bottom: 0;
}

.order-details-content .table-bordered {
    border: 1px solid var(--gray-200);
}

.order-details-content .table thead {
    background-color: var(--gray-100);
}

.order-details-content .table-light {
    background-color: var(--gray-50) !important;
}

/* Numero ordine prominente */
.order-details-content h5 {
    font-weight: 600;
    font-size: 1.5rem;
}

/* Cliente multilinea nella tabella */
.order-row td small {
    display: block;
    font-size: 0.85rem;
}

/* Date nella stessa cella */
.order-row td > div {
    line-height: 1.4;
}

/* Hover effetto sul checkbox senza propagazione */
.order-row td input[type="checkbox"] {
    cursor: pointer;
}

/* Responsive: Adatta la tabella su schermi piccoli */
@media (max-width: 768px) {
    .order-details-content .row {
        margin: 0;
    }
    
    .order-details-content .col-md-6,
    .order-details-content .col-md-12 {
        padding: 0.5rem;
    }
    
    .order-details-content h5 {
        font-size: 1.2rem;
    }
}

/* ====================================
   Order Filters with Badges
   ==================================== */

/* Badge nei filtri degli ordini */
#order-filters .badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25em 0.5em;
    border-radius: 10px;
    vertical-align: middle;
}

/* Badge nel pulsante attivo */
#order-filters .btn.active .badge {
    background-color: rgba(255, 255, 255, 0.3) !important;
    color: inherit !important;
}

/* Stili specifici per ogni tipo di badge quando il pulsante è attivo */
#order-filters .btn.active .bg-primary {
    background-color: rgba(255, 255, 255, 0.3) !important;
}

#order-filters .btn.active .bg-info {
    background-color: rgba(255, 255, 255, 0.3) !important;
}

#order-filters .btn.active .bg-success {
    background-color: rgba(255, 255, 255, 0.3) !important;
}

#order-filters .btn.active .bg-secondary {
    background-color: rgba(255, 255, 255, 0.3) !important;
}

/* Transizione smooth per i badge */
#order-filters .badge {
    transition: all 0.2s ease;
}

/* Responsive: Nascondi badge su schermi molto piccoli */
@media (max-width: 576px) {
    #order-filters .badge {
        display: none;
    }
}

