/* ============================================================
   Gerador de Comunicados — Rede Gaya
   Estilos da Interface (NÃO do HTML gerado)
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: Arial, sans-serif;
  background: #f0f2f5;
  color: #333;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e3f2fd 0%, #f0f2f5 100%);
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 52px 48px;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.10);
  max-width: 400px;
  width: 100%;
}

.login-logo {
  width: 88px;
  height: auto;
  margin-bottom: 24px;
}

.login-card h1 {
  font-size: 22px;
  color: #0d3b8a;
  margin-bottom: 8px;
  font-weight: bold;
}

.login-card .login-subtitle {
  color: #777;
  margin-bottom: 36px;
  font-size: 14px;
  line-height: 1.5;
}

.login-error {
  margin-top: 16px;
  font-size: 13px;
  color: #c62828;
  background: #ffebee;
  border-radius: 6px;
  padding: 10px 14px;
  display: none;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */
#app {
  display: none;
  flex-direction: column;
  height: 100vh;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  background: #1565C0;
  color: #fff;
  padding: 0 20px;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
  z-index: 100;
}

.header-logo {
  height: 34px;
  width: auto;
  border-radius: 4px;
}

.header-title {
  font-size: 17px;
  font-weight: bold;
  flex: 1;
  letter-spacing: 0.2px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  object-fit: cover;
}

.user-name {
  opacity: 0.92;
}

.btn-logout {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
  padding: 5px 13px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.18s;
  font-family: Arial, sans-serif;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.app-main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============================================================
   LEFT PANEL
   ============================================================ */
.left-panel {
  width: 288px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.left-panel-scroll {
  flex: 1;
  overflow-y: auto;
}

.panel-section {
  border-bottom: 1px solid #efefef;
}

.panel-section-header {
  padding: 10px 14px;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #888;
  background: #fafafa;
  border-bottom: 1px solid #efefef;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Settings */
.settings-form {
  padding: 12px 14px;
}

.form-group {
  margin-bottom: 11px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 11px;
  color: #666;
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  color: #333;
  outline: none;
  transition: border-color 0.18s;
  font-family: Arial, sans-serif;
  background: #fff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #1565C0;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.10);
}

.form-group input[type="checkbox"] {
  margin-right: 6px;
  accent-color: #1565C0;
}

.form-group input[type="color"] {
  width: 44px;
  height: 32px;
  padding: 2px 3px;
  border: 1px solid #ddd;
  border-radius: 5px;
  cursor: pointer;
  vertical-align: middle;
}

.prop-row {
  display: flex;
  gap: 8px;
}

.prop-row .form-group {
  flex: 1;
}

/* Component Palette */
.component-palette {
  padding: 10px 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.palette-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 6px;
  background: #f8f9fa;
  border: 1px solid #e3e3e3;
  border-radius: 7px;
  cursor: grab;
  font-size: 11px;
  color: #555;
  text-align: center;
  transition: all 0.14s;
  user-select: none;
  -webkit-user-drag: element;
}

.palette-item:hover {
  background: #e3f2fd;
  border-color: #1565C0;
  color: #0d47a1;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(46, 125, 50, 0.12);
}

.palette-item:active {
  cursor: grabbing;
  transform: translateY(0);
}

.palette-icon {
  font-size: 18px;
  line-height: 1;
  font-weight: bold;
  color: #1565C0;
}

/* Properties Panel */
.properties-panel-content {
  padding: 12px 14px;
}

.no-selection {
  color: #bbb;
  font-size: 12px;
  text-align: center;
  padding: 18px 14px;
  line-height: 1.5;
}

.props-tip {
  font-size: 11px;
  color: #aaa;
  line-height: 1.5;
  margin-bottom: 10px;
  padding: 7px 9px;
  background: #f9f9f9;
  border-radius: 5px;
  border-left: 3px solid #e0e0e0;
}

/* Generate Section */
.generate-section {
  padding: 14px;
  border-top: 1px solid #eee;
  background: #fff;
  flex-shrink: 0;
}

.btn-generate {
  width: 100%;
  padding: 11px;
  background: #1565C0;
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.18s;
  font-family: Arial, sans-serif;
  letter-spacing: 0.2px;
}

.btn-generate:hover {
  background: #0d47a1;
}

.btn-generate:disabled {
  background: #9e9e9e;
  cursor: not-allowed;
}

/* ============================================================
   RIGHT PANEL (PREVIEW)
   ============================================================ */
.right-panel {
  flex: 1;
  background: #e8eaed;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.preview-label {
  font-size: 10px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  margin-bottom: 14px;
  align-self: center;
}

.preview-container {
  width: 680px;
  background: #fff;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.12);
  border-radius: 3px;
  min-height: 420px;
  margin-bottom: 32px;
}

.preview-inner {
  padding: 32px 32px 16px;
  min-height: 300px;
}

.preview-footer {
  border-top: 1px solid #e0e0e0;
  padding: 16px;
  text-align: center;
}

.preview-footer img {
  max-width: 120px;
  height: auto;
}

/* Empty state */
.preview-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 56px 32px;
  color: #ccc;
  gap: 12px;
  pointer-events: none;
}

.preview-empty-icon {
  font-size: 44px;
  opacity: 0.5;
}

.preview-empty p {
  font-size: 13px;
  text-align: center;
  line-height: 1.6;
}

/* ============================================================
   COMPONENT WRAPPER
   ============================================================ */
.preview-component {
  position: relative;
  margin-bottom: 2px;
  border-radius: 3px;
  transition: outline 0.1s;
}

.preview-component.selected {
  outline: 2px solid #1565C0;
  outline-offset: 2px;
}

.preview-component:hover:not(.selected) {
  outline: 1px dashed #90caf9;
  outline-offset: 2px;
}

.component-controls {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 1px;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 20;
  background: #fff;
  border-radius: 0 3px 0 5px;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.14);
  overflow: hidden;
}

.preview-component:hover .component-controls,
.preview-component.selected .component-controls {
  opacity: 1;
}

.component-controls button {
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: #777;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, color 0.1s;
  font-family: Arial, sans-serif;
}

.component-controls button:hover {
  background: #f5f5f5;
  color: #333;
}

.component-controls .btn-ctrl-delete:hover {
  background: #ffebee;
  color: #c62828;
}

/* Drop zones */
.drop-zone {
  height: 5px;
  border-radius: 3px;
  transition: height 0.12s, background 0.12s;
  position: relative;
}

.drop-zone.drag-over {
  height: 36px;
  background: #e3f2fd;
  border: 2px dashed #42a5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #1976d2;
}

/* ============================================================
   INLINE PREVIEW ELEMENTS
   ============================================================ */
[contenteditable] {
  outline: none;
  min-height: 1em;
  cursor: text;
}

[contenteditable]:focus {
  background: rgba(46, 125, 50, 0.04);
  border-radius: 2px;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
}

.preview-table td,
.preview-table th {
  border: 1px solid #ddd;
  padding: 7px 10px;
  min-width: 50px;
  outline: none;
}

.preview-table th {
  background: #f5f5f5;
  font-weight: bold;
}

.preview-image-placeholder {
  border: 2px dashed #ddd;
  border-radius: 8px;
  padding: 28px;
  text-align: center;
  color: #bbb;
  cursor: pointer;
  background: #fafafa;
  transition: all 0.15s;
}

.preview-image-placeholder:hover {
  border-color: #1565C0;
  background: #e8f4ff;
  color: #1565C0;
}

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border-radius: 12px;
  padding: 26px;
  width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.20);
  position: relative;
}

.modal-sm {
  width: 380px;
}

.modal-lg {
  width: 700px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f0f0f0;
}

.modal-title {
  font-size: 17px;
  font-weight: bold;
  color: #1a1a1a;
}

.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #aaa;
  cursor: pointer;
  padding: 3px 7px;
  border-radius: 5px;
  line-height: 1;
  transition: all 0.14s;
  font-family: Arial, sans-serif;
}

.modal-close:hover {
  background: #f5f5f5;
  color: #444;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.modal-note {
  font-size: 12px;
  color: #888;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* Buttons */
.btn {
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  font-family: Arial, sans-serif;
  font-weight: 500;
}

.btn-primary {
  background: #1565C0;
  color: #fff;
  border-color: #1565C0;
}

.btn-primary:hover {
  background: #0d47a1;
}

.btn-primary:disabled {
  background: #9e9e9e;
  border-color: #9e9e9e;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: #444;
  border-color: #ddd;
}

.btn-secondary:hover {
  background: #f5f5f5;
}

.btn-danger {
  background: #fff;
  color: #c62828;
  border-color: #ef9a9a;
}

.btn-danger:hover {
  background: #ffebee;
}

.btn-block {
  width: 100%;
  text-align: center;
  margin-bottom: 6px;
}

/* Image upload */
.image-upload-area {
  border: 2px dashed #d0d0d0;
  border-radius: 8px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.18s;
  color: #aaa;
  font-size: 13px;
  margin-bottom: 12px;
}

.image-upload-area:hover {
  border-color: #1565C0;
  background: #f0f7ff;
  color: #1565C0;
}

.image-upload-area.has-file {
  border-style: solid;
  border-color: #90caf9;
  background: #f0f7ff;
}

.image-upload-icon {
  font-size: 30px;
  margin-bottom: 8px;
}

.image-upload-hint {
  font-size: 11px;
  color: #bbb;
  margin-top: 5px;
}

.image-preview-thumb {
  max-width: 100%;
  max-height: 180px;
  border-radius: 6px;
  margin: 0 auto 12px;
  display: block;
  border: 1px solid #e0e0e0;
}

/* HTML Output */
.html-output {
  width: 100%;
  height: 320px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  border: 1px solid #e0e0e0;
  border-radius: 7px;
  padding: 12px;
  resize: vertical;
  background: #f8f9fa;
  color: #333;
  line-height: 1.5;
  outline: none;
}

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.18);
  animation: toastSlideIn 0.22s ease;
  display: flex;
  align-items: center;
  gap: 9px;
  max-width: 320px;
  pointer-events: auto;
}

.toast-success { background: #1565C0; }
.toast-error   { background: #c62828; }
.toast-info    { background: #1565c0; }

.toast-icon {
  font-size: 15px;
  flex-shrink: 0;
}

@keyframes toastSlideIn {
  from { transform: translateX(60px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   SCROLLBAR STYLING
   ============================================================ */
.left-panel-scroll::-webkit-scrollbar,
.right-panel::-webkit-scrollbar {
  width: 5px;
}

.left-panel-scroll::-webkit-scrollbar-track,
.right-panel::-webkit-scrollbar-track {
  background: transparent;
}

.left-panel-scroll::-webkit-scrollbar-thumb,
.right-panel::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

.left-panel-scroll::-webkit-scrollbar-thumb:hover,
.right-panel::-webkit-scrollbar-thumb:hover {
  background: #aaa;
}

/* ============================================================
   MOBILE TABS
   ============================================================ */
.mobile-tabs {
  display: none;
}

/* ============================================================
   RESPONSIVIDADE — MOBILE (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {

  body {
    height: auto;
    overflow: auto;
  }

  /* Header compacto */
  .app-header {
    height: 48px;
    padding: 0 12px;
    gap: 10px;
  }

  .header-logo {
    height: 28px;
  }

  .header-title {
    font-size: 14px;
  }

  .user-name {
    display: none;
  }

  .user-avatar {
    width: 26px;
    height: 26px;
  }

  .btn-logout {
    padding: 4px 10px;
    font-size: 11px;
  }

  /* App altura dinâmica */
  #app {
    height: 100%;
    min-height: 100vh;
  }

  /* Tab bar */
  .mobile-tabs {
    display: flex;
    background: #fff;
    border-bottom: 2px solid #e0e0e0;
    flex-shrink: 0;
  }

  .mobile-tab {
    flex: 1;
    padding: 12px 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
    font-family: Arial, sans-serif;
  }

  .mobile-tab.active {
    color: #1565C0;
    border-bottom-color: #1565C0;
  }

  /* Layout principal em coluna */
  .app-main {
    flex-direction: column;
    overflow: auto;
    height: auto;
  }

  /* Left panel: largura total, visível/oculto via tab */
  .left-panel {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #e0e0e0;
    max-height: none;
    overflow: visible;
  }

  .left-panel.tab-hidden {
    display: none;
  }

  .left-panel-scroll {
    overflow: visible;
  }

  /* Paleta em 3 colunas no mobile */
  .component-palette {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
    padding: 8px;
  }

  .palette-item {
    padding: 8px 4px;
    font-size: 10px;
  }

  .palette-icon {
    font-size: 16px;
  }

  /* Botão Gerar */
  .generate-section {
    padding: 10px 12px;
  }

  /* Right panel: largura total */
  .right-panel {
    flex: none;
    width: 100%;
    padding: 12px 8px;
    overflow: visible;
  }

  .right-panel.tab-hidden {
    display: none;
  }

  /* Preview se adapta à largura da tela */
  .preview-container {
    width: 100%;
    max-width: 100%;
  }

  .preview-inner {
    padding: 16px 14px 10px;
  }

  .preview-footer {
    padding: 10px;
  }

  /* Modais fullscreen no mobile */
  .modal-overlay {
    align-items: flex-end;
  }

  .modal,
  .modal.modal-sm,
  .modal.modal-lg {
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    margin: 0;
  }

  /* HTML output menor */
  .html-output {
    height: 220px;
    font-size: 10px;
  }

  /* Toast na parte de baixo centralizado */
  .toast-container {
    bottom: 12px;
    right: 8px;
    left: 8px;
    align-items: center;
  }

  .toast {
    max-width: 100%;
    justify-content: center;
  }
}

/* ============================================================
   RESPONSIVIDADE — TABLET (max-width: 1024px)
   ============================================================ */
@media (max-width: 1024px) and (min-width: 769px) {
  .left-panel {
    width: 240px;
  }

  .component-palette {
    grid-template-columns: 1fr 1fr;
  }

  .preview-container {
    width: 100%;
    max-width: 100%;
  }
}
