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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  margin: 0;
}

/* ===== MAIN CONTAINER ===== */
.app-container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.main-card {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  border-radius: 32px;
  padding: 35px 40px 40px 40px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* ===== HEADER ===== */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 2.2rem;
}

.logo h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #2d3748;
  letter-spacing: -0.5px;
}

.tagline {
  font-size: 0.75rem;
  color: #718096;
  font-weight: 400;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: #f7fafc;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.3s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.icon-btn:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px);
}

.badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #fc8181;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* ===== STATUS BAR ===== */
.status-bar {
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.connected {
  background: #48bb78;
}
.status-dot.error {
  background: #fc8181;
}
.status-dot.loading {
  background: #ed8936;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.status-text {
  font-size: 0.85rem;
  color: #4a5568;
}

/* ===== INPUT SECTION ===== */
.analyzer-section {
  margin-bottom: 20px;
}

.input-wrapper {
  background: #f7fafc;
  border-radius: 14px;
  padding: 18px 20px 16px 20px;
  border: 2px solid #e2e8f0;
  transition: all 0.3s;
  margin-bottom: 14px;
}

.input-wrapper:focus-within {
  border-color: #667eea;
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15);
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.input-label {
  font-weight: 600;
  color: #2d3748;
  font-size: 0.85rem;
}

.char-count {
  font-size: 0.7rem;
  color: #a0aec0;
}

textarea {
  width: 100%;
  height: 140px;
  padding: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1rem;
  font-family: inherit;
  color: #2d3748;
  resize: vertical;
  line-height: 1.6;
}

textarea::placeholder {
  color: #a0aec0;
}

.input-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

.input-shortcut {
  font-size: 0.7rem;
  color: #a0aec0;
}

kbd {
  padding: 2px 8px;
  background: white;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 600;
  border: 1px solid #e2e8f0;
}

/* ===== BUTTONS ===== */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  flex: 1;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  background: #f7fafc;
  color: #4a5568;
  border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
  background: #e2e8f0;
  transform: translateY(-2px);
}

.btn-outline {
  background: transparent;
  color: #2d3748;
  border: 2px solid #e2e8f0;
}

.btn-outline:hover {
  background: #f7fafc;
  transform: translateY(-2px);
}

.btn-sm {
  padding: 5px 12px;
  font-size: 0.75rem;
}

.btn-danger {
  background: #fc8181;
  color: white;
}

.btn-danger:hover {
  background: #f56565;
  transform: translateY(-2px);
}

.button-group {
  display: flex;
  gap: 10px;
}

.button-group .btn {
  flex: 1;
}

/* ===== RESULTS ===== */
.result-container {
  margin-top: 20px;
  padding: 20px 22px 22px 22px;
  border-radius: 14px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.result-header h2 {
  font-size: 1.2rem;
  color: #2d3748;
  font-weight: 700;
}

.result-actions {
  display: flex;
  gap: 6px;
}

/* ===== GAUGE ===== */
.gauge-container {
  display: flex;
  gap: 25px;
  align-items: center;
  background: white;
  border-radius: 14px;
  padding: 20px 25px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  justify-content: center;
}

.gauge-wrapper {
  position: relative;
  width: 120px;
  height: 120px;
}

.gauge {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.gauge-bg {
  fill: none;
  stroke: #f7fafc;
  stroke-width: 8;
}

.gauge-progress {
  fill: none;
  stroke: #48bb78;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dasharray 1s cubic-bezier(0.4, 0, 0.2, 1), stroke 1s ease;
}

.gauge-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.gauge-score {
  font-size: 2.2rem;
  font-weight: 800;
  color: #2d3748;
  display: block;
  line-height: 1;
}

.gauge-label {
  font-size: 0.65rem;
  color: #a0aec0;
  font-weight: 500;
  display: block;
  margin-top: 3px;
}

.risk-level-container {
  flex: 1;
  min-width: 180px;
}

.risk-level {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  margin-bottom: 10px;
  padding: 6px 16px;
  border-radius: 10px;
  display: inline-block;
  width: 100%;
}

.risk-level.Safe { color: #48bb78; }
.risk-level.Low { color: #68d391; }
.risk-level.Medium { color: #ed8936; }
.risk-level.High { color: #ed8936; }
.risk-level.Critical { color: #fc8181; }

.risk-level-bar {
  height: 6px;
  background: #f7fafc;
  border-radius: 3px;
  overflow: hidden;
  margin: 6px 0;
}

.risk-level-fill {
  height: 100%;
  background: linear-gradient(90deg, #48bb78, #68d391, #ed8936, #ed8936, #fc8181);
  border-radius: 3px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.risk-level-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.55rem;
  color: #a0aec0;
}

/* ===== DETAIL CARDS ===== */
.details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.detail-card {
  background: white;
  border-radius: 10px;
  padding: 16px 18px;
  border: 1px solid #e2e8f0;
}

.detail-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.detail-icon {
  font-size: 1.1rem;
}

.detail-card h3 {
  font-size: 0.85rem;
  color: #2d3748;
  font-weight: 600;
}

.detail-list {
  list-style: none;
  padding: 0;
}

.detail-list li {
  padding: 4px 0;
  color: #4a5568;
  font-size: 0.85rem;
  line-height: 1.5;
  padding-left: 18px;
  position: relative;
}

.detail-list li::before {
  position: absolute;
  left: 0;
  top: 4px;
}

.detail-card:first-child .detail-list li::before {
  content: "⚠️";
}

.detail-card:last-child .detail-list li::before {
  content: "✅";
}

/* ===== METADATA ===== */
.metadata {
  padding: 10px 16px;
  background: white;
  border-radius: 8px;
  font-size: 0.7rem;
  color: #a0aec0;
  text-align: right;
  border: 1px solid #e2e8f0;
}

/* ===== QUICK STATS ===== */
.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid #e2e8f0;
}

.stat-item {
  text-align: center;
  padding: 12px;
  background: white;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

.stat-value {
  font-size: 1.3rem;
  font-weight: 700;
  color: #2d3748;
  display: block;
}

.stat-label {
  font-size: 0.65rem;
  color: #a0aec0;
  font-weight: 500;
}

/* ===== MODALS ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: white;
  border-radius: 24px;
  padding: 28px 30px 30px 30px;
  max-width: 550px;
  width: 92%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.2rem;
  color: #2d3748;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: #a0aec0;
  cursor: pointer;
  padding: 0 8px;
  transition: all 0.3s;
}

.close-btn:hover {
  color: #2d3748;
  transform: rotate(90deg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* ===== HISTORY ===== */
.history-list {
  max-height: 350px;
  overflow-y: auto;
}

.history-item {
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
}

.history-item .h-date {
  font-size: 0.65rem;
  color: #a0aec0;
}

.history-item .h-score {
  font-weight: 700;
  font-size: 1rem;
}

.history-item .h-message {
  margin-top: 3px;
  color: #4a5568;
  font-size: 0.8rem;
}

.empty-history {
  text-align: center;
  color: #a0aec0;
  padding: 30px;
}

/* ===== SHARE ===== */
.share-preview {
  background: #f7fafc;
  padding: 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
}

.share-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.share-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  color: white;
  font-size: 0.85rem;
}

.share-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.share-btn.email { background: #34a853; }
.share-btn.whatsapp { background: #25d366; }
.share-btn.twitter { background: #1da1f2; }
.share-btn.copy { background: #667eea; }

/* ===== DARK THEME ===== */
[data-theme="dark"] .main-card {
  background: rgba(26, 32, 44, 0.92);
}

[data-theme="dark"] .logo h1 {
  color: #e2e8f0;
}

[data-theme="dark"] .input-wrapper {
  background: #2d3748;
  border-color: #4a5568;
}

[data-theme="dark"] textarea {
  color: #e2e8f0;
}

[data-theme="dark"] .status-bar {
  background: #2d3748;
  border-color: #4a5568;
}

[data-theme="dark"] .status-text {
  color: #a0aec0;
}

[data-theme="dark"] .result-container {
  background: #2d3748;
  border-color: #4a5568;
}

[data-theme="dark"] .result-header h2 {
  color: #e2e8f0;
}

[data-theme="dark"] .detail-card {
  background: #2d3748;
  border-color: #4a5568;
}

[data-theme="dark"] .detail-card h3 {
  color: #e2e8f0;
}

[data-theme="dark"] .detail-list li {
  color: #a0aec0;
}

[data-theme="dark"] .gauge-container {
  background: #2d3748;
}

[data-theme="dark"] .risk-level-bar {
  background: #1a202c;
}

[data-theme="dark"] .stat-item {
  background: #2d3748;
  border-color: #4a5568;
}

[data-theme="dark"] .stat-value {
  color: #e2e8f0;
}

[data-theme="dark"] .modal-content {
  background: #2d3748;
}

[data-theme="dark"] .modal-header h2 {
  color: #e2e8f0;
}

[data-theme="dark"] .history-item {
  background: #1a202c;
  border-color: #4a5568;
}

[data-theme="dark"] .share-preview {
  background: #1a202c;
}

[data-theme="dark"] .metadata {
  background: #2d3748;
  border-color: #4a5568;
  color: #718096;
}

[data-theme="dark"] .icon-btn {
  background: #2d3748;
  color: #e2e8f0;
}

[data-theme="dark"] .icon-btn:hover {
  background: #667eea;
  color: white;
}

[data-theme="dark"] .btn-secondary {
  background: #2d3748;
  color: #a0aec0;
  border-color: #4a5568;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .main-card {
    padding: 20px;
    border-radius: 20px;
  }

  .logo h1 {
    font-size: 1.3rem;
  }

  .details-grid {
    grid-template-columns: 1fr;
  }

  .gauge-container {
    flex-direction: column;
    padding: 16px;
  }

  .button-group {
    flex-direction: column;
  }

  .button-group .btn {
    flex: none;
    width: 100%;
  }

  .quick-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .header {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .result-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .result-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .modal-content {
    padding: 18px;
    width: 95%;
  }
}

@media (max-width: 480px) {
  .main-card {
    padding: 14px;
  }

  .gauge-wrapper {
    width: 100px;
    height: 100px;
  }

  .gauge-score {
    font-size: 1.8rem;
  }

  .risk-level {
    font-size: 1.2rem;
  }

  .stat-value {
    font-size: 1rem;
  }

  textarea {
    height: 100px;
  }
}

/* ===== UTILITY ===== */
.hidden {
  display: none !important;
}

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