/* ================================================
   Braxil v2 — Sistema Desktop UI
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=DM+Mono:wght@400;500&display=swap');

:root {
  /* Paleta Braxil */
  --green-50:  #f0faf4;
  --green-100: #dcf3e5;
  --green-200: #afe0c0;
  --green-400: #52b872;
  --green-500: #3aa85a;
  --green-600: #2e8f4a;
  --green-700: #216b37;
  --green-800: #174d28;
  --green-900: #0d3018;

  --gray-50:  #f8f8f6;
  --gray-100: #f0efec;
  --gray-200: #e0dfd9;
  --gray-300: #c8c7c0;
  --gray-400: #a09f98;
  --gray-500: #76756e;
  --gray-600: #555450;
  --gray-700: #3a3937;
  --gray-800: #252422;
  --gray-900: #141413;

  /* Navbar */
  --navbar-bg:     #1d3d2a;
  --navbar-height: 42px;

  /* Janelas */
  --win-bg:        #ffffff;
  --win-titlebar:  #2e6644;
  --win-titlebar-text: #ffffff;
  --win-border:    rgba(0,0,0,0.12);
  --win-shadow:    0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.10);
  --win-radius:    8px;

  /* Tabela (janela maximizada) */
  --tab-bg:        #f2f2f0;
  --tab-active:    #ffffff;

  /* Tipografia */
  --font-ui:   'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--gray-800);
  background: var(--gray-100);
  -webkit-font-smoothing: antialiased;
}

/* ================================================
   NAVBAR
   ================================================ */
#navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--navbar-height);
  background: var(--navbar-bg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  z-index: 9000;
  gap: 4px;
  user-select: none;
}

#navbar .brand {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  padding: 4px 10px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.01em;
  transition: background 0.15s;
}
#navbar .brand:hover { background: rgba(255,255,255,0.1); }
#navbar .brand .dot {
  width: 7px; height: 7px;
  background: var(--green-400);
  border-radius: 50%;
  display: inline-block;
}

/* Menu itens */
.nav-menu-item {
  position: relative;
}
.nav-menu-btn {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 400;
  color: rgba(255,255,255,0.82);
  background: none;
  border: none;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.nav-menu-btn:hover,
.nav-menu-btn.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.nav-menu-btn svg { opacity: 0.7; transition: transform 0.2s; }
.nav-menu-btn.active svg { transform: rotate(180deg); opacity: 1; }

/* Dropdown */
.nav-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 210px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
  padding: 6px;
  z-index: 9100;
  display: none;
  animation: dropIn 0.15s ease;
}
.nav-dropdown.open { display: block; }

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 400;
  transition: background 0.1s;
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-dropdown-item:hover { background: var(--green-50); color: var(--green-700); }
.nav-dropdown-item .item-icon {
  width: 16px; height: 16px;
  color: var(--gray-400);
  flex-shrink: 0;
}
.nav-dropdown-item:hover .item-icon { color: var(--green-500); }
.nav-dropdown-divider {
  height: 1px;
  background: var(--gray-100);
  margin: 4px 0;
}

/* Lado direito da navbar */
.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav-icon-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  border: none;
  background: none;
  transition: background 0.15s, color 0.15s;
}
.nav-icon-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-icon-btn.has-badge { position: relative; }
.nav-badge {
  position: absolute;
  top: 3px; right: 3px;
  width: 7px; height: 7px;
  background: #ef4444;
  border-radius: 50%;
  border: 1.5px solid var(--navbar-bg);
}
.nav-clock {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green-400);
  font-weight: 500;
  padding: 0 8px;
  letter-spacing: 0.05em;
}

/* ================================================
   ÁREA DE TRABALHO (DESKTOP)
   ================================================ */
#desktop {
  position: fixed;
  top: var(--navbar-height);
  left: 0; right: 0; bottom: 0;
  overflow: hidden;
}

/* ================================================
   BARRA DE JANELAS ABERTAS (taskbar)
   ================================================ */
#taskbar {
  position: fixed;
  top: var(--navbar-height);
  left: 0; right: 0;
  height: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  background: var(--tab-bg);
  border-bottom: 1px solid var(--gray-200);
  z-index: 8000;
  overflow-x: auto;
  scrollbar-width: none;
  transition: height 0.18s ease;
}
#taskbar::-webkit-scrollbar { display: none; }
#taskbar.has-tabs {
  height: 36px;
}

.taskbar-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 10px;
  border-radius: 6px 6px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-500);
  background: transparent;
  cursor: pointer;
  white-space: nowrap;
  max-width: 180px;
  border: none;
  transition: background 0.1s, color 0.1s;
  position: relative;
}
.taskbar-tab:hover { background: rgba(0,0,0,0.05); color: var(--gray-700); }
.taskbar-tab.active {
  background: var(--tab-active);
  color: var(--gray-800);
  border: 1px solid var(--gray-200);
  border-bottom: 1px solid #fff;
}
.taskbar-tab .tab-close {
  font-size: 11px;
  opacity: 0.5;
  margin-left: 2px;
  padding: 1px 3px;
  border-radius: 3px;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}
.taskbar-tab .tab-close:hover { opacity: 1; background: rgba(0,0,0,0.08); }

/* Ajuste desktop quando taskbar aberta */
#desktop.with-taskbar {
  top: calc(var(--navbar-height) + 36px);
}

/* ================================================
   JANELAS
   ================================================ */
.window {
  position: absolute;
  min-width: 320px;
  min-height: 200px;
  background: var(--win-bg);
  border: 1px solid var(--win-border);
  border-radius: var(--win-radius);
  box-shadow: var(--win-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  animation: winOpen 0.18s cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes winOpen {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

.window.minimized { display: none; }

.window.maximized {
  position: fixed !important;
  top: calc(var(--navbar-height) + 36px) !important;
  left: 0 !important; right: 0 !important; bottom: 0 !important;
  width: 100% !important;
  height: calc(100vh - var(--navbar-height) - 36px) !important;
  border-radius: 0;
  z-index: 500;
  animation: none;
}

.window.focused { z-index: 200; }

/* Titlebar */
.window-titlebar {
  background: var(--win-titlebar);
  padding: 0 10px;
  height: 36px;
  display: flex;
  align-items: center;
  cursor: move;
  flex-shrink: 0;
  user-select: none;
  gap: 8px;
}
.window-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--win-titlebar-text);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.window-controls {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.win-btn {
  width: 24px; height: 24px;
  border-radius: 5px;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  transition: background 0.15s, opacity 0.15s;
  color: rgba(255,255,255,0.9);
}
.win-btn:hover { opacity: 0.85; }
.win-btn-min  { background: rgba(255,255,255,0.15); }
.win-btn-max  { background: rgba(255,255,255,0.15); }
.win-btn-close { background: rgba(239,68,68,0.7); }
.win-btn-close:hover { background: #ef4444; }

/* Conteúdo da janela */
.window-body {
  flex: 1;
  overflow: auto;
  position: relative;
}

/* Loading state dentro da janela */
.window-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  color: var(--gray-400);
  gap: 8px;
  font-size: 13px;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--green-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Resize handle */
.window-resize {
  position: absolute;
  bottom: 0; right: 0;
  width: 16px; height: 16px;
  cursor: se-resize;
  opacity: 0.3;
}
.window-resize::after {
  content: '';
  position: absolute;
  bottom: 3px; right: 3px;
  width: 8px; height: 8px;
  border-right: 2px solid var(--gray-500);
  border-bottom: 2px solid var(--gray-500);
  border-radius: 0 0 2px 0;
}

/* ================================================
   CONTEÚDO PADRÃO DE JANELAS
   ================================================ */
.win-content {
  padding: 24px;
}

.win-section-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--green-700);
  margin-bottom: 4px;
}
.win-section-sub {
  font-size: 13px;
  color: var(--gray-400);
  margin-bottom: 20px;
}

/* Busca */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-bar:focus-within {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(58,168,90,0.12);
}
.search-bar input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 14px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--gray-800);
  background: transparent;
}
.search-bar input::placeholder { color: var(--gray-300); }
.search-bar .search-btn {
  padding: 8px 14px;
  background: var(--green-500);
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex; align-items: center;
  transition: background 0.15s;
}
.search-bar .search-btn:hover { background: var(--green-600); }

/* Tabela */
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.data-table th {
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
  text-align: left;
  position: sticky;
  top: 0;
  z-index: 1;
}
.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.data-table tbody tr:hover { background: var(--green-50); }

/* Badge status */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
}
.badge-status.ativo  { background: var(--green-100); color: var(--green-700); }
.badge-status.inativo { background: #fee2e2; color: #b91c1c; }
.badge-status.pendente { background: #fef3c7; color: #92400e; }

/* Paginação */
.pag-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-100);
  font-size: 12px;
  color: var(--gray-500);
  flex-shrink: 0;
}
.pag-controls { display: flex; gap: 4px; }
.pag-btn {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  color: var(--gray-600);
  transition: all 0.1s;
}
.pag-btn:hover { background: var(--green-50); border-color: var(--green-300); color: var(--green-700); }
.pag-btn.active { background: var(--green-500); border-color: var(--green-500); color: #fff; }
.pag-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Form */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-input {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 7px;
  padding: 9px 12px;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--gray-800);
  background: #fff;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(58,168,90,0.12);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--green-500);
  color: #fff;
}
.btn-primary:hover { background: var(--green-600); }
.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
}
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
}
.btn-danger:hover { background: #fecaca; }

/* ================================================
   LOGIN PAGE
   ================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f5ec 0%, #d4eedd 50%, #c0e6cc 100%);
  overflow: auto;
}
.login-card {
  width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: 0 20px 60px rgba(30,80,50,0.12), 0 4px 16px rgba(30,80,50,0.08);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo-circle {
  width: 80px; height: 80px;
  background: radial-gradient(circle at 40% 35%, #52c472, #2b8a47);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  position: relative;
  box-shadow: 0 8px 24px rgba(46,140,74,0.3);
}
.login-logo-circle::after {
  content: '®';
  position: absolute;
  top: 2px; right: -2px;
  font-size: 10px;
  background: #fff;
  color: var(--green-600);
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.login-subtitle {
  font-size: 12px;
  color: var(--gray-400);
  text-align: center;
  margin-top: 6px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.login-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-800);
  text-align: center;
  margin-bottom: 24px;
}
.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--green-500);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  margin-top: 4px;
}
.login-btn:hover  { background: var(--green-600); }
.login-btn:active { transform: scale(0.99); }
.login-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.login-forgot {
  display: block;
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
  color: var(--green-600);
  text-decoration: none;
}
.login-forgot:hover { text-decoration: underline; }
.login-error {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #b91c1c;
  border-radius: 7px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* ================================================
   TOAST / NOTIFICAÇÃO
   ================================================ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--gray-800);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: toastIn 0.25s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  max-width: 360px;
}
.toast.success { background: var(--green-700); }
.toast.error   { background: #b91c1c; }
@keyframes toastIn  { from { opacity:0; transform:translateY(8px) scale(0.96); } to { opacity:1; transform:none; } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(4px) scale(0.97); } }

/* ================================================
   SCROLLBAR GLOBAL
   ================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-300); }
