/**
 * Admin Panel Styles - Plateform Socket.IO
 * 
 * Stili condivisi per tutte le pagine admin
 * 
 * @author Plateform Team
 * @version 2.0.0
 * @license MIT
 */

/* ============================================================================
   RESET E STILI BASE
   ============================================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: white;
  border-radius: 15px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

/* ============================================================================
   HEADER
   ============================================================================ */

.header {
  background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
  color: white;
  padding: 30px;
  text-align: center;
}

.header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
}

.header p {
  opacity: 0.9;
  font-size: 1.1em;
}

/* ============================================================================
   SEZIONI PRINCIPALI
   ============================================================================ */

.login-section {
  padding: 40px;
  text-align: center;
  display: block;
}

.login-info {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 30px;
  text-align: left;
}

.login-info p {
  margin-bottom: 8px;
  color: #495057;
}

.login-info code {
  background: #e9ecef;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: "Courier New", monospace;
  font-weight: bold;
  color: #495057;
}

.admin-section {
  padding: 40px;
  display: none;
}

/* ============================================================================
   FORM E INPUT
   ============================================================================ */

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: #2c3e50;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 12px;
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  font-size: 16px;
  transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #3498db;
}

/* ============================================================================
   PULSANTI
   ============================================================================ */

.btn {
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: white;
  padding: 12px 30px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition:
    transform 0.2s,
    box-shadow 0.2s;
  margin: 5px;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.btn-danger:hover {
  box-shadow: 0 5px 15px rgba(231, 76, 60, 0.4);
}

.btn-success {
  background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
}

.btn-success:hover {
  box-shadow: 0 5px 15px rgba(39, 174, 96, 0.4);
}

.btn-warning {
  background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
}

.btn-warning:hover {
  box-shadow: 0 5px 15px rgba(243, 156, 18, 0.4);
}

.btn-info {
  background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
}

.btn-info:hover {
  box-shadow: 0 5px 15px rgba(23, 162, 184, 0.4);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

/* ============================================================================
   STATI E MESSAGGI
   ============================================================================ */

.status {
  padding: 15px;
  border-radius: 8px;
  margin: 20px 0;
  font-weight: 600;
}

.status.success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.status.error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.status.info {
  background-color: #d1ecf1;
  color: #0c5460;
  border: 1px solid #bee5eb;
}

/* ============================================================================
   TABELLE
   ============================================================================ */

.users-table,
.tokens-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.users-table th,
.tokens-table th {
  background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
  color: white;
  padding: 15px;
  text-align: left;
  font-weight: 600;
}

.users-table td,
.tokens-table td {
  padding: 12px 15px;
  border-bottom: 1px solid #e1e8ed;
  word-break: break-word;
}

.users-table tr:hover,
.tokens-table tr:hover {
  background-color: #f8f9fa;
}

.users-table tr:last-child td,
.tokens-table tr:last-child td {
  border-bottom: none;
}

.tokens-table {
  font-size: 14px;
}

.tokens-table th {
  padding: 12px;
}

.tokens-table td {
  padding: 10px 12px;
}

/* ============================================================================
   BADGE E INDICATORI
   ============================================================================ */

.role-badge {
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.role-admin {
  background-color: #e74c3c;
  color: white;
}

.role-user {
  background-color: #3498db;
  color: white;
}

/* ============================================================================
   AZIONI E PULSANTI
   ============================================================================ */

.action-buttons {
  display: flex;
  gap: 5px;
}

/* ============================================================================
   MODAL
   ============================================================================ */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background-color: white;
  margin: 5% auto;
  padding: 30px;
  border-radius: 15px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.close {
  color: #aaa;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}

.close:hover {
  color: #000;
}

/* ============================================================================
   STATISTICHE
   ============================================================================ */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
  position: relative;
}

.stat-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
}

.stat-number {
  font-size: 2em;
  font-weight: bold;
  margin-bottom: 5px;
}

.stat-label {
  opacity: 0.9;
}

/* ============================================================================
   RICERCA E FILTRI
   ============================================================================ */

.search-bar {
  margin-bottom: 20px;
}

.search-bar input {
  width: 100%;
  padding: 12px;
  border: 2px solid #e1e8ed;
  border-radius: 8px;
  font-size: 16px;
}

/* ============================================================================
   UTILITY
   ============================================================================ */

.hidden {
  display: none;
}

.loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto 20px;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* ============================================================================
   LAYOUT E ORGANIZZAZIONE
   ============================================================================ */

.header-section {
  margin-bottom: 30px;
}

.header-content {
  margin-bottom: 20px;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 768px) {
  .button-group {
    justify-content: center;
  }

  .button-group .btn {
    flex: 1;
    min-width: 140px;
    margin: 5px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .users-table,
  .tokens-table {
    font-size: 12px;
  }

  .users-table th,
  .users-table td,
  .tokens-table th,
  .tokens-table td {
    padding: 8px 6px;
  }
}

@media (max-width: 480px) {
  .button-group {
    flex-direction: column;
  }

  .button-group .btn {
    width: 100%;
    margin: 5px 0;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .users-table,
  .tokens-table {
    font-size: 11px;
  }
}

/* ============================================================================
   MODAL OVERLAY
   ============================================================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  visibility: hidden;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible !important;
}

.modal-overlay .modal {
  background: white !important;
  border-radius: 10px;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  display: block !important;
  position: relative !important;
  z-index: 1001 !important;
  left: auto !important;
  top: auto !important;
  width: auto !important;
  height: auto !important;
  margin: 0 !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-overlay.show .modal {
  transform: scale(1);
}

.modal-header {
  padding: 20px;
  border-bottom: 1px solid #e1e8ed;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #2c3e50;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.3s;
}

.modal-close:hover {
  background-color: #f0f0f0;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 20px;
  border-top: 1px solid #e1e8ed;
  text-align: center;
}

/* ============================================================================
   TOKEN DETAILS
   ============================================================================ */

.token-details {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 4px solid #667eea;
}

.detail-row strong {
  min-width: 120px;
  color: #2c3e50;
  font-weight: 600;
}

.detail-row span {
  flex: 1;
  word-break: break-all;
}

.token-hash {
  font-family: "Courier New", monospace;
  background: #f1f3f4;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 0.9em;
  border: 1px solid #ddd;
}

.user-agent {
  font-size: 0.85em;
  color: #666;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================================
   STILI SPECIFICI PER I LOG
   ============================================================================ */

.logs-container {
  background: #1a1a1a;
  border-radius: 8px;
  padding: 20px;
  margin: 20px 0;
  font-family: "Courier New", monospace;
  font-size: 12px;
  line-height: 1.4;
  max-height: 600px;
  overflow-y: auto;
  border: 1px solid #333;
}

.log-line {
  padding: 2px 0;
  border-bottom: 1px solid #2a2a2a;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.log-line:hover {
  background: #2a2a2a;
}

.log-timestamp {
  color: #888;
  font-weight: bold;
}

.log-level {
  font-weight: bold;
  margin: 0 8px;
}

.log-level.INFO {
  color: #4caf50;
}

.log-level.ERROR {
  color: #f44336;
}

.log-level.WARN {
  color: #ff9800;
}

.log-level.DEBUG {
  color: #2196f3;
}

.log-message {
  color: #fff;
}

.log-worker {
  color: #888;
  font-style: italic;
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 20px 0;
  gap: 10px;
}

.pagination button {
  padding: 8px 16px;
  background: #333;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

.pagination button:hover {
  background: #555;
}

.pagination button:disabled {
  background: #1a1a1a;
  color: #666;
  cursor: not-allowed;
}

.pagination-info {
  color: #888;
  font-size: 14px;
  margin: 0 20px;
}

.logs-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.logs-controls-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logs-controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auto-refresh {
  display: flex;
  align-items: center;
  gap: 8px;
}

.auto-refresh input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.auto-refresh label {
  color: #888;
  font-size: 14px;
}

.error-message {
  background: #f44336;
  color: white;
  padding: 10px;
  border-radius: 4px;
  margin: 10px 0;
}

.filter-controls {
  margin-bottom: 20px;
  padding: 15px;
  background: #2a2a2a;
  border-radius: 8px;
  border: 1px solid #333;
}

.filter-row {
  display: flex;
  gap: 15px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group label {
  font-size: 12px;
  color: #888;
}

.filter-group input,
.filter-group select {
  padding: 5px 8px;
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 4px;
  color: white;
  font-size: 12px;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #4caf50;
}

/* ============================================================================
   STILI SPECIFICI PER LOG API
   ============================================================================ */

/* Stili per i log API */
.log-line.log-request {
  border-left: 4px solid #2196f3;
  background-color: #f8f9ff;
}

.log-line.log-response {
  border-left: 4px solid #4caf50;
  background-color: #f8fff9;
}

.log-line.log-error {
  border-left: 4px solid #f44336;
  background-color: #fff8f8;
}

.log-line.log-warning {
  border-left: 4px solid #ff9800;
  background-color: #fffbf0;
}

/* Header del log API */
.log-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.log-icon {
  font-size: 1.2em;
}

.log-type {
  background: #e3f2fd;
  color: #1976d2;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.8em;
  font-weight: 600;
  text-transform: uppercase;
}

.log-details {
  margin-left: 30px;
}

.log-method-path {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.log-status {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8em;
  font-weight: 600;
  color: white;
}

.status-2xx {
  background-color: #4caf50;
}

.status-3xx {
  background-color: #2196f3;
}

.status-4xx {
  background-color: #ff9800;
}

.status-5xx {
  background-color: #f44336;
}

.log-time {
  background: #f5f5f5;
  color: #666;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8em;
}

.log-ip {
  color: #666;
  font-size: 0.9em;
  margin-bottom: 5px;
}

.log-payload,
.log-response {
  margin-top: 8px;
}

.log-payload pre,
.log-response pre {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 4px;
  padding: 8px;
  margin: 5px 0;
  font-size: 0.85em;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 200px;
  overflow-y: auto;
}

.log-error-msg {
  color: #d32f2f;
  font-weight: 600;
  margin-top: 5px;
}

/* Responsive per log API */
@media (max-width: 768px) {
  .log-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .log-method-path {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .log-details {
    margin-left: 15px;
  }
}
