/* ====================================
   KYO LICENSE MANAGER - STYLES V2
   Design: Professional + Mobile-First
   ==================================== */

/* Reset e Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Cores principais */
  --color-primary: #0c0c0c;
  --color-primary-light: #2d2d2d;
  --color-secondary: #6366f1;
  --color-accent: #10b981;
  
  /* Background */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-hover: #e2e8f0;
  
  /* Borders */
  --border-color: #e2e8f0;
  --border-color-dark: #cbd5e1;
  
  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  
  /* Status colors */
  --status-active: #10b981;
  --status-blocked: #f59e0b;
  --status-black: #ef4444;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
  
  /* Border radius */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Spacing responsivo */
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

/* Inputs e Buttons - MOBILE FIRST */
input, select, button, textarea {
  font-family: inherit;
  font-size: 16px; /* Previne zoom no iOS */
}

input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  background: var(--bg-primary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--color-secondary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

button {
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  white-space: nowrap;
  font-size: 14px;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: scale(0.98);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Button variants */
.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-light);
}

.btn-secondary {
  background: var(--color-secondary);
  color: white;
}

.btn-secondary:hover:not(:disabled) {
  background: #5558e3;
}

.btn-success {
  background: var(--status-active);
  color: white;
}

.btn-warning {
  background: var(--status-blocked);
  color: white;
}

.btn-danger {
  background: var(--status-black);
  color: white;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-color-dark);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color-dark);
  border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Animations */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.spin { animation: spin 1s linear infinite; }
.fade-in { animation: fadeIn 0.3s ease-out; }
.slide-in { animation: slideIn 0.3s ease-out; }
.scale-in { animation: scaleIn 0.2s ease-out; }

/* Cards */
.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.badge-active {
  background: rgba(16, 185, 129, 0.1);
  color: var(--status-active);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-blocked {
  background: rgba(245, 158, 11, 0.1);
  color: var(--status-blocked);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-black {
  background: rgba(239, 68, 68, 0.1);
  color: var(--status-black);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Stats Cards - RESPONSIVO */
.stat-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.stat-card-active { border-left: 4px solid var(--status-active); }
.stat-card-blocked { border-left: 4px solid var(--status-blocked); }
.stat-card-black { border-left: 4px solid var(--status-black); }
.stat-card-total { border-left: 4px solid var(--color-secondary); }

/* Table - MOBILE RESPONSIVE */
.table-container {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 800px; /* Permite scroll horizontal em mobile */
}

thead tr {
  background: var(--bg-tertiary);
  border-bottom: 2px solid var(--border-color);
}

thead th {
  padding: 12px 10px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-color);
}

tbody tr:hover {
  background: var(--bg-secondary);
}

tbody td {
  padding: 12px 10px;
  font-size: 13px;
  color: var(--text-primary);
}

/* License Code */
.license-code {
  background: var(--bg-tertiary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 11px;
  color: var(--color-primary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-block;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.license-code:hover {
  background: var(--bg-hover);
  border-color: var(--color-secondary);
}

/* Modal - MOBILE FRIENDLY */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: var(--spacing-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  margin: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 18px;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Detail Rows - MOBILE STACK */
.detail-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  font-size: 13px;
  border: 1px solid var(--border-color);
}

.detail-label {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
}

.detail-value {
  color: var(--text-primary);
  font-weight: 500;
  word-break: break-all;
}

.detail-value-mono {
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 12px;
}

/* History Box */
.history-box {
  margin-top: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

.history-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-sm);
  display: flex;
  align-items: center;
  gap: 8px;
}

.history-item {
  padding: 10px;
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  font-size: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border-color);
  margin-bottom: 6px;
  word-break: break-all;
}

.history-item:last-child {
  margin-bottom: 0;
}

.history-badge {
  background: var(--bg-tertiary);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}

/* Notifications - MOBILE POSITION */
.notification-container {
  position: fixed;
  top: 16px;
  right: 16px;
  left: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.notification {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.notification-success {
  border-left: 4px solid var(--status-active);
}

.notification-error {
  border-left: 4px solid var(--status-black);
}

.notification-info {
  border-left: 4px solid var(--color-secondary);
}

.notification-icon {
  font-size: 18px;
  font-weight: bold;
  flex-shrink: 0;
}

.notification-message {
  flex: 1;
  font-size: 13px;
  color: var(--text-primary);
  font-weight: 500;
}

/* Pagination - MOBILE FRIENDLY */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: var(--spacing-md);
}

.pagination-btn {
  padding: 8px 12px;
  min-width: 36px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 13px;
}

.pagination-btn-active {
  background: var(--color-primary);
  color: white;
}

.pagination-ellipsis {
  color: var(--text-muted);
  padding: 0 4px;
}

/* Login Page */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #f7f7f7;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-primary);
  border-radius: var(--radius-xl);
  padding: var(--spacing-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border-color);
}

.login-logo {
  width: 70px;
  height: 70px;
  margin: 0 auto var(--spacing-md);
  background: #000000;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 10px;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: 6px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.form-group {
  margin-bottom: var(--spacing-md);
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.error-message {
  padding: 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  color: var(--status-black);
  font-size: 12px;
  text-align: center;
  margin-bottom: var(--spacing-md);
}

/* Header - MOBILE STACK */
.header {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.header-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.header-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.user-badge {
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 12px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

/* Search and Filter Bar - MOBILE STACK */
.search-bar {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  box-shadow: var(--shadow-sm);
}

.search-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Footer Info */
.footer-info {
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm);
  text-align: center;
  font-size: 12px;
  color: var(--text-secondary);
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
}

.footer-highlight {
  color: var(--text-primary);
  font-weight: 700;
}

/* ============================================
   RESPONSIVE - TABLET E DESKTOP
   ============================================ */

@media (min-width: 640px) {
  .notification-container {
    right: 20px;
    left: auto;
    max-width: 400px;
  }
  
  .login-logo {
    width: 80px;
    height: 80px;
    padding: 12px;
  }
  
  .login-title {
    font-size: 28px;
  }
  
  .card {
    padding: var(--spacing-lg);
  }
  
  .stat-card {
    padding: var(--spacing-lg);
  }
}

@media (min-width: 768px) {
  .header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }
  
  .header-title {
    font-size: 28px;
  }
  
  .header-subtitle {
    font-size: 14px;
  }
  
  .search-controls {
    flex-direction: row;
  }
  
  .detail-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
  
  .detail-label {
    font-size: 13px;
    min-width: 140px;
  }
  
  .detail-value {
    text-align: right;
  }
  
  .license-code {
    max-width: 200px;
    font-size: 12px;
  }
  
  .user-badge {
    max-width: none;
  }
}

@media (min-width: 1024px) {
  .header-title {
    font-size: 32px;
  }
  
  .modal-content {
    padding: var(--spacing-xl);
  }
  
  thead th {
    font-size: 11px;
    padding: 16px 12px;
  }
  
  tbody td {
    font-size: 14px;
    padding: 16px 12px;
  }
  
  .card:hover {
    box-shadow: var(--shadow-md);
  }
  
  .stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
  }
  
  button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
  }
}

/* ============================================
   GENERATOR SECTION - MOBILE RESPONSIVE
   ============================================ */

/* Grid do gerador - mobile first */
.generator-grid {
  display: grid;
  
  gap: 16px;
}

/* Formulário do gerador */
.generator-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Grid de 2 colunas (tema e tipo) - mobile stack */
.generator-grid-2 {
  display: grid;
  
  gap: 14px;
}

/* Output box do gerador */
.generator-output {
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-family: 'Monaco', 'Courier New', monospace;
  font-size: 13px;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
}

/* Placeholder quando vazio */
.generator-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  text-align: center;
  padding: 20px;
  background: var(--bg-secondary);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-muted);
}

.generator-placeholder-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}

.generator-placeholder-text {
  font-size: 13px;
}

/* Info box */
.generator-info-box {
  padding: 12px;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: var(--radius-md);
  text-align: center;
  font-size: 13px;
  color: var(--color-secondary);
}

/* Success message */
.generator-success {
  margin-top: 14px;
  padding: 12px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-md);
  color: var(--status-active);
  font-size: 13px;
  text-align: center;
}

/* Checkbox container */
.generator-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.generator-checkbox input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.generator-checkbox label {
  margin: 0;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-primary);
  flex: 1;
}

/* Botão de copiar */
.generator-copy-btn {
  width: 100%;
  margin-top: 14px;
}

/* ============================================
   RESPONSIVE - GENERATOR TABLET/DESKTOP
   ============================================ */

@media (min-width: 768px) {
  /* 2 colunas em tablet+ */
  .generator-grid {
    #grid-template-columns: 1fr 1fr;
    gap: 20px;
  }
  
  /* Grid de 2 colunas (tema e tipo) */
  .generator-grid-2 {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
  
  .generator-form {
    gap: 16px;
  }
  
  .generator-output {
    font-size: 14px;
    padding: 20px;
  }
  
  .generator-info-box {
    font-size: 14px;
  }
  
  .generator-checkbox label {
    font-size: 14px;
  }
}

@media (min-width: 1024px) {
  .generator-grid {
    gap: 24px;
  }
}

/* Ajustes para telas muito pequenas */
@media (max-width: 360px) {
  .card {
    padding: 12px;
  }
  
  .generator-form {
    gap: 12px;
  }
  
  .generator-output {
    font-size: 12px;
    padding: 12px;
  }
  
  input, select, textarea {
    padding: 12px 14px;
    font-size: 15px;
  }
  
  button {
    padding: 10px 16px;
    font-size: 13px;
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.w-full { width: 100%; }
.text-center { text-align: center; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

/* Print styles */
@media print {
  .header-actions,
  .search-bar,
  .pagination,
  .notification-container {
    display: none;
  }
}