/* Apartrent2026 - Custom Styles */

:root {
    --primary-color: #0d6efd;
    --sidebar-width: 250px;
    --navbar-height: 56px;
}

/* General */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
}

/* Utility - for text-truncate in flex containers */
.min-width-0 {
    min-width: 0;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 15px;
    overflow: hidden;
    background-color: #fff;
}

.login-card > .card-header:first-child {
    border-radius: 0 !important;
    border: none !important;
    margin: -1px -1px 0 -1px;
}

.login-card .card-header.bg-primary {
    background-color: #0d6efd !important;
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    z-index: 100;
    transition: all 0.3s;
}

.sidebar .sidebar-content {
    padding: 1rem;
}

.sidebar-link {
    display: block;
    color: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    margin-bottom: 2px;
    transition: all 0.2s;
    text-decoration: none;
}

.sidebar-link:hover {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-link.active {
    color: #fff;
    background-color: var(--primary-color);
}

.sidebar-link i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.sidebar-section-title {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.70rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 1rem 1rem 0.5rem;
    margin-top: 0.5rem;
}

.sidebar-section-title:first-child {
    margin-top: 0;
}

/* Main Content */
.main-content {
    transition: all 0.3s;
}

.main-content.with-sidebar {
    margin-left: var(--sidebar-width);
    padding-top: calc(var(--navbar-height) + 20px);
}

.page-content {
    padding: 20px;
}

/* Cards */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid #eee;
    font-weight: 600;
}

/* Stats Cards */
.stat-card {
    border-left: 4px solid;
    transition: transform 0.2s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card.primary { border-left-color: #0d6efd; }
.stat-card.success { border-left-color: #198754; }
.stat-card.warning { border-left-color: #ffc107; }
.stat-card.danger { border-left-color: #dc3545; }
.stat-card.info { border-left-color: #0dcaf0; }

.stat-card .stat-icon {
    font-size: 2.5rem;
    opacity: 0.3;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: bold;
}

.stat-card .stat-label {
    color: #6c757d;
    font-size: 0.9rem;
}

/* Tables */
.table {
    margin-bottom: 0;
}

.table th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    font-weight: 600;
    white-space: nowrap;
}

.table td {
    vertical-align: middle;
}

.table-actions {
    white-space: nowrap;
}

.table-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Badges */
.badge {
    padding: 0.5em 0.75em;
    font-weight: 500;
}

.badge-stato-attivo { background-color: #198754; }
.badge-stato-bozza { background-color: #6c757d; }
.badge-stato-scaduto { background-color: #dc3545; }
.badge-stato-pendente { background-color: #ffc107; color: #000; }
.badge-stato-pagata { background-color: #198754; }

/* Forms */
.form-label {
    font-weight: 500;
    margin-bottom: 0.3rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* Buttons */
.btn {
    border-radius: 8px;
    padding: 0.5rem 1rem;
    font-weight: 500;
}

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

/* Quick Actions */
.quick-action-btn {
    padding: 1rem;
    text-align: center;
    border-radius: 10px;
    background-color: #f8f9fa;
    transition: all 0.2s;
    cursor: pointer;
    border: 1px solid #dee2e6;
}

.quick-action-btn:hover {
    background-color: #e9ecef;
    transform: translateY(-2px);
}

.quick-action-btn i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.5rem;
    color: var(--primary-color);
}

/* Public Area */
.immobile-card {
    transition: all 0.3s;
}

.immobile-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.immobile-card .card-img-top {
    height: 200px;
    object-fit: cover;
    background-color: #e9ecef;
}

.immobile-card .property-features {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.immobile-card .property-features span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.85rem;
    color: #6c757d;
}

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

/* Pagination */
.pagination {
    margin-top: 1rem;
}

.page-link {
    border-radius: 8px;
    margin: 0 2px;
    border: none;
    color: #6c757d;
}

.page-link:hover {
    background-color: #e9ecef;
    color: var(--primary-color);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    color: #fff;
}

/* Loading */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

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

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

/* =====================================================
   MOBILE STYLES - AREA INQUILINO
   ===================================================== */

/* Bottom Navigation per inquilini su mobile */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary-color);
    z-index: 1000;
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
}

.bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bottom-nav-item {
    flex: 1;
    text-align: center;
}

.bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.75rem;
    transition: color 0.2s;
}

.bottom-nav-link i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.bottom-nav-link.active,
.bottom-nav-link:hover {
    color: #fff;
}

/* Mobile card per movimenti (sostituisce tabella) */
.movimento-card-mobile {
    background: #fff;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid #dee2e6;
}

.movimento-card-mobile.tipo-dare {
    border-left-color: #dc3545;
}

.movimento-card-mobile.tipo-avere {
    border-left-color: #198754;
}

.movimento-card-mobile .mov-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.movimento-card-mobile .mov-causale {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
}

.movimento-card-mobile .mov-importo {
    font-weight: 700;
    font-size: 1.1rem;
}

.movimento-card-mobile .mov-importo.dare {
    color: #dc3545;
}

.movimento-card-mobile .mov-importo.avere {
    color: #198754;
}

.movimento-card-mobile .mov-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: #6c757d;
}

.movimento-card-mobile .mov-details span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.movimento-card-mobile .mov-stato {
    margin-top: 0.5rem;
}

/* Stats cards compatte mobile */
.stat-card-compact {
    font-size: 0.95rem;
}

.stat-card-compact .fw-bold {
    font-size: 1.1rem;
}

/* Ticket card mobile */
.ticket-card-mobile {
    background: #fff;
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid #6c757d;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.ticket-card-mobile:active {
    transform: scale(0.98);
}

.ticket-card-mobile.priorita-urgente { border-left-color: #dc3545; }
.ticket-card-mobile.priorita-alta { border-left-color: #fd7e14; }
.ticket-card-mobile.priorita-media { border-left-color: #0d6efd; }
.ticket-card-mobile.priorita-bassa { border-left-color: #6c757d; }

.ticket-card-mobile .ticket-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.ticket-card-mobile .ticket-numero {
    font-size: 0.8rem;
    color: #6c757d;
}

.ticket-card-mobile .ticket-oggetto {
    font-weight: 600;
    font-size: 0.95rem;
    color: #333;
    margin-bottom: 0.25rem;
}

.ticket-card-mobile .ticket-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
}

.ticket-card-mobile .ticket-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ticket-card-mobile .ticket-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Modal mobile improvements */
@media (max-width: 767.98px) {
    .modal-fullscreen-md-down .modal-body {
        padding: 1rem;
    }

    .modal-fullscreen-md-down .modal-footer {
        padding: 0.75rem 1rem;
        gap: 0.5rem;
    }

    .modal-fullscreen-md-down .modal-footer .btn {
        flex: 1;
    }

    /* Ticket dettaglio mobile - card header compatto */
    #dettaglioTicketContent .card-header {
        font-size: 0.8rem;
        padding: 0.5rem 0.75rem !important;
    }

    #dettaglioTicketContent .card-header .d-flex {
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between;
        flex-wrap: nowrap;
        gap: 0.5rem;
    }

    #dettaglioTicketContent .card-header .d-flex > div:first-child {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
        min-width: 0;
    }

    #dettaglioTicketContent .card-header .text-muted.small {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.7rem;
    }

    #dettaglioTicketContent .card-header .mt-1.small {
        font-size: 0.7rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #dettaglioTicketContent .card-header .badge {
        font-size: 0.65rem;
        padding: 0.2em 0.4em;
    }

    /* Ticket dettaglio mobile - azioni admin scrollabili */
    #dettaglioTicketContent .bg-light.rounded {
        overflow-x: auto;
        flex-wrap: nowrap !important;
        padding-bottom: 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    #dettaglioTicketContent .bg-light.rounded .btn {
        flex-shrink: 0;
        white-space: nowrap;
    }

    /* Row to column su mobile */
    #dettaglioTicketContent .row.g-2 {
        flex-direction: column;
    }

    #dettaglioTicketContent .row.g-2 > div[class*="col-"] {
        width: 100% !important;
        max-width: 100% !important;
    }

    #dettaglioTicketContent .border-start {
        border-left: none !important;
        border-top: 1px solid #dee2e6 !important;
        padding-top: 0.75rem;
        margin-top: 0.5rem;
    }

    /* Conversazione compatta */
    #dettaglioTicketContent .card-body.border-bottom {
        padding: 0.75rem !important;
    }

    /* Form risposta mobile */
    #dettaglioTicketContent textarea {
        font-size: 16px;
    }

    /* Form mobile touch-friendly */
    .modal-fullscreen-md-down .form-control,
    .modal-fullscreen-md-down .form-select {
        min-height: 44px;
        font-size: 16px; /* Previene zoom su iOS */
    }

    .modal-fullscreen-md-down textarea.form-control {
        min-height: auto;
    }

    /* Badge più piccoli nel titolo modal */
    #dettaglioTicketTitle .badge {
        font-size: 0.7rem;
        padding: 0.3em 0.5em;
    }

    /* Pulsanti allega/invia più piccoli */
    #dettaglioTicketContent .btn[style*="58px"] {
        width: 40px !important;
        height: 40px !important;
    }

    #dettaglioTicketContent .btn[style*="58px"] i {
        font-size: 1rem !important;
    }

    /* Textarea risposta più compatta */
    #dettaglioTicketContent #ticketRisposta {
        min-height: 60px;
    }
}

/* Quick actions mobile */
.quick-actions-mobile {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.quick-action-mobile {
    background: #fff;
    border-radius: 16px;
    padding: 1.5rem 1rem;
    text-align: center;
    text-decoration: none;
    color: inherit;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transition: transform 0.2s, box-shadow 0.2s;
}

.quick-action-mobile:hover,
.quick-action-mobile:active {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    color: inherit;
}

.quick-action-mobile i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
}

.quick-action-mobile .action-title {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.quick-action-mobile .action-desc {
    font-size: 0.8rem;
    color: #6c757d;
}

/* Saldo card mobile */
.saldo-card-mobile {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.saldo-card-mobile .saldo-label {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-bottom: 0.5rem;
}

.saldo-card-mobile .saldo-value {
    font-size: 2.5rem;
    font-weight: 700;
}

.saldo-card-mobile .saldo-desc {
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 0.5rem;
}

/* Mobile specific media queries */
@media (max-width: 767.98px) {
    /* Mostra bottom nav per inquilini */
    body.inquilino-view .bottom-nav {
        display: block;
    }

    /* Nascondi sidebar per inquilini su mobile */
    body.inquilino-view .sidebar {
        display: none !important;
    }

    /* Nascondi pulsante hamburger per inquilini (hanno bottom nav) */
    body.inquilino-view .navbar-toggler {
        display: none !important;
    }

    /* Navbar più compatta per inquilini */
    body.inquilino-view .navbar {
        padding-top: 0.5rem;
        padding-bottom: 0.5rem;
    }

    body.inquilino-view .navbar-brand {
        font-size: 1rem;
    }

    /* Rimuovi margine sidebar e aggiusta padding top */
    body.inquilino-view .main-content.with-sidebar {
        margin-left: 0;
        padding-top: calc(50px + 1rem); /* Navbar compatta + margine */
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }

    /* Titoli più piccoli */
    body.inquilino-view h2 {
        font-size: 1.5rem;
    }

    /* Container fluid padding */
    body.inquilino-view .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Card più compatte */
    body.inquilino-view .card {
        border-radius: 12px;
    }

    /* Bottoni touch-friendly */
    body.inquilino-view .btn {
        min-height: 44px;
        padding: 0.625rem 1rem;
    }

    /* Fix per iOS safe areas */
    body.inquilino-view {
        padding-bottom: env(safe-area-inset-bottom);
    }
}


/* Desktop inquilino - nascondi bottom nav */
@media (min-width: 768px) {
    .bottom-nav {
        display: none !important;
    }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

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

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

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

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