@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ============================================
   RESET E BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #343a40;
    color: #f8f9fa;
    font-family: 'Poppins', sans-serif;
    margin: 0;
    padding: 0;
}

/* ============================================
   TITOLI
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    color: #f8f9fa;
    text-align: center;
}

/* ============================================
   HEADER
   ============================================ */
header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background-color: #343a40;
    width: 100%;
    height: 60px;
    z-index: 1000;
    position: relative;
}

/* ============================================
   ICONE
   ============================================ */
.icon, .logout-icon {
    font-size: 20px;
    color: #fff;
    cursor: pointer;
    transition: color 0.3s ease;
}

.logout-icon:hover {
    color: #c02d2d;
}

/* ============================================
   CONTENITORI
   ============================================ */
.container {
    background-color: #343a40;
    padding: 20px;
    border-radius: 5px;
    color: #f8f9fa;
    margin-top: 1.5rem;
}

#previewContainer {
    background-color: #495057;
    color: #f8f9fa;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #6c757d;
}

/* ============================================
   CARD
   ============================================ */
.card {
    background-color: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 5px;
    margin-bottom: 1.5rem;
}

.card-header {
    background: linear-gradient(135deg, #6c757d 0%, #343a40 100%);
    border-bottom: 1px solid #404040;
    color: #fff;
    font-weight: bold;
}

.card-body {
    background: linear-gradient(135deg, #6c757d 0%, #343a40 100%);
    color: #e0e0e0;
    padding: 1.5rem;
}

.card-title {
    color: #f8f9fa;
}

.card-text {
    color: #f8f9fa;
}

.card a {
    color: #0d6efd;
    text-decoration: none;
}

.card a:hover {
    color: #0b5ed7;
    text-decoration: underline;
}

/* ============================================
   FORM INPUT E TEXTAREA
   ============================================ */
.input, .form-control, .form-select {
    background-color: #2d2d2d;
    color: #f8f9fa;
    border: 1px solid #404040;
    border-radius: 4px;
    padding: 10px;
}

.input::placeholder, .form-control::placeholder {
    color: #888;
}

.form-control:focus, .form-select:focus {
    background-color: #363636;
    border-color: #667eea;
    color: #e0e0e0;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25);
}

.form-label {
    color: #f8f9fa !important;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.form-text {
    color: #adb5bd !important;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.form-text strong {
    color: #20c997 !important;
    font-weight: 600;
}

.form-text .bi {
    color: #ffc107;
}

small.text-muted {
    color: #adb5bd !important;
}

small.text-muted strong {
    color: #20c997 !important;
}

small.text-muted .bi {
    color: #ffc107 !important;
}

/* ============================================
   PULSANTI
   ============================================ */
.btn-primary {
    background-color: #0d6efd;
    color: #fff;
    border: none;
    transition: background-color 0.3s ease;
}

.btn-primary:hover {
    background-color: #0b5ed7;
}

.btn-secondary {
    background-color: #6c757d;
    color: #fff;
    border: none;
    transition: background-color 0.3s ease;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-login {
    width: 100%;
    padding: 15px;
    font-weight: 600;
    font-size: 1.1rem;
    margin-top: 10px;
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    border: none;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.btn-login:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(13, 110, 253, 0.3);
}

.btn-login:active {
    transform: translateY(-1px);
}

/* ============================================
   TABELLE
   ============================================ */
.table {
    color: #e0e0e0;
}

.table-dark {
    background-color: #2d2d2d;
}

.table-dark thead {
    background-color: #495057;
}

.table-dark tbody tr {
    border-bottom: 1px solid #404040;
}

.table-dark tbody tr:hover {
    background-color: #363636;
}

.table-dark td {
    background-color: #2C3034;
    color: #fff;
}

.table-responsive {
    overflow-x: auto;
}

/* ============================================
   MODALI
   ============================================ */
.modal-content {
    background-color: #2d2d2d;
    color: #e0e0e0;
    border: 1px solid #404040;
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.modal-header {
    background: linear-gradient(135deg, #6c757d 0%, #343a40 100%);
    color: #fff;
    border-bottom: 1px solid #404040;
    border-radius: 10px 10px 0 0;
    padding: 1rem 1.5rem;
}

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

.modal-body {
    background-color: #2d2d2d;
    padding: 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #e0e0e0;
}

.modal-footer {
    background-color: #2d2d2d;
    border-top: 1px solid #404040;
    padding: 1rem;
}

/* ============================================
   LINK
   ============================================ */
a {
    color: #0d6efd;
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #0b5ed7;
    text-decoration: underline;
}

/* ============================================
   BADGE
   ============================================ */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    font-size: 0.85rem;
}

/* ============================================
   PAGINAZIONE
   ============================================ */
.pagination .page-link {
    background-color: #2d2d2d;
    border-color: #404040;
    color: #e0e0e0;
}

.pagination .page-link:hover {
    background-color: #383838;
    border-color: #667eea;
    color: #fff;
}

.pagination .page-item.active .page-link {
    background-color: #667eea;
    border-color: #667eea;
}

/* ============================================
   POPUP / TOAST
   ============================================ */
.popup {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    background-color: #28a745;
    color: #fff;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    font-size: 14px;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    display: none;
    max-width: 90%;
    word-wrap: break-word;
    text-align: center;
}

.popup.error {
    background-color: #dc3545;
}

.popup.show {
    display: block;
    opacity: 1;
}

.popup-message {
    position: fixed;
    top: 10px;
    right: 10px;
    z-index: 1050;
    display: none;
    padding: 10px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 5px;
}

/* ============================================
   CONTEXT MENU
   ============================================ */
.custom-context-menu {
    position: absolute;
    background-color: #495057;
    border: 1px solid #6c757d;
    border-radius: 5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    min-width: 200px;
}

.custom-context-menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.custom-context-menu ul li {
    padding: 10px 15px;
    cursor: pointer;
    color: #f8f9fa;
    border-bottom: 1px solid #6c757d;
    transition: background-color 0.2s;
}

.custom-context-menu ul li:last-child {
    border-bottom: none;
}

.custom-context-menu ul li:hover {
    background-color: #6c757d;
}

/* ============================================
   STATS CARD (per log_invii.php)
   ============================================ */
.stats-card {
    background: linear-gradient(135deg, #6c757d 0%, #343a40 100%);
    border: none;
    color: white;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 10px;
}

.stats-card h3 {
    font-size: 2rem;
    margin: 0;
}

.stats-card p {
    margin: 0;
    opacity: 0.9;
}

/* ============================================
   UPLOAD IMAGES
   ============================================ */
.drop-zone {
    border: 2px dashed #6c757d;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.3s ease;
}

.drop-zone.dragover {
    background-color: #495057;
    border-color: #0d6efd;
}

.image-preview {
    width: 150px;
    height: 150px;
    object-fit: cover;
    border-radius: 10px;
    margin: 0 auto;
    display: block;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #121212 0%, #1a1a2e 100%);
    padding: 20px;
}

.login-card {
    background: rgba(33, 37, 41, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.8s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 40px;
}

.login-logo {
    font-size: 3.5rem;
    color: #0d6efd;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.login-title {
    color: white;
    font-weight: 700;
    font-size: 2rem;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #0d6efd, #0dcaf0);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 1rem;
}

.login-footer {
    text-align: center;
    margin-top: 30px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
}

.password-toggle {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    z-index: 10;
}

.password-toggle:hover {
    color: white;
}

.form-floating label {
    color: rgba(255, 255, 255, 0.7);
}

/* ============================================
   ALERT
   ============================================ */
.alert {
    border-radius: 10px;
    border: none;
    padding: 15px;
    margin-bottom: 20px;
}

.alert-danger {
    background: linear-gradient(135deg, rgba(220, 53, 69, 0.9) 0%, rgba(187, 45, 59, 0.9) 100%);
    color: white;
}

.alert-info {
    background-color: rgba(13, 110, 253, 0.2);
    color: #0dcaf0;
    border: 1px solid rgba(13, 110, 253, 0.3);
}

.alert-warning {
    background-color: rgba(255, 193, 7, 0.2);
    color: #ffc107;
    border: 1px solid rgba(255, 193, 7, 0.3);
}

/* ============================================
   ANIMAZIONI
   ============================================ */
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

/* ============================================
   FOOTER
   ============================================ */
footer {
    color: #f8f9fa;
    text-align: center;
    padding: 20px 0;
    margin-top: 30px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .popup, .popup-message {
        top: 10px;
        font-size: 12px;
        padding: 8px 16px;
        max-width: 95%;
    }
    
    .container {
        padding: 15px;
    }
    
    .card-body .row {
        flex-direction: column;
    }
    
    .card-body .col {
        margin-bottom: 15px;
    }
    
    .table-responsive {
        font-size: 12px;
    }
    
    .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .login-card {
        padding: 30px 20px;
        margin: 10px;
    }
    
    .login-title {
        font-size: 1.8rem;
    }
    
    .login-logo {
        font-size: 2.5rem;
    }
}

@media (max-width: 576px) {
    header {
        padding: 8px 15px;
        height: auto;
    }
    
    .container {
        margin-top: 1rem;
    }
}

/* ============================================
   UTILITIES
   ============================================ */
.text-muted {
    color: #adb5bd !important;
}

.message-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-full {
    cursor: pointer;
}

.message-full:hover {
    text-decoration: underline;
}