/* Admin Panel CSS - Chatbot Widget
 * Data: 2025-11-03 ore 17:50
 * Conformità: Design professionale e responsive
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f7fa;
    color: #2d3748;
    line-height: 1.6;
}

/* CONTAINER PRINCIPALE */
.admin-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* HEADER ADMIN */
.admin-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.admin-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.admin-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* NAVIGAZIONE */
.admin-nav {
    background: white;
    padding: 0 2rem;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 2rem;
}

.nav-item {
    padding: 1rem 0;
    text-decoration: none;
    color: #64748b;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.nav-item:hover,
.nav-item.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* MAIN CONTENT */
.admin-main {
    flex: 1;
    padding: 2rem;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

/* CARDS E GRID */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border-left: 4px solid #667eea;
}

.stat-card h3 {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: #1a202c;
    margin-bottom: 0.25rem;
}

.stat-change {
    font-size: 0.875rem;
    color: #10b981;
    font-weight: 500;
}

/* CHARTS */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.chart-container h3 {
    margin-bottom: 1rem;
    color: #374151;
}

/* SYSTEM STATUS */
.system-status {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
}

.status-indicator.online {
    color: #10b981;
    font-weight: 600;
}

.status-indicator.offline {
    color: #ef4444;
    font-weight: 600;
}

/* BUTTONS */
.btn-primary {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary:hover {
    background: #5a67d8;
    transform: translateY(-1px);
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-danger {
    background: #ef4444;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-logout {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.3);
}

.btn-back {
    background: #6b7280;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.875rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
    margin: 0 0.125rem;
}

/* FORMS */
.rules-container {
    display: grid;
    gap: 2rem;
}

.rule-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.rule-section h2 {
    margin-bottom: 1.5rem;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
    padding-bottom: 0.5rem;
}

.rule-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.rule-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rule-item label {
    font-weight: 600;
    color: #374151;
}

.rule-item input,
.rule-item select {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.3s ease;
}

.rule-item input:focus,
.rule-item select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rule-item small {
    color: #6b7280;
    font-size: 0.75rem;
}

.checkbox-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.rules-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* FILTERS */
.filters-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.filter-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-item label {
    font-weight: 600;
    color: #374151;
    font-size: 0.875rem;
}

.filter-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
    justify-content: flex-start;
    margin-top: 1rem;
}

/* QUICK STATS */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.quick-stats .stat-card {
    text-align: center;
    border-left: none;
    border-top: 4px solid #667eea;
}

.quick-stats .stat-number {
    font-size: 1.5rem;
}

/* TABLES */
.conversations-table-container {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.conversations-table {
    width: 100%;
    border-collapse: collapse;
}

.conversations-table th {
    background: #f8fafc;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.conversations-table td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
}

.conversations-table tr:hover {
    background: #f8fafc;
}

.no-data,
.loading {
    text-align: center;
    color: #6b7280;
    font-style: italic;
    padding: 2rem;
}

/* PAGINATION */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    background: white;
    margin: 2% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}

.modal-header {
    background: #667eea;
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.modal-close:hover {
    background: rgba(255,255,255,0.2);
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* CONVERSATION DETAILS */
.conversation-info {
    margin-bottom: 1.5rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.info-item {
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 6px;
}

.info-item strong {
    display: block;
    color: #374151;
    margin-bottom: 0.25rem;
}

.conversation-messages {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 8px;
}

.message.user {
    background: #dbeafe;
    margin-left: 2rem;
}

.message.bot {
    background: #f3f4f6;
    margin-right: 2rem;
}

.message-content {
    margin-bottom: 0.25rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
    overflow-wrap: break-word;
}

.message-time {
    font-size: 0.75rem;
    color: #6b7280;
}

.booking-details {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 8px;
    padding: 1rem;
}

.booking-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

/* STATUS MESSAGES */
.status-message {
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    font-weight: 500;
}

.status-message.success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-message.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.status-message.info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .admin-nav {
        flex-direction: column;
        gap: 0;
    }
    
    .nav-item {
        padding: 0.75rem 0;
        border-bottom: 1px solid #e5e7eb;
        border-left: none;
    }
    
    .stats-grid,
    .charts-grid {
        grid-template-columns: 1fr;
    }
    
    .rule-grid,
    .filters-grid {
        grid-template-columns: 1fr;
    }
    
    .conversations-table-container {
        overflow-x: auto;
    }
    
    .modal-content {
        width: 95%;
        margin: 5% auto;
    }
    
    .rules-actions,
    .filter-actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .admin-main {
        padding: 1rem;
    }
    
    .stat-card,
    .rule-section,
    .filters-section {
        padding: 1rem;
    }
    
    .conversations-table th,
    .conversations-table td {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
}

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

.admin-section.active {
    animation: fadeIn 0.3s ease;
}

.stat-card,
.chart-container,
.rule-section {
    animation: fadeIn 0.5s ease;
}

/* SECURITY SECTION */
.security-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.security-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    font-weight: 500;
    color: #64748b;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-btn:hover {
    color: #667eea;
    background: #f8fafc;
}

.security-tab {
    display: none;
}

.security-tab.active {
    display: block;
}

/* ANOMALIES */
.anomalies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.anomaly-item {
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.anomaly-item h4 {
    font-size: 0.875rem;
    color: #991b1b;
    margin-bottom: 0.5rem;
}

.anomaly-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: #dc2626;
    margin-bottom: 0.25rem;
}

.anomaly-details {
    font-size: 0.75rem;
    color: #6b7280;
}

.recent-anomalies {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
}

.anomalies-list {
    max-height: 300px;
    overflow-y: auto;
}

.anomaly-record {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.anomaly-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.anomaly-type {
    font-weight: 600;
    color: #dc2626;
}

.anomaly-time {
    font-size: 0.75rem;
    color: #6b7280;
}

.no-anomalies {
    text-align: center;
    color: #10b981;
    padding: 2rem;
    font-weight: 500;
}

/* GEO STATS */
.geo-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.geo-item {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    padding: 1rem;
    border-radius: 8px;
    text-align: center;
}

.geo-item.suspicious {
    background: #fef2f2;
    border-color: #fecaca;
}

.geo-item h4 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.geo-count {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 0.25rem;
}

.geo-item.suspicious .geo-count {
    color: #dc2626;
}

.geo-percentage {
    font-size: 0.75rem;
    color: #6b7280;
}

.geo-details {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
}

.geo-table-container {
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.geo-table {
    width: 100%;
    border-collapse: collapse;
}

.geo-table th,
.geo-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

.geo-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
}

/* IP STATS */
.ip-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.top-ips,
.suspicious-ips {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
}

.top-ips h4,
.suspicious-ips h4 {
    margin-bottom: 1rem;
    color: #374151;
}

.ip-list {
    max-height: 250px;
    overflow-y: auto;
}

.ip-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    gap: 0.5rem;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
}

.ip-item.suspicious {
    background: #fef2f2;
    border-color: #fecaca;
}

.ip-rank {
    font-weight: 700;
    color: #667eea;
}

.ip-address {
    font-family: monospace;
    font-weight: 600;
}

.ip-location {
    color: #6b7280;
}

.ip-count {
    font-size: 0.75rem;
    color: #6b7280;
}

.ip-reason {
    color: #dc2626;
    font-size: 0.75rem;
}

.no-suspicious {
    text-align: center;
    color: #10b981;
    padding: 1rem;
    font-weight: 500;
}

.ip-details {
    border-top: 1px solid #e5e7eb;
    padding-top: 1.5rem;
}

.ip-search {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ip-search input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
}

.ip-details-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1rem;
}

.ip-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}

.ip-anomalies {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 0.75rem;
    margin: 1rem 0;
}

.ip-anomalies ul {
    margin: 0.5rem 0 0 1rem;
}

.ip-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* CONVERSATION TABLE UPDATES */
.geo-info {
    font-size: 0.75rem;
}

.ip-short {
    font-family: monospace;
    color: #6b7280;
}

.location {
    color: #374151;
}

.anomaly-low {
    color: #f59e0b;
    font-weight: 600;
}

.anomaly-medium {
    color: #ef4444;
    font-weight: 600;
}

.anomaly-high {
    color: #dc2626;
    font-weight: 700;
    background: #fef2f2;
    padding: 0.125rem 0.25rem;
    border-radius: 3px;
}

.btn-warning {
    background: #f59e0b;
    color: white;
}

.btn-warning:hover {
    background: #d97706;
}

/* STAT CARDS UPDATES */
.anomaly-card {
    border-left-color: #ef4444;
}

.anomaly-card .stat-number {
    color: #dc2626;
}

.security-card {
    border-left-color: #6b7280;
}

.security-card .stat-number {
    color: #374151;
}

/* FILTER RESULTS */
.conversations-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.filter-results {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #1e40af;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-results span {
    font-weight: 600;
}

/* FILTER ENHANCEMENTS */
.filter-item input[type="date"],
.filter-item input[type="text"],
.filter-item select {
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.filter-item input:focus,
.filter-item select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-actions .btn-primary {
    background: #10b981;
}

.filter-actions .btn-primary:hover {
    background: #059669;
}

.filter-actions .btn-secondary {
    background: #f59e0b;
    color: white;
}

.filter-actions .btn-secondary:hover {
    background: #d97706;
}

/* ACTIVE FILTERS INDICATOR */
.filters-section.has-active-filters {
    border-left: 4px solid #10b981;
}

.filters-section.has-active-filters h3::after {
    content: " (Filtri Attivi)";
    color: #10b981;
    font-size: 0.875rem;
    font-weight: normal;
}

/* UTILITIES */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.hidden { display: none; }
.visible { display: block; }