/* =========================================================================
   Windland Development Manager — tema base
   Variáveis de marca (secção 3). As cores são sobrepostas em runtime a partir
   das definições da empresa (backoffice) através de :root inline no layout.
   ========================================================================= */

:root {
    --windland-primary: #0057A8;
    --windland-secondary: #00A6D6;
    --windland-dark: #172333;
    --windland-light: #F4F7FA;
    --windland-success: #28A745;
    --windland-warning: #F4B400;
    --windland-danger: #D93025;
    --windland-info: #1389C9;

    /* Tokens semânticos — modo claro (default) */
    --bg: #eef2f7;
    --surface: #ffffff;
    --surface-2: #f7f9fc;
    --border: #e2e8f0;
    --text: #1f2a3a;
    --text-muted: #6b7a90;
    --sidebar-bg: var(--windland-dark);
    --sidebar-text: #c7d2e0;
    --sidebar-active: var(--windland-primary);
    --shadow: 0 1px 3px rgba(23, 35, 51, .08), 0 1px 2px rgba(23, 35, 51, .06);
    --shadow-lg: 0 10px 25px rgba(23, 35, 51, .12);
    --radius: 10px;
    --radius-sm: 7px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
    --bg: #0f1621;
    --surface: #172333;
    --surface-2: #1d2b3f;
    --border: #29384d;
    --text: #e6edf5;
    --text-muted: #93a4bb;
    --sidebar-bg: #0c131e;
    --sidebar-text: #a7b6ca;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, .5);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

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

/* ------------------------------------------------------------- Layout app */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 40;
    transition: transform .25s ease;
}
.sidebar__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar__brand img { height: 30px; }
.sidebar__brand span { font-weight: 700; color: #fff; font-size: 15px; letter-spacing: .2px; }
.sidebar__nav { flex: 1; overflow-y: auto; padding: 12px 0; }
.sidebar__section { padding: 14px 20px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.4); }
.sidebar__link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    color: var(--sidebar-text);
    font-weight: 500;
    border-left: 3px solid transparent;
}
.sidebar__link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.sidebar__link.active { background: rgba(0, 87, 168, .22); border-left-color: var(--windland-secondary); color: #fff; }
.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; }

.main { flex: 1; margin-left: 260px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: 62px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px;
    padding: 0 22px;
    position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-weight: 600; font-size: 16px; }
.topbar__spacer { flex: 1; }
.topbar__action {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--radius-sm);
    color: var(--text-muted); background: transparent; border: 1px solid transparent; cursor: pointer;
}
.topbar__action:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }

.content { padding: 24px; flex: 1; }

/* ------------------------------------------------------------- Avatar / user */
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--windland-primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
}
.dropdown { position: relative; }
.dropdown__menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 200px; padding: 6px; display: none; z-index: 50;
}
.dropdown__menu.open { display: block; }
.dropdown__item { display: block; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text); }
.dropdown__item:hover { background: var(--surface-2); text-decoration: none; }

/* ------------------------------------------------------------- Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card__header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.card__title { font-weight: 600; font-size: 15px; margin: 0; }
.card__body { padding: 20px; }

.grid { display: grid; gap: 18px; }
.grid--stats { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
    display: flex; flex-direction: column; gap: 6px;
}
.stat__label { color: var(--text-muted); font-size: 12.5px; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.stat__value { font-size: 30px; font-weight: 700; line-height: 1; }
.stat__meta { font-size: 12px; color: var(--text-muted); }
.stat__icon { width: 40px; height: 40px; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; }
.stat--primary .stat__icon { background: rgba(0,87,168,.12); color: var(--windland-primary); }
.stat--danger .stat__icon { background: rgba(217,48,37,.12); color: var(--windland-danger); }
.stat--warning .stat__icon { background: rgba(244,180,0,.15); color: #b5850b; }
.stat--success .stat__icon { background: rgba(40,167,69,.14); color: var(--windland-success); }

/* ------------------------------------------------------------- Buttons */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 9px 16px; border-radius: var(--radius-sm);
    font-weight: 600; font-size: 13.5px; cursor: pointer;
    border: 1px solid transparent; background: var(--surface-2); color: var(--text);
    transition: background .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn--primary { background: var(--windland-primary); color: #fff; }
.btn--primary:hover { background: #024e97; }
.btn--secondary { background: var(--windland-secondary); color: #fff; }
.btn--danger { background: var(--windland-danger); color: #fff; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--surface-2); }
.btn--sm { padding: 6px 11px; font-size: 12.5px; }
.btn--block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ------------------------------------------------------------- Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 6px; color: var(--text); }
.form-control {
    width: 100%; padding: 10px 12px; font-size: 14px; font-family: inherit;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.form-control:focus { outline: none; border-color: var(--windland-primary); box-shadow: 0 0 0 3px rgba(0,87,168,.15); }
.form-control.is-invalid { border-color: var(--windland-danger); }
.form-error { color: var(--windland-danger); font-size: 12.5px; margin-top: 5px; }
.form-hint { color: var(--text-muted); font-size: 12.5px; margin-top: 5px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
input[type="color"].form-control { height: 42px; padding: 4px; }

/* ------------------------------------------------------------- Tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); background: var(--surface-2); font-weight: 600; }
.table tbody tr:hover, .table tbody tr:hover { background: var(--surface-2); }
.table td { font-size: 13.5px; }

/* ------------------------------------------------------------- Badges */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.badge--success { background: rgba(40,167,69,.14); color: #1c7a33; }
.badge--danger { background: rgba(217,48,37,.14); color: #b3271d; }
.badge--warning { background: rgba(244,180,0,.18); color: #916700; }
.badge--info { background: rgba(19,137,201,.14); color: #0f6ea3; }
.badge--muted { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.badge--dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------- Alerts / flash */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 13.5px; border: 1px solid transparent; }
.alert--success { background: rgba(40,167,69,.1); border-color: rgba(40,167,69,.3); color: #1c7a33; }
.alert--error, .alert--danger { background: rgba(217,48,37,.08); border-color: rgba(217,48,37,.3); color: #b3271d; }
.alert--info { background: rgba(19,137,201,.08); border-color: rgba(19,137,201,.3); color: #0f6ea3; }
.alert--warning { background: rgba(244,180,0,.1); border-color: rgba(244,180,0,.35); color: #916700; }

/* ------------------------------------------------------------- Toasts */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--windland-primary); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: 12px 16px; min-width: 260px; animation: toast-in .2s ease; }
.toast--success { border-left-color: var(--windland-success); }
.toast--error { border-left-color: var(--windland-danger); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------- Auth / install */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
    background: linear-gradient(135deg, var(--windland-dark) 0%, #0d3a63 55%, var(--windland-primary) 100%); }
.auth-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); width: 100%; max-width: 420px; padding: 34px 32px; }
.auth-card__brand { text-align: center; margin-bottom: 22px; }
.auth-card__brand img { height: 46px; }
.auth-card__title { font-size: 20px; font-weight: 700; margin: 4px 0 2px; text-align: center; }
.auth-card__subtitle { color: var(--text-muted); text-align: center; margin: 0 0 22px; font-size: 13.5px; }
.auth-card--wide { max-width: 640px; }

.page-header { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 21px; margin: 0; font-weight: 700; }
.page-header .page-header__spacer { flex: 1; }

/* ------------------------------------------------------------- Installer steps */
.steps { display: flex; gap: 8px; margin-bottom: 26px; flex-wrap: wrap; }
.step { flex: 1; min-width: 90px; text-align: center; font-size: 12.5px; color: var(--text-muted); padding-bottom: 8px; border-bottom: 3px solid var(--border); }
.step.active { color: var(--windland-primary); border-color: var(--windland-primary); font-weight: 600; }
.step.done { color: var(--windland-success); border-color: var(--windland-success); }
.req-list { list-style: none; padding: 0; margin: 0 0 20px; }
.req-list li { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }

.text-muted { color: var(--text-muted); }
.mt-3 { margin-top: 18px; } .mb-0 { margin-bottom: 0; } .text-center { text-align: center; }
.d-flex { display: flex; } .gap-2 { gap: 10px; } .justify-between { justify-content: space-between; } .items-center { align-items: center; }

/* ------------------------------------------------------------- Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tab {
    padding: 10px 16px; cursor: pointer; font-weight: 600; font-size: 13.5px;
    color: var(--text-muted); background: none; border: none; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab--active { color: var(--windland-primary); border-bottom-color: var(--windland-primary); }

/* Progresso */
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress__bar { height: 100%; background: var(--windland-primary); border-radius: 999px; transition: width .3s; }

/* Definição chave/valor */
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; }
.dl dt { color: var(--text-muted); font-size: 13px; }
.dl dd { margin: 0; font-size: 13.5px; }
@media (max-width: 640px) { .dl { grid-template-columns: 1fr; gap: 2px 0; } .dl dd { margin-bottom: 8px; } }

/* ------------------------------------------------------------- Kanban */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban__col { flex: 0 0 280px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 220px); }
.kanban__head { padding: 12px 14px; font-weight: 600; font-size: 13px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); position: sticky; top: 0; }
.kanban__count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--text-muted); }
.kanban__body { padding: 10px; overflow-y: auto; flex: 1; min-height: 60px; }
.kanban__body.drag-over { background: rgba(0,87,168,.06); outline: 2px dashed var(--windland-secondary); outline-offset: -4px; }
.kcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 12px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .45; }
.kcard__title { font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.kcard__title a { color: var(--text); }
.kcard__meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.kcard__code { font-size: 11px; color: var(--text-muted); }

/* ------------------------------------------------------------- Gantt */
.gantt { border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; background: var(--surface); }
.gantt__row { display: flex; align-items: center; border-bottom: 1px solid var(--border); min-height: 40px; }
.gantt__label { flex: 0 0 220px; padding: 8px 12px; font-size: 13px; border-right: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: sticky; left: 0; background: var(--surface); }
.gantt__track { position: relative; flex: 1; height: 40px; min-width: 600px; }
.gantt__bar { position: absolute; top: 9px; height: 22px; border-radius: 5px; background: var(--windland-primary); opacity: .85; display: flex; align-items: center; padding: 0 8px; color: #fff; font-size: 11px; white-space: nowrap; overflow: hidden; }
.gantt__head { display: flex; border-bottom: 2px solid var(--border); font-size: 11px; color: var(--text-muted); }
.gantt__head-label { flex: 0 0 220px; padding: 8px 12px; border-right: 1px solid var(--border); font-weight: 600; }
.gantt__months { display: flex; flex: 1; min-width: 600px; }
.gantt__month { flex: 1; padding: 8px 4px; text-align: center; border-right: 1px solid var(--border); }

/* ------------------------------------------------------------- Calendar */
.cal { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal__dow { padding: 8px; text-align: center; font-size: 12px; font-weight: 600; color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cal__day { min-height: 96px; border: 1px solid var(--border); padding: 6px; font-size: 12px; }
.cal__day--out { background: var(--surface-2); color: var(--text-muted); }
.cal__day--today { outline: 2px solid var(--windland-primary); outline-offset: -2px; }
.cal__num { font-weight: 600; margin-bottom: 4px; }
.cal__ev { display: block; padding: 2px 6px; border-radius: 4px; margin-bottom: 3px; font-size: 11px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal__ev--task { background: var(--windland-primary); }
.cal__ev--milestone { background: var(--windland-warning); color: #3a2c00; }
.cal__ev--phase { background: var(--windland-secondary); }
.cal__ev--sprint { background: var(--windland-info); }

/* ------------------------------------------------------------- Editor */
.editor-toolbar { display: flex; gap: 4px; flex-wrap: wrap; padding: 8px; border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--surface-2); }
.editor-toolbar button { min-width: 34px; height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: 5px; cursor: pointer; color: var(--text); font-size: 13px; padding: 0 8px; }
.editor-toolbar button:hover { background: var(--surface-2); }
.editor-area { min-height: 420px; border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 18px 20px; background: var(--surface); font-size: 14.5px; line-height: 1.7; outline: none; overflow-y: auto; }
.editor-area:focus { border-color: var(--windland-primary); }
.editor-area h2 { font-size: 22px; margin: 16px 0 8px; } .editor-area h3 { font-size: 18px; margin: 14px 0 6px; }
.editor-area table { border-collapse: collapse; width: 100%; margin: 10px 0; } .editor-area td, .editor-area th { border: 1px solid var(--border); padding: 6px 10px; }
.editor-area pre { background: var(--surface-2); padding: 12px; border-radius: 6px; overflow-x: auto; } .editor-area code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.editor-area blockquote { border-left: 3px solid var(--windland-secondary); margin: 10px 0; padding: 4px 14px; color: var(--text-muted); }

/* Documento impresso */
.doc-print { max-width: 800px; margin: 30px auto; padding: 0 24px; color: #111; font-size: 15px; line-height: 1.7; }
.doc-print h1 { font-size: 26px; } .doc-print table { border-collapse: collapse; width: 100%; } .doc-print td, .doc-print th { border: 1px solid #ccc; padding: 6px 10px; }
@media print { .no-print { display: none !important; } body { background: #fff; } }

/* ------------------------------------------------------------- Timer */
.timer-widget { display: flex; align-items: center; gap: 12px; }
.timer-clock { font-variant-numeric: tabular-nums; font-size: 22px; font-weight: 700; }

/* ------------------------------------------------------------- Responsive */
.sidebar__toggle { display: none; }
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .sidebar__toggle { display: inline-flex; }
    .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .content { padding: 16px; }
    .grid--stats { grid-template-columns: 1fr 1fr; }
    .stat__value { font-size: 24px; }
}

/* Backdrop para sidebar mobile */
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 39; }
.sidebar-backdrop.open { display: block; }
