/* Reset */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #fafafa;
  color: #333;
  font-size: 16px;
}

/* Previne zoom em inputs no iOS */
input, textarea, select, button {
  font-size: 16px !important;
}

/* Login Screen */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.login-box {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-box input {
  width: 280px;
  padding: 14px 50px 14px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  background: #fafafa;
  transition: border-color 0.2s;
}

.login-box input:focus {
  outline: none;
  border-color: #666;
}

.toggle-password {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  opacity: 0.5;
}

.toggle-password:hover {
  opacity: 1;
}

.error-message {
  color: #dc3545;
  font-size: 13px;
  min-height: 18px;
}

/* Main App Layout */
.main-app {
  display: flex;
  height: 100vh;
}

.main-app.hidden {
  display: none;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: #1a1a1a;
  color: #999;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid #333;
}

.logo {
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  letter-spacing: -0.5px;
}

.btn-new {
  width: 28px;
  height: 28px;
  background: #333;
  border: none;
  border-radius: 6px;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-new:hover {
  background: #444;
}

.sidebar-search {
  padding: 12px 16px;
}

.sidebar-search input {
  width: 100%;
  padding: 8px 12px;
  background: #2a2a2a;
  border: 1px solid #333;
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
}

.sidebar-search input::placeholder {
  color: #666;
}

.sidebar-search input:focus {
  outline: none;
  border-color: #555;
}

.pages-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.page-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 14px;
}

.page-item:hover {
  background: #2a2a2a;
}

.page-item.active {
  background: #333;
  color: #fff;
}

.page-item .page-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-item .page-delete {
  opacity: 0;
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.page-item:hover .page-delete {
  opacity: 1;
}

.page-item .page-delete:hover {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid #333;
}

.btn-logout {
  width: 100%;
  padding: 8px;
  background: transparent;
  border: 1px solid #333;
  border-radius: 6px;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #333;
  color: #fff;
}

/* Content Area */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #333;
  padding: 4px;
}

.topbar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 6px;
  font-size: 15px;
  background: #fafafa;
  min-width: 0;
}

.topbar input:focus {
  outline: none;
  border-color: #ccc;
  background: #fff;
}

.btn-save {
  width: 36px;
  height: 36px;
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-save:hover {
  background: #f0f0f0;
}

.btn-save:active {
  transform: scale(0.95);
}

/* Botão Copiar Tudo no topo - SEMPRE visível */
.btn-copy-top {
  padding: 10px 18px;
  background: #667eea;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  white-space: nowrap;
}

.btn-copy-top:hover {
  background: #5568d3;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-copy-top:active {
  transform: scale(0.98);
}

.editor-wrapper {
  flex: 1;
  display: flex;
  overflow: hidden;
}

textarea {
  width: 100%;
  height: 100%;
  padding: 20px;
  border: none;
  resize: none;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Fira Code', monospace;
  font-size: 14px;
  line-height: 1.6;
  background: #fff;
  color: #333;
}

textarea:focus {
  outline: none;
}

textarea::placeholder {
  color: #bbb;
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eee;
  font-size: 13px;
  color: #999;
}

.statusbar .success {
  color: #28a745;
}

.statusbar .error {
  color: #dc3545;
}

/* Scrollbar */
.pages-list::-webkit-scrollbar {
  width: 6px;
}

.pages-list::-webkit-scrollbar-track {
  background: transparent;
}

.pages-list::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

/* Mobile */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -240px;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.25s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
    display: none;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  .menu-toggle {
    display: block;
  }

  .topbar {
    padding: 10px 12px;
    gap: 8px;
  }

  .topbar input {
    font-size: 15px;
  }

  .btn-save {
    width: 34px;
    height: 34px;
    font-size: 14px;
  }

  .btn-copy-top {
    padding: 10px 16px;
    font-size: 13px;
  }

  textarea {
    padding: 16px;
    font-size: 14px;
  }

  .statusbar {
    gap: 8px;
    padding: 10px 16px;
  }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
}

/* Desktop */
@media (min-width: 1025px) {
  .sidebar {
    width: 260px;
  }
}

/* Large Desktop */
@media (min-width: 1400px) {
  .sidebar {
    width: 300px;
  }
}
