/* Responsive card width for NIS2 compliance (no inline style) */
.card-responsive {
    max-width: 98vw;
    width: 98%;
}
@media (max-width: 768px) {
    .container {
        max-width: 99vw !important;
        width: 99vw !important;
        box-sizing: border-box !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    .container .custom-logo, .custom-logo {
        height: 70px !important;
        max-height: 70px !important;
        max-width: 100% !important;
    }
}
.custom-logo {
    max-height: 50px !important;
    width: auto !important;
}

.custom-logo-compact {
    max-height: 50px;
    width: auto;
}

.container {
    margin: 0 auto;
    width: 99%;
}

.col-lg-8 {
    max-width: 800px;
}

/* Ensure minimum width for role selector without inline styles (CSP-safe) */
.role-minwidth {
    min-width: 140px;
}

/* Card Styles */
.card {
    border: none;
    border-radius: 16px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    margin-top: 1rem;
}

.card-header {
    background: linear-gradient(135deg, #2c3e50, #3498db);
    padding: 0.75rem 1rem;
    border-bottom: none;
    font-size: 1rem;
    font-size: 1.15rem !important;
    font-weight: 600;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.card-body1 {
    padding: 2rem;
    background: #f8f9fa;
}

/* Ensure card body has bottom border radius matching the card */
.card-body {
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    max-width: 900px;
    width: 90%;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: all 0.3s ease-out;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* List Group Items */
.list-group-item {
    border: 1px solid #dee2e6 !important;
    margin-bottom: 0.75rem;
    border-radius: 12px !important;
    padding: 0.75rem 1.5rem;
    transition: all 0.2s ease;
    background: white;
}

/* Logo */
.custom-logo {
    max-height: 50px !important;
    width: auto !important;
    transition: transform 0.3s ease;
    object-fit: contain;
}

/* Form Styles */
.login-form .form-control {
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.login-form .form-control:focus {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #3498db;
}

/* Toast Notifications */
.toast-container {
    z-index: 1100;
    top: 20px;
    right: 20px;
}

.toast {
    margin-bottom: 0.5rem;
    animation: fadeIn 0.3s;
    max-width: 350px;
}

.toast-body {
    padding: 0.75rem;
}

/* Ensure heading sizing/margins are explicit to satisfy validators and provide a consistent base */
h1 {
    font-size: 1.75rem;
    margin: 0.67rem 0;
}

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

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

/* Select2 Styles */
.select2-container--default .select2-selection--single {
    height: 38px;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 36px;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 36px;
}

#new-company-container {
    transition: all 0.3s ease;
    margin-top: 8px;
    display: none;
}

#existingFilesSection,
#deleteZipBtn,
#downloadZipBtn,
#totalSize {
    display: none;
}

/* Text Colors */
.text-info {
    color: #0dcaf0;
}

.text-success {
    color: #198754;
}

.text-danger {
    color: #dc3545;
}

.text-warning {
    color: #ffc107;
}

/* Badge Styles */
.waiting-badge {
    background-color: #ffc107;
    color: white;
}

.accepted-badge {
    background-color: #198754;
    color: white;
}

/* Signature Styles */
.signature-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
    background: white;
    width: 100%;
}

#signature-canvas {
    width: 100%;
    height: 200px;
    background-color: #f8f9fa;
    touch-action: none;
}

/* Login Form Styles */
.login-container {
    max-width: 500px;
    margin: 2rem auto;
}

.login-form .form-control {
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #dee2e6;
    transition: all 0.3s ease;
}

.login-form .form-control:focus {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #3498db;
}
 .card-header .bi-chevron-down {
        color: white;
        font-weight: bold;
        font-size: 1.2rem;
    }

@media (max-width: 768px) {
    .card-header .bi-chevron-down {
        color: white;
        font-weight: bold;
        font-size: 1rem;
    }

    .container {
        max-width: 100% !important;
        padding: 0;
        margin: 0 auto;
    }

    .card {
        margin: 0.5rem 0 !important;
        border-radius: 14px !important;
        width: 100% !important;
    }

    .card-header {
        padding: 0.75rem 1rem !important;
        font-size: 0.95rem;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }

    .dati {
        height: 3rem !important;
    }

    .card-body1 {
        padding: 1rem !important;
    }

    .card-body {
        padding-top: 0em !important;
         padding-left: 0.2em !important;
          padding-right: 0.2em !important;
    }

    .custom-logo {
        max-height: 50px !important;
    }

    html {
        font-size: 90%;
    }
    
    .form-control,
    .form-select {
        font-size: 1.8em;
    }

    .col-lg-10 {
        padding: 0rem;
    }

    /* Toast Notifications */
    .toast-container {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        max-width: 100%;
    }

    .toast {
        width: 100%;
        max-width: 100%;
    }

    /* Mobile action buttons */
    .action-buttons {
        display: flex;
        justify-content: space-between;
        padding: 0.3rem 1rem;
        background: #f8f9fa;
        border-bottom: 1px solid #dee2e6;
        margin: 0.5rem 0;
    }

    .btn-outline-primary,
    .btn-logout {
        font-weight: bold;
        width: auto;
        padding: 0.3rem 0.3em;
        font-size: 1rem;
        border-radius: 0.2rem;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.3rem;
        height: 32px;
    }

    .btn-mobile {
        margin-left: 1rem;
        margin-right: 1rem;
        margin-top: 0.7rem;
    }

    .card-body {
        padding-top: 0.6em;
    }

    /* Icon-only buttons for mobile */
    .btn-outline-danger {
        position: relative;
        width: 45px;
        height: 45px;
        padding: 0;
        border: 1px solid #dc3545;
        background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23dc3545"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"/><path d="M10 10h2v6h-2zm4 0h2v6h-2z" fill="%23fff"/></svg>') no-repeat center;
        background-size: 24px;
        text-indent: -9999px;
        overflow: hidden;
    }

    /* Hide badges on mobile except position-absolute ones */
    .badge:not(.position-absolute) {
        display: none !important;
    }

    /* Show tick mark on cancel button when registered */
    .btn-outline-danger.registered {
        overflow: visible;
        position: relative;
    }
    .btn-outline-danger.registered::after {
        content: '';
        position: absolute;
        top: -10px;
        right: -7px;
        width: 24px;
        height: 24px;
        background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%2328a745"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41L9 16.17z"/></svg>') no-repeat center;
        background-size: 14px;
        background-color: white;
        border-radius: 50%;
        border: 2px solid #28a745;
        box-shadow: 0 0 0 2px white;
        z-index: 10;
    }
    
    .btn-iscriviti {
        position: relative;
        width: 45px;
        height: 45px;
        padding: 0;
        border: none;
        background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23007bff"><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/></svg>') no-repeat center;
        background-size: 24px;
        text-indent: -9999px;
        overflow: hidden;
    }

    }
    
/* Styles for choose_role.php */
.role-card {
    cursor: pointer;
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.75rem;
    border-radius: 12px;
    background: white;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease-in-out;
    display: block;
    text-decoration: none;
    color: inherit;
    /* Fix Chrome rendering */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.role-card:hover {
    transform: translateY(-3px);
    -webkit-transform: translateY(-3px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-color: #3498db;
}

.role-card:active {
    transform: translateY(0);
    -webkit-transform: translateY(0);
}

.role-card .d-flex {
    align-items: center;
    gap: 1rem;
}

/* Utility classes replacing inline styles */
.approvato-true {
    background: #dc3545;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}
.approvato-false {
    background: #198754;
    color: #fff;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}
.debug-pre {
    background:#fff;
    color:#000;
    border:1px solid #ccc;
    padding:10px;
}
.error-text { color: red; }

.role-icon {
    font-size: 2rem;
    color: #2c3e50;
    flex-shrink: 0;
}

.btn-logout.desktop {
    display: none;
}

.btn-logout-text {
    display: inline-block !important;
    color: white;
    font-size: 1rem;
}

@media (max-width: 768px) {
    .btn-logout {
        position: fixed;
        top: 1.2rem;
        right: 1.2rem;
        z-index: 1100;
        background: white;
        border-radius: 35%;
        width: 42px;
        height: 42px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .container {
        max-width: 100% !important;
        padding: 0;
    }

    .col-lg-8 {
        padding: 0rem;
    }

    .card-header {
        padding-right: 1rem !important;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
    }
}

@media (min-width: 768px) {
    .btn-logout {
        background: transparent !important;
        box-shadow: none !important;
    }

    .btn-logout .bi {
        color: white !important;
    }
}

/* Styles for lista_corsi.php */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 1rem;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: all 0.3s ease-out;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.list-group-item {
    border: none;
    margin-bottom: 0.75rem;
    border-radius: 12px !important;
    padding: 1.25rem 1.5rem;
    transition: all 0.2s ease;
    background: white;
    text-align: left !important;
}

.list-group-item > div:first-child {
    text-align: left;
}

.list-group-item h5 {
    text-align: left;
    margin-bottom: 0.5rem;
}

.list-group-item small {
    text-align: left;
    display: block;
}

.list-group-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.badge-signed {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: #198754;
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-signed .bi {
    font-size: 1.1em;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

.badge-signed-text {
    display: none;
}

.badge-cooldown {
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: #198754;
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.badge-cooldown .bi {
    font-size: 1.1em;
    filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.1));
}

.badge-cooldown-text {
    display: none;
}

.badge-count {
    background: #6c757d;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Styles for edit_profile.php */
.badge-signed {
    background: #198754;
    padding: 0.4rem 0.8rem;
    border-radius: 24px;
}

.select2-container--default .select2-selection--single {
    border: 1px solid #ced4da !important;
    border-radius: 0.375rem !important;
    height: 45px !important;
    display: flex !important;
    align-items: center;
}

/* Styles extracted from verify_email.php */
.verification-icon {
    font-size: 64px;
    margin-bottom: 20px;
}
.icon-success { color: #28a745; }
.icon-error { color: #dc3545; }
.verification-title { font-size: 24px; font-weight: 600; margin-bottom: 15px; color: #333; }
.verification-message { font-size: 16px; color: #666; margin-bottom: 30px; line-height: 1.6; }
.btn-login { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border: none; padding: 12px 30px; font-size: 16px; border-radius: 5px; color: white; text-decoration: none; display: inline-block; transition: transform 0.2s; }
.btn-login:hover { transform: translateY(-2px); color: white; text-decoration: none; }
.card-body1 { padding: 2rem; background: #f8f9fa; text-align: center; }

@media (max-width: 768px) {
    .card { margin: 0.5rem 0 !important; border-radius: 14px !important; }
    .card-header { padding: 1.4rem !important; }
    .card-body1 { padding: 1.4rem !important; }
    .custom-logo { max-width: 100px !important; }
    .form-control, .form-select { font-size: 1.8em; }
}

/* Additional styles extracted from index.php to satisfy CSP */
.card-header-toggle {
    cursor: pointer;
    transition: background-color 0.2s;
    position: relative;
    z-index: 1;
}

.toggle-icon {
    transition: transform 0.3s ease;
}

.card-header-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

.user-data-section {
    margin-bottom: 1.5rem;
    border-radius: 12px;
    overflow: visible;
    position: relative;
}

.col-lg-8 {
    padding: 0rem !important;
}

/* Fix: ensure Select2 dropdowns are not clipped and appear above cards
   - High z-index so dropdown floats above other elements
   - Minimum width so it isn't rendered as a tiny rectangle
   - Force container width to fill available space for consistent look
*/
.select2-dropdown {
    z-index: 99999 !important;
    min-width: 220px !important;
}
.select2-container {
    width: 100% !important;
}
.select2-container--open .select2-dropdown {
    left: 0 !important;
}

/* keep rendered selection text multi-line if needed and ensure arrow is visible */
.select2-container--default .select2-selection--single .select2-selection__rendered {
    white-space: normal !important;
    overflow: visible !important;
}

.select2-dropdown {
    position: absolute !important;
    /* let select2 JS set the width to match the control - avoid forcing 100% */
    width: 100% !important;
    max-width: 100%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border: 1px solid #dee2e6 !important;
    z-index: 9999 !important;
}

.select2-results__options {
    /* Increase max-height to show more list items in dropdown
       Default was 200px; bump to 360px for improved visibility on desktop
       Keep overflow-y auto to allow scrolling if list is still long. */
    max-height: 360px !important;
    overflow-y: auto;
}

@media (min-width: 768px) {
    .btn-logout {
        position: static !important;
        transform: none !important;
        box-shadow: none !important;
        background: transparent !important;
        width: auto !important;
        height: auto !important;
    }

    .btn-logout .bi {
        color: white !important;
        font-size: 1.2rem;
    }

    .btn-logout-text {
        display: inline-block !important;
        color: white;
        font-size: 1rem;
    }

    .custom-logo {
        max-width: 120px;
    }

    .select2-dropdown {
        width: auto !important;
        /* fallback min width equal to the original select so dropdown never narrower */
        min-width: inherit !important;
    }
}

@media (max-width: 768px) {
    .btn-logout {
        position: fixed;
        top: 1.2rem;
        right: 1.2rem;
        z-index: 1100;
        padding: 0px;
        background: white;
        border-radius: 35%;
        width: 42px;
        height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    }

    .btn-logout:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    }

    .btn-logout:active {
        transform: scale(0.96);
    }

    .btn-logout .bi {
        font-size: 1.4em;
        color: #2c3e50;
        margin-right: 0;
    }

    .select2-dropdown {
        width: 100vw !important;
        left: 0 !important;
        max-width: none;
        margin-left: -1rem;
        margin-right: -1rem;
    }
}

/* Mobile responsive card width */
@media (max-width: 768px) {
    .card-responsive .card {
        width: 99vw !important;
        max-width: 99vw !important;
        margin: 0.5rem auto 0 auto !important;
        position: relative !important;
        left: 0 !important;
        right: 0 !important;
    }
}

/* Signature header spacing */
.signature-header-spacing {
    margin-top: 1.5rem;
}

/* PDF footer/meta used by genera_pdf.php - moved from inline style to CSS to respect strict CSP */
.pdf-meta {
    margin-top: 30px;
    text-align: right;
    font-size: 7pt;
}

/* Email history modal pre element - moved from inline style to respect CSP */
#historyBody {
    white-space: pre-wrap;
}

/* End of extracted styles */

/* Signature history modal styles */
.signature-preview-img {
    max-width: 300px;
    border: 1px solid #ddd;
    padding: 10px;
}

@media (max-width: 768px) {
    .signature-preview-img {
        max-width: 100%;
    }
}
