/* =============================================
   SISTEMA DE RELATÓRIOS NAVAIS - ESTILOS
   ============================================= */

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

:root {
    --navy:    #0a2342;
    --blue:    #1565c0;
    --blue-lt: #1976d2;
    --accent:  #0288d1;
    --green:   #2e7d32;
    --red:     #c62828;
    --gray:    #546e7a;
    --gray-lt: #eceff1;
    --border:  #cfd8dc;
    --white:   #ffffff;
    --shadow:  0 2px 8px rgba(0,0,0,0.10);

    --bg-page:        #f0f4f8;
    --bg-card:        #ffffff;
    --bg-card-hover:  #f5f7fa;
    --bg-nav:         var(--navy);
    --bg-subnav:      #0c2850;
    --bg-input:       #fafafa;
    --text-primary:   #263238;
    --text-secondary: var(--gray);
    --border-color:   var(--border);
}

/* ── TEMA ESCURO ── */
html.dark {
    --navy:    #388bfd;
    --blue:    #1f6feb;
    --blue-lt: #388bfd;
    --accent:  #58a6ff;
    --green:   #238636;
    --red:     #da3633;
    --gray:    #8b949e;
    --gray-lt: #1c2430;
    --border:  #30363d;
    --shadow:  0 2px 12px rgba(0,0,0,0.4);

    --bg-page:        #0d1117;
    --bg-card:        #161b22;
    --bg-card-hover:  #1c2430;
    --bg-nav:         #010409;
    --bg-subnav:      #161b22;
    --bg-input:       #0d1117;
    --text-primary:   #e6edf3;
    --text-secondary: #8b949e;
    --border-color:   #30363d;
}

html.dark .alert-success { background: rgba(35,134,54,0.15); }
html.dark .alert-error   { background: rgba(218,54,51,0.15); }

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── NAV ── */
nav {
    background: var(--bg-nav);
    color: var(--white);
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

/* ── SUBNAV (barra de navegação secundária) ── */
.nav-subnav {
    background: var(--bg-subnav);
    border-top: 1px solid rgba(255,255,255,0.07);
}

.nav-subnav-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 42px;
    gap: 2px;
}

.nav-subnav a {
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0 16px;
    height: 42px;
    display: flex;
    align-items: center;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    white-space: nowrap;
    border-radius: 4px 4px 0 0;
}

.nav-subnav a:hover {
    color: var(--white);
    background: rgba(255,255,255,0.06);
    border-bottom-color: rgba(255,255,255,0.3);
}

.nav-subnav a.active {
    color: var(--white);
    font-weight: 600;
    border-bottom-color: var(--accent);
    background: rgba(255,255,255,0.05);
}

.nav-brand {
    color: var(--white);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--white);
    font-weight: 600;
}

/* ── MAIN ── */
main {
    max-width: 1000px;
    margin: 32px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

/* ── ALERTS ── */
.alert {
    padding: 14px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.alert-success { background: #e8f5e9; color: var(--green); border-left: 4px solid var(--green); }
.alert-error   { background: #ffebee; color: var(--red);   border-left: 4px solid var(--red); }

/* ── PAGE HEADER ── */
.page-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h1 {
    font-size: 1.7rem;
    color: var(--navy);
    font-weight: 700;
}

.page-header p {
    color: var(--gray);
    margin-top: 4px;
    font-size: 0.95rem;
}

/* ── CARDS ── */
.card {
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-header {
    background: var(--bg-nav);
    color: var(--white);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.section-num {
    background: var(--accent);
    color: var(--white);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.card-body {
    padding: 24px;
}

/* ── FORM FIELDS ── */
.field {
    margin-bottom: 18px;
}

.field:last-child {
    margin-bottom: 0;
}

label {
    display: block;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

input[type="text"],
input[type="password"],
input[type="date"],
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--bg-input);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="date"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--blue-lt);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
    background: var(--bg-card);
}

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

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 18px;
}

.subsection-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 8px 0 14px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}

.hint {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 18px;
}

/* ── FOTOS ── */
.foto-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.foto-upload label,
.foto-desc label {
    font-size: 0.88rem;
}

input[type="file"] {
    display: block;
    width: 100%;
    padding: 8px;
    border: 1.5px dashed var(--border);
    border-radius: 6px;
    background: var(--gray-lt);
    cursor: pointer;
    font-size: 0.88rem;
    margin-bottom: 8px;
}

input[type="file"]:hover {
    border-color: var(--accent);
}

.preview-box {
    width: 100%;
    height: 130px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-lt);
    overflow: hidden;
    color: var(--gray);
    font-size: 0.85rem;
}

.preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

/* ── SUBMIT ── */
.submit-area {
    text-align: center;
    margin: 8px 0 40px;
}

.btn-submit {
    background: var(--blue);
    color: var(--white);
    border: none;
    padding: 14px 48px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.3px;
}

.btn-submit:hover {
    background: var(--navy);
    transform: translateY(-1px);
}

.btn-submit:active {
    transform: translateY(0);
}

/* ── LISTA / TABELA ── */
.table-wrapper {
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: var(--shadow);
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

thead tr {
    background: var(--bg-nav);
    color: var(--white);
}

thead th {
    padding: 13px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

tbody tr:hover {
    background: var(--bg-card-hover);
}

tbody td {
    padding: 12px 16px;
    vertical-align: middle;
}

td.small {
    font-size: 0.82rem;
    color: var(--gray);
}

.badge {
    background: var(--gray-lt);
    color: var(--navy);
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 12px;
    font-size: 0.82rem;
}

.btn-download {
    background: var(--green);
    color: var(--white);
    text-decoration: none;
    padding: 6px 14px;
    border-radius: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-block;
    transition: background 0.2s;
}

.btn-download:hover {
    background: #1b5e20;
}

.btn-new {
    background: var(--accent);
    color: var(--white);
    text-decoration: none;
    padding: 9px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.btn-new:hover {
    background: var(--blue);
}

.no-file {
    color: var(--gray);
    font-size: 0.82rem;
}

/* ── BUSCA (histórico) ── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.search-bar select {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-card);
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar select:focus {
    border-color: var(--blue-lt);
}

.search-bar input {
    flex: 1;
    min-width: 180px;
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--bg-card);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--blue-lt);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
}

.search-bar button {
    background: none;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    padding: 7px 11px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--gray);
    transition: background 0.2s, color 0.2s;
}

.search-bar button:hover {
    background: var(--gray-lt);
    color: var(--navy);
}

.search-count {
    font-size: 0.82rem;
    color: var(--gray);
    margin-bottom: 12px;
    min-height: 18px;
}

.download-cell {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dl-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dl-done    { background: #2e7d32; }
.dl-pending { background: #e65100; }

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 64px 24px;
    color: var(--gray);
}

.empty-state p {
    font-size: 1.2rem;
    margin-bottom: 24px;
}

/* ── FOOTER ── */
footer {
    background: var(--bg-nav);
    color: rgba(255,255,255,0.5);
    text-align: center;
    padding: 14px;
    font-size: 0.82rem;
}

/* ── LOGIN ── */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 24px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
    padding: 40px 48px;
    width: 100%;
    max-width: 420px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 12px;
}

.login-header h1 {
    font-size: 1.4rem;
    color: var(--navy);
    margin-bottom: 6px;
}

.login-header p {
    color: var(--gray);
    font-size: 0.88rem;
}

.input-eye {
    position: relative;
    display: flex;
    align-items: center;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    background: var(--bg-input);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-eye:focus-within {
    border-color: var(--blue-lt);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
    background: var(--bg-card);
}

.input-eye input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 10px 44px 10px 14px;
    outline: none;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text-primary);
}

.input-eye input:focus {
    border: none !important;
    box-shadow: none !important;
}

.eye-btn {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    opacity: 0.4;
    padding: 0;
    line-height: 1;
    transition: opacity 0.2s;
}

.eye-btn:hover {
    opacity: 0.8;
}

.back-link {
    color: var(--gray);
    text-decoration: none;
    font-size: 0.88rem;
}

.back-link:hover {
    color: var(--navy);
}

/* ── NAV usuário autenticado ── */
.nav-user {
    color: rgba(255,255,255,0.6);
    font-size: 0.88rem;
    padding: 3px 10px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
}

.nav-logout {
    color: rgba(255,255,255,0.7) !important;
    font-size: 0.85rem;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 12px;
    transition: background 0.2s !important;
}

.nav-logout:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white) !important;
}

/* ── Botão perigo ── */
.btn-danger {
    background: none;
    border: 1px solid var(--red);
    color: var(--red);
    padding: 4px 12px;
    border-radius: 5px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.btn-danger:hover {
    background: var(--red);
    color: var(--white);
}

/* ── Cards de formulário (/formularios) ── */
.form-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.form-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.10);
    border-color: var(--accent);
}

.form-card-icon { font-size: 2rem; flex-shrink: 0; }
.form-card-body { flex: 1; }

.form-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.form-card-desc {
    font-size: 0.88rem;
    color: var(--gray);
    line-height: 1.4;
}

.form-card-arrow { font-size: 1.2rem; color: var(--accent); flex-shrink: 0; }

/* ── RESPONSIVE ── */
@media (max-width: 680px) {
    .grid-2 { grid-template-columns: 1fr; }
    .foto-row { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
}

/* ── Dark Mode Toggle ────────────────────────────────── */
.theme-toggle {
    display: flex;
    align-items: center;
}

.theme-toggle input[type="checkbox"] {
    display: none;
}

.theme-toggle label {
    position: relative;
    width: 52px;
    height: 26px;
    background: #546e7a;
    border-radius: 13px;
    cursor: pointer;
    transition: background 0.3s ease;
    display: flex;
    align-items: center;
    padding: 0 4px;
    box-sizing: border-box;
}

.theme-toggle label::after {
    content: '';
    position: absolute;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.theme-toggle input:checked + label {
    background: #1f6feb;
}

.theme-toggle input:checked + label::after {
    transform: translateX(26px);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
    font-size: 13px;
    line-height: 1;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    transition: opacity 0.2s ease;
    pointer-events: none;
    user-select: none;
}

.theme-toggle .icon-sun  { right: 5px; }
.theme-toggle .icon-moon { left: 5px; opacity: 0; }

.theme-toggle input:checked + label .icon-sun  { opacity: 0; }
.theme-toggle input:checked + label .icon-moon { opacity: 1; }
