/* ============================================================
   4tools.com.br - Main Stylesheet
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --color-sidebar-bg: #1e293b;
  --color-sidebar-text: #cbd5e1;
  --color-sidebar-hover: #334155;
  --color-sidebar-active: #3b82f6;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;
  --color-accent: #3b82f6;
  --color-accent-hover: #2563eb;
  --color-success: #22c55e;
  --color-error: #ef4444;
  --color-warning: #f59e0b;
  --sidebar-width: 250px;
  --header-height: 64px;
  --ad-right-width: 160px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --transition: .2s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--color-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

ul { list-style: none; }

/* --- Layout Wrapper --- */
.layout {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--color-sidebar-bg);
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.header-logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -1px;
  white-space: nowrap;
  text-decoration: none;
}

.header-logo span { color: var(--color-accent); }

.header-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.header-search input {
  width: 100%;
  padding: .5rem 1rem .5rem 2.5rem;
  border-radius: 999px;
  border: none;
  background: #334155;
  color: #fff;
  font-size: .9rem;
  outline: none;
  transition: background var(--transition);
}

.header-search input::placeholder { color: #94a3b8; }
.header-search input:focus { background: #475569; }

.header-search .search-icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
  font-size: .9rem;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  padding: .35rem;
  background: none;
  border: none;
  margin-left: auto;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: var(--transition);
}

/* ============================================================
   BODY WRAPPER (sidebar + main + ad)
   ============================================================ */
.body-wrapper {
  display: flex;
  flex: 1;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
}

.sidebar-search {
  padding: .75rem 1rem;
  border-bottom: 1px solid #334155;
}

.sidebar-search input {
  width: 100%;
  padding: .45rem .75rem;
  border-radius: var(--radius);
  border: 1px solid #334155;
  background: #0f172a;
  color: #e2e8f0;
  font-size: .85rem;
  outline: none;
  transition: border-color var(--transition);
}

.sidebar-search input::placeholder { color: #64748b; }
.sidebar-search input:focus { border-color: var(--color-accent); }

.sidebar-nav { flex: 1; padding: .5rem 0 1rem; }

.sidebar-category { margin-bottom: .25rem; }

.sidebar-category-title {
  display: block;
  padding: .5rem 1rem .25rem;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #64748b;
  cursor: default;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem 1rem .45rem 1.25rem;
  color: var(--color-sidebar-text);
  font-size: .875rem;
  border-left: 3px solid transparent;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(59,130,246,.15);
  border-left-color: var(--color-accent);
  color: #93c5fd;
}

.sidebar-nav a .nav-icon { font-size: 1rem; width: 1.2rem; text-align: center; }

/* ============================================================
   MAIN CONTENT
   ============================================================ */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ============================================================
   AD SIDEBAR RIGHT
   ============================================================ */
.ad-sidebar-right {
  width: var(--ad-right-width);
  min-width: var(--ad-right-width);
  padding: 1rem .75rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================================
   AD PLACEHOLDERS
   ============================================================ */
.ad-placeholder {
  display: block;
  background: transparent;
}

.ad-banner { width: 100%; height: 90px; }
.ad-square { width: 100%; height: 250px; }
.ad-sidebar { width: 100%; height: 600px; }

/* ============================================================
   BREADCRUMB
   ============================================================ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .82rem;
  color: var(--color-text-muted);
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--color-accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: #cbd5e1; }

/* ============================================================
   HERO (index)
   ============================================================ */
.hero {
  background: linear-gradient(135deg, var(--color-sidebar-bg) 0%, #1e40af 100%);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  text-align: center;
}

.hero h1 { font-size: clamp(1.5rem, 3vw, 2.25rem); font-weight: 800; margin-bottom: .75rem; }
.hero p { font-size: 1.05rem; color: #bfdbfe; max-width: 520px; margin: 0 auto; }

/* ============================================================
   SECTION TITLE
   ============================================================ */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1rem;
}

/* ============================================================
   TOOL CARDS GRID
   ============================================================ */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.tool-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  text-decoration: none;
  color: inherit;
}

.tool-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--color-accent);
  text-decoration: none;
}

.tool-card-icon { font-size: 2rem; line-height: 1; }
.tool-card-title { font-size: .95rem; font-weight: 700; color: var(--color-text); }
.tool-card-desc { font-size: .8rem; color: var(--color-text-muted); flex: 1; }
.tool-card-link { font-size: .8rem; color: var(--color-accent); font-weight: 600; margin-top: .25rem; }

/* ============================================================
   TOOL PAGE STYLES
   ============================================================ */
.tool-header { margin-bottom: 1.25rem; }
.tool-header h1 { font-size: 1.5rem; font-weight: 800; margin-bottom: .35rem; }
.tool-header p { color: var(--color-text-muted); font-size: .95rem; }

.tool-card-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* --- Form Elements --- */
.form-group { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

label {
  font-size: .875rem;
  font-weight: 600;
  color: var(--color-text);
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="url"],
textarea,
select {
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: .9rem;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

textarea { resize: vertical; min-height: 120px; }

.form-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }

.form-check {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--color-accent);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.25rem;
  border-radius: var(--radius);
  border: none;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  line-height: 1.4;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--color-accent);
  color: #fff;
}
.btn-primary:hover { background: var(--color-accent-hover); box-shadow: 0 4px 12px rgba(59,130,246,.35); }

.btn-secondary {
  background: #e2e8f0;
  color: var(--color-text);
}
.btn-secondary:hover { background: #cbd5e1; }

.btn-danger {
  background: #fee2e2;
  color: var(--color-error);
}
.btn-danger:hover { background: #fecaca; }

.btn-success {
  background: #dcfce7;
  color: #16a34a;
}
.btn-success:hover { background: #bbf7d0; }

.btn-copy {
  background: #f1f5f9;
  color: var(--color-text-muted);
  font-size: .8rem;
  padding: .35rem .75rem;
  border: 1px solid var(--color-border);
}
.btn-copy:hover { background: #e2e8f0; }
.btn-copy.copied { background: #dcfce7; color: #16a34a; border-color: #86efac; }

.btn-group { display: flex; gap: .6rem; flex-wrap: wrap; }

/* --- Output Area --- */
.output-area {
  position: relative;
  margin-top: 1rem;
}

.output-box {
  background: #f8fafc;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
  font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace;
  font-size: .95rem;
  min-height: 48px;
  word-break: break-all;
  white-space: pre-wrap;
  color: var(--color-text);
}

.output-box.large {
  min-height: 160px;
  white-space: pre-wrap;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .4rem;
}

.output-label { font-size: .8rem; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }

/* --- Result States --- */
.result-valid {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  background: #dcfce7;
  color: #166534;
  border: 1px solid #86efac;
}

.result-invalid {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .85rem 1rem;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 1rem;
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.result-icon { font-size: 1.3rem; }

/* --- Slider --- */
input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  appearance: none;
  background: var(--color-border);
  outline: none;
  padding: 0;
  border: none;
  box-shadow: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}

/* --- Password Strength --- */
.strength-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
  overflow: hidden;
  margin-top: .5rem;
}

.strength-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .3s ease, background .3s ease;
}

.strength-label { font-size: .8rem; font-weight: 600; margin-top: .3rem; }
.strength-weak { color: var(--color-error); }
.strength-fair { color: var(--color-warning); }
.strength-good { color: #3b82f6; }
.strength-strong { color: var(--color-success); }

/* --- Stats Grid --- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .75rem;
}

.stat-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem;
  text-align: center;
}

.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--color-accent); }
.stat-label { font-size: .75rem; color: var(--color-text-muted); margin-top: .1rem; }

/* --- CEP Result Card --- */
.cep-result-card {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-top: 1rem;
}

.cep-result-card h3 { font-size: .95rem; font-weight: 700; color: #0c4a6e; margin-bottom: .75rem; }
.cep-row { display: flex; gap: 1rem; margin-bottom: .4rem; flex-wrap: wrap; }
.cep-field { flex: 1; min-width: 150px; }
.cep-field dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: #64748b; font-weight: 700; }
.cep-field dd { font-size: .95rem; color: var(--color-text); font-weight: 500; }

/* --- Color Converter --- */
.color-preview {
  width: 100%;
  height: 80px;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  margin-bottom: 1rem;
  transition: background .2s;
}

.color-inputs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.color-field-group { display: flex; flex-direction: column; gap: .4rem; }
.color-field-group label { font-size: .8rem; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: .05em; }

.color-row { display: flex; gap: .5rem; align-items: center; }
.color-row input[type="text"],
.color-row input[type="number"] {
  flex: 1;
}

input[type="color"] {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  cursor: pointer;
  padding: 2px;
  background: var(--color-surface);
}

/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  background: var(--color-sidebar-bg);
  color: #94a3b8;
  text-align: center;
  padding: 1.25rem 1rem;
  font-size: .82rem;
  margin-top: auto;
}

.site-footer a { color: #60a5fa; }
.site-footer a:hover { color: #93c5fd; }

/* ============================================================
   SEARCH RESULTS OVERLAY
   ============================================================ */
.search-results {
  position: absolute;
  top: calc(100% + .4rem);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
  display: none;
}

.search-results.open { display: block; }
.search-result-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem 1rem;
  font-size: .875rem;
  cursor: pointer;
  transition: background var(--transition);
  color: var(--color-text);
  text-decoration: none;
}
.search-result-item:hover { background: #f1f5f9; }
.search-result-item .ri { font-size: 1.1rem; }
.search-result-empty { padding: .8rem 1rem; font-size: .875rem; color: var(--color-text-muted); text-align: center; }

/* Sidebar filtered hidden */
.sidebar-nav a.hidden { display: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .ad-sidebar-right {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    padding: 0 1rem .75rem;
  }
  .ad-sidebar-right .ad-sidebar { display: none; }
  .ad-sidebar-right .ad-square   { height: 100px; }
}

@media (max-width: 768px) {
  .hamburger { display: flex; }

  .header-search { display: none; }

  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform .25s ease;
    height: calc(100vh - var(--header-height));
  }

  .sidebar.open { transform: translateX(0); }

  .body-wrapper { flex-direction: column; }

  .main-content { padding: 1rem; }

  .tools-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

  .color-inputs-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .tools-grid { grid-template-columns: 1fr 1fr; }
  .hero { padding: 1.5rem 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr 1fr; }
}

/* ============================================================
   OVERLAY (mobile sidebar backdrop)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 80;
}

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

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.text-muted { color: var(--color-text-muted); font-size: .85rem; }
.divider { border: none; border-top: 1px solid var(--color-border); margin: 1.25rem 0; }
.mono { font-family: 'Cascadia Code', 'Fira Code', 'Courier New', monospace; }
