/* ==========================================================
   RESET E VARIÁVEIS GLOBAIS
========================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
  font-family: 'Inter', sans-serif; 
  background: #F3F4F6;
  color: #374151; 
  display: flex; 
  height: 100vh; 
  overflow: hidden; 
}
h1, h2, h3, h4 { font-family: 'Poppins', sans-serif; color: #111827; }

/* ==========================================================
   TELA DE LOGIN
========================================================== */
.login-body {
  background-color: #0A0A0A !important;
  display: flex !important; align-items: center !important; justify-content: center !important;
  height: 100vh; margin: 0; color: #fff;
  background-image: radial-gradient(circle at 50% 0%, rgba(227, 0, 15, 0.15) 0%, transparent 60%), radial-gradient(circle at 50% 100%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
}
.login-box { 
  background: #111111; padding: 50px 40px; border-radius: 20px; width: 100%; max-width: 420px; 
  box-shadow: 0 25px 60px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.05); position: relative; overflow: hidden;
}
.login-box::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: #E3000F; }
.login-logo { display: block !important; max-width: 160px !important; max-height: 80px !important; width: auto !important; height: auto !important; margin: 0 auto 30px auto !important; object-fit: contain; }
.login-box h1 { color: #fff; font-size: 22px; text-align: center; margin-bottom: 8px; }
.login-box p { font-size: 14px; color: #9CA3AF; margin-bottom: 32px; text-align: center; }
.login-box input { width: 100%; padding: 14px 16px; background: #1A1A1A; border: 1.5px solid #333; border-radius: 8px; margin-bottom: 16px; box-sizing: border-box; font-family: inherit; color: #fff; font-size: 14px; transition: 0.3s; }
.login-box input:focus { outline: none; border-color: #E3000F; background: #111; }
.login-box button[type="submit"] { width: 100%; padding: 14px; background: #E3000F; color: #fff; border: none; border-radius: 8px; font-weight: 700; cursor: pointer; font-size: 15px; transition: 0.3s; text-transform: uppercase; letter-spacing: 1px; }
.login-box button[type="submit"]:hover { background: #B3000C; transform: translateY(-2px); box-shadow: 0 10px 20px rgba(227,0,15,0.3); }
.login-box .status { margin-top: 16px; font-size: 13px; text-align: center; color: #EF4444; font-weight: 500; }

/* ==========================================================
   SIDEBAR E NAVEGAÇÃO (DESKTOP)
========================================================== */
.sidebar { width: 250px; background: #0A0A0A; color: #fff; display: flex; flex-direction: column; transition: 0.3s; border-right: 2px solid #1F1F1F; flex-shrink: 0; }
.brand { padding: 16px; border-bottom: 1px solid #1F1F1F; display: flex; justify-content: center; align-items: center; height: 80px; overflow: hidden; }
.brand img { max-height: 45px !important; max-width: 100% !important; width: auto !important; height: auto !important; object-fit: contain; }
.menu { list-style: none; padding: 16px 12px; flex: 1; }
.menu li { padding: 12px 16px; border-radius: 8px; margin-bottom: 4px; display: flex; align-items: center; gap: 10px; color: #9CA3AF; cursor: pointer; transition: 0.2s; font-size: 15px; font-weight: 500; }
.menu li:hover { background: rgba(255,255,255,0.05); color: #fff; }
.menu li.active { background: #E3000F; color: #fff; box-shadow: 0 4px 12px rgba(227, 0, 15, 0.3); }
.menu li span { display: inline-block; }

/* ==========================================================
   ÁREA PRINCIPAL E TOPBAR
========================================================== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar { background: #fff; padding: 16px 32px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #E5E7EB; }
.topbar h2 { font-size: 20px; }
.user-info { display: flex; align-items: center; gap: 16px; font-size: 14px; color: #6B7280; }
.btn-logout { background: transparent; border: 1.5px solid #E5E7EB; padding: 8px 16px; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; color: #E3000F; }
.btn-logout:hover { background: #FEE2E2; border-color: #FEE2E2; }
.btn-icon { background: transparent; border: none; color: #9CA3AF; font-size: 18px; cursor: pointer; transition: 0.2s; padding: 4px 8px; display: flex; align-items: center; justify-content: center; }
.btn-icon:hover { color: #E3000F; transform: scale(1.1); }
.content { padding: 32px; overflow-y: auto; flex: 1; }

/* ==========================================================
   DASHBOARD E CARDS
========================================================== */
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: #fff; border-radius: 12px; border: 1px solid #E5E7EB; box-shadow: 0 4px 12px rgba(0,0,0,0.03); display: flex; flex-direction: column; align-items: stretch; gap: 16px; padding: 24px; }
.kpi-icon { width: 60px; height: 60px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 28px; flex-shrink: 0; }
.kpi-val { font-family: 'Poppins', sans-serif; font-size: 36px; font-weight: 800; color: #111827; line-height: 1; margin: 0; }
.kpi-lbl { font-size: 12px; color: #6B7280; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.alert-banner { background: #FEF2F2; border: 1px solid #FECACA; color: #991B1B; padding: 16px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 10px; margin-bottom: 24px; animation: pulseAlert 2s infinite; }
.alert-banner.hidden { display: none !important; }
@keyframes pulseAlert { 0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.2); } 50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); } }

/* ==========================================================
   BOTÕES GLOBAIS, FORMS E TABELAS
========================================================== */
.btn-primary { background: #111827; color: #fff; padding: 10px 20px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; font-size: 14px; }
.btn-primary:hover { background: #E3000F; }
.btn-secondary { background: #F3F4F6; color: #374151; padding: 10px 20px; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: 0.2s; font-size: 14px; }
.btn-secondary:hover { background: #E5E7EB; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.card-header h3 { font-size: 20px; }

.form-container { background: #fff; padding: 24px; border-radius: 12px; border: 1px solid #E5E7EB; margin-bottom: 24px; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.form-container.hidden { display: none; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.form-section h4 { margin-bottom: 12px; color: #111827; font-size: 15px; border-bottom: 1px solid #E5E7EB; padding-bottom: 8px; }
.form-section input, .form-section textarea { width: 100%; padding: 12px; border: 1.5px solid #E5E7EB; border-radius: 8px; margin-bottom: 12px; font-family: inherit; font-size: 14px; }
.form-section input:focus, .form-section textarea:focus { outline: none; border-color: #E3000F; }
.upload-section { background: #F9FAFB; padding: 16px; border-radius: 8px; border: 1.5px dashed #D1D5DB; margin-bottom: 24px; }
.upload-section h4 { margin-bottom: 8px; color: #111827; font-size: 15px; }
.upload-section small { display: block; margin-top: 8px; color: #6B7280; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; }

.table-container { background: #fff; border-radius: 12px; border: 1px solid #E5E7EB; overflow-x: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.03); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: #F9FAFB; padding: 14px 20px; font-size: 13px; color: #6B7280; text-transform: uppercase; border-bottom: 1px solid #E5E7EB; white-space: nowrap; }
td { padding: 14px 20px; font-size: 14px; border-bottom: 1px solid #E5E7EB; color: #374151; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.badge { display: inline-block; padding: 4px 10px; border-radius: 100px; font-size: 11px; font-weight: 700; }

/* ==========================================================
   MODAL E DETALHES DA ORDEM
========================================================== */
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 9999; opacity: 1; transition: opacity 0.3s ease; }
.modal-overlay.hidden { display: none !important; opacity: 0; pointer-events: none; }
.modal-content { background: #fff; padding: 32px; border-radius: 16px; width: 100%; max-width: 600px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 50px rgba(0,0,0,0.3); animation: slideUp 0.3s ease; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.order-header-box { background: #fff; padding: 24px; border-radius: 12px; border: 1px solid #E5E7EB; margin-bottom: 24px; display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 20px; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.order-info h3 { font-size: 24px; margin-bottom: 4px; color: #111827; }
.order-info p { color: #6B7280; font-size: 14px; }
.link-section { background: #F9FAFB; border: 1.5px dashed #D1D5DB; padding: 16px; border-radius: 8px; width: 100%; max-width: 400px; }
.link-section p { font-size: 12px; color: #6B7280; margin-bottom: 8px; font-weight: 600; text-transform: uppercase; }
.link-box { display: flex; gap: 8px; }
.link-box input { flex: 1; padding: 10px; border: 1px solid #E5E7EB; border-radius: 6px; font-family: monospace; font-size: 12px; color: #E3000F; background: #fff; font-weight: bold; }
.link-box button { background: #111827; color: #fff; border: none; padding: 0 16px; border-radius: 6px; font-weight: 600; cursor: pointer; transition: 0.2s; }
.link-box button:hover { background: #E3000F; }
.timeline-container { background: #fff; padding: 24px; border-radius: 12px; border: 1px solid #E5E7EB; box-shadow: 0 4px 12px rgba(0,0,0,0.03); }
.timeline-item { display: flex; gap: 16px; padding: 16px 0; border-bottom: 1px solid #E5E7EB; }
.timeline-item:last-child { border-bottom: none; }
.tl-icon { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; flex-shrink: 0; font-weight: bold; }
.tl-done { background: #10B981; }
.tl-active { background: #E3000F; animation: pulse 1.5s infinite; }
.tl-pending { background: #E5E7EB; color: #9CA3AF; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.tl-content { flex: 1; }
.tl-content h4 { font-size: 15px; margin-bottom: 4px; color: #111827; }
.tl-content p { font-size: 13px; color: #6B7280; }
.tl-actions { display: flex; align-items: center; gap: 8px; }


/* ==========================================================
   RESPONSIVIDADE (MOBILE / TABLET)
========================================================== */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Ajuste da estrutura base para rolagem no celular */
  html, body {
    height: auto;
    overflow: auto;
  }
  body:not(.login-body) {
    flex-direction: column;
    padding-bottom: 70px; /* Espaço para o menu inferior */
  }

  /* TOPBAR FIXA E COMPACTA */
  .topbar {
    padding: 12px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  }
  .topbar h2 { font-size: 18px; }
  .user-info { width: 100%; justify-content: space-between; font-size: 13px; }
  .btn-logout { padding: 6px 12px; font-size: 13px; }

  /* MENU INFERIOR (BOTTOM NAVIGATION) */
  .sidebar {
    width: 100%;
    height: 65px;
    position: fixed;
    bottom: 0;
    left: 0;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid #1F1F1F;
    z-index: 1000;
    background: #0A0A0A;
  }
  .brand { display: none; }
  .menu {
    display: flex;
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    justify-content: space-around;
    align-items: center;
  }
  .menu li {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 6px 4px;
    margin: 0;
    font-size: 20px; /* Tamanho do Emoji */
    gap: 2px;
    border-radius: 8px;
    color: #9CA3AF;
    transition: 0.2s;
  }
  .menu li span {
    font-size: 10px;
    font-weight: 600;
  }
  .menu li:hover { background: transparent; }
  .menu li.active {
    background: transparent;
    color: #E3000F;
  }
  .menu li.active span { color: #E3000F; }

  /* CONTEÚDO E TABELAS */
  .main-content { height: auto; overflow: visible; }
  .content { padding: 16px; }
  
  /* Força tabelas a terem rolagem horizontal sem quebrar o layout */
  table { min-width: 600px; }
  th, td { padding: 12px 14px; font-size: 13px; }

  /* CARDS E FORMULÁRIOS EM 1 COLUNA */
  .kpi-grid, .cards-3, .cards-4, .form-grid, .pgrid {
    grid-template-columns: 1fr !important;
  }
  
  /* BOTÕES E MODAIS */
  .form-actions {
    flex-direction: column-reverse;
  }
  .form-actions button {
    width: 100%;
  }
  .modal-content {
    width: 95%;
    padding: 20px;
  }
  .order-header-box {
    flex-direction: column;
  }
  .link-section {
    max-width: 100%;
  }
}

@media (max-width: 480px) {
  .topbar h2 { font-size: 16px; }
  .user-info span { font-size: 12px; max-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .btn-logout { padding: 6px 8px; font-size: 11px; }
}