/* =====================================================================
   Livro de Visitas (Guestbook PHP 8) — folha de estilo responsiva
   ===================================================================== */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --bg: #f4f5fb;
    --card-bg: #ffffff;
    --text: #1f2433;
    --muted: #6b7280;
    --border: #e5e7eb;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --warning: #d97706;
    --warning-bg: #fef3c7;
    --radius: 14px;
    --shadow: 0 4px 20px rgba(31, 36, 51, 0.08);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 820px;
    margin: 0 auto;
    padding: 0 1rem;
}

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

/* ---------- Cabeçalho ---------- */
.site-header {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: .9rem;
    padding-bottom: .9rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-icon { font-size: 1.4rem; }
.site-nav { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.site-nav a { color: var(--muted); font-weight: 500; font-size: .95rem; }
.site-nav a:hover { color: var(--text); text-decoration: none; }
.nav-cta {
    background: var(--primary);
    color: #fff !important;
    padding: .45rem .9rem;
    border-radius: 8px;
}
.nav-cta:hover { background: var(--primary-dark); text-decoration: none; }

.main-content { padding: 2rem 1rem 3rem; }

/* ---------- Hero ---------- */
.hero { text-align: center; margin-bottom: 2rem; }
.hero h1 { font-size: 2rem; margin: 0 0 .4rem; }
.hero-sub { color: var(--muted); margin: 0; }

/* ---------- Cartões / formulários ---------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.8rem;
    border: 1px solid var(--border);
}
h1, h2 { line-height: 1.25; }
.card h1 { margin-top: 0; }
.card h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; color: var(--text); }

label {
    display: block;
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: .92rem;
}
label em { color: var(--danger); font-style: normal; }
input, textarea, select {
    width: 100%;
    margin-top: .35rem;
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    font-family: inherit;
    font-size: .95rem;
    font-weight: 400;
    background: #fff;
    color: var(--text);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
textarea { resize: vertical; }
.has-error { border-color: var(--danger) !important; background: #fff5f5; }
.field-error { display: block; color: var(--danger); font-size: .82rem; margin-top: .3rem; font-weight: 500; }
.field-hint { display: block; color: var(--muted); font-size: .8rem; margin-top: .3rem; font-weight: 400; }
.field-label { display: block; font-weight: 600; margin-bottom: .35rem; }

/* ---------- Rich Text Editor (Quill) ---------- */
#editor-container {
    margin-top: .35rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
}
#editor-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
#editor-container .ql-editor {
    min-height: 180px;
    font-family: var(--font);
    font-size: .95rem;
}
#editor-container .ql-toolbar {
    border: none;
    border-bottom: 1px solid var(--border);
    border-radius: 9px 9px 0 0;
    background: #fafbfc;
}
#editor-container .ql-container {
    border: none;
    border-radius: 0 0 9px 9px;
}
.ql-snow .ql-stroke { stroke: var(--text); }
.ql-snow .ql-fill { fill: var(--text); }
.ql-snow .ql-picker { color: var(--text); }
.ql-snow .ql-picker-options { background: #fff; border-color: var(--border); border-radius: 8px; }
.ql-toolbar button:hover .ql-stroke,
.ql-toolbar button.ql-active .ql-stroke { stroke: var(--primary); }
.ql-toolbar button:hover .ql-fill,
.ql-toolbar button.ql-active .ql-fill { fill: var(--primary); }
.ql-toolbar button:hover, .ql-toolbar button.ql-active { color: var(--primary); }
.ql-snow.ql-toolbar button:hover .ql-stroke,
.ql-snow.ql-toolbar button.ql-active .ql-stroke,
.ql-snow .ql-toolbar button:hover .ql-stroke,
.ql-snow .ql-toolbar button.ql-active .ql-stroke { stroke: var(--primary); }

/* ---- Upload de fotos (formulário público) ---- */
.photo-field input[type="file"] { padding: .55rem; background: #fff; cursor: pointer; }
.photo-preview {
    margin-top: .6rem;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
.photo-preview img {
    width: 96px;
    height: 96px;
    border-radius: 10px;
    border: 1px solid var(--border, #e5e7eb);
    object-fit: cover;
}

/* ---- Fotos exibidas nas mensagens públicas (galeria com thumbnails 380x470) ---- */
.entry-photos {
    margin-top: .7rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: .6rem;
}
.entry-photo { display: block; cursor: zoom-in; }
.entry-photo img {
    width: 100%;
    height: 100%;
    max-height: 470px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--border, #e5e7eb);
    transition: transform .15s ease, box-shadow .15s ease;
}
.entry-photo:hover img {
    transform: scale(1.03);
    box-shadow: 0 6px 24px rgba(31, 36, 51, 0.15);
}

/* ---- Fotos na área administrativa (galeria) ---- */
.admin-entry-photos {
    margin-top: .6rem;
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
}
.admin-entry-photos img {
    width: 90px;
    height: 90px;
    border-radius: 8px;
    border: 1px solid var(--border, #e5e7eb);
    object-fit: cover;
}

/* ---- Edição de fotos (admin) ---- */
.edit-photo { margin: 1rem 0; }
.edit-photo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .8rem;
    margin: .5rem 0 .8rem;
}
.edit-photo-item {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: .35rem;
    background: #fafbfc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .7rem;
}
.edit-photo-item img {
    width: 130px;
    height: 130px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--border, #e5e7eb);
    display: block;
}
.edit-photo-item .checkbox { font-size: .85rem; }
.edit-photo-label {
    display: block;
    font-size: .78rem;
    font-weight: 500;
    margin-bottom: 0;
    width: 100%;
}
.edit-photo-label input {
    font-size: .8rem;
    padding: .35rem .5rem;
    margin-top: .15rem;
    border-radius: 6px;
}
.input-sm {
    font-size: .82rem !important;
    padding: .4rem .55rem !important;
    border-radius: 6px !important;
}

label.checkbox {
    display: flex;
    align-items: center;
    gap: .55rem;
    font-weight: 400;
}
label.checkbox input { width: auto; margin: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 1rem; }

/* ---------- Botões ---------- */
.btn {
    display: inline-block;
    padding: .6rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font-weight: 600;
    font-size: .92rem;
    cursor: pointer;
    font-family: inherit;
    transition: all .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-block { width: 100%; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }

/* ---------- Mensagens (público) ---------- */
.entries { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 2.5rem; }
.entry-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    display: flex;
    gap: 1rem;
    box-shadow: var(--shadow);
}
.entry-avatar {
    flex: 0 0 44px;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
}
.entry-body { flex: 1; min-width: 0; }
.entry-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.entry-name { font-weight: 600; }
.entry-date { color: var(--muted); font-size: .82rem; }
.entry-message { margin-top: .4rem; word-wrap: break-word; }
.entry-message p { margin: 0 0 .5rem; }
.entry-message p:last-child { margin-bottom: 0; }

.empty-state {
    text-align: center;
    color: var(--muted);
    padding: 2rem;
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

/* ---------- Paginação ---------- */
.pagination { display: flex; gap: .4rem; justify-content: center; flex-wrap: wrap; margin-top: 1rem; }
.page-link {
    padding: .4rem .8rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-weight: 500;
}
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-link:hover { text-decoration: none; }

/* ---------- Alertas ---------- */
.alert { padding: .85rem 1.1rem; border-radius: 10px; margin-bottom: 1rem; font-weight: 500; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-bg); color: #991b1b; border: 1px solid #fecaca; }
.alert ul { margin: 0; padding-left: 1.2rem; }

/* ---------- Login ---------- */
.login-wrap { max-width: 400px; margin: 2rem auto; }
.login-card h1 { margin-top: 0; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }

/* ---------- Painel admin ---------- */
.admin-body { background: #eef0f8; }
.dash-head h1 { margin: 0 0 1rem; }
.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-num { display: block; font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: .85rem; }

.filter-tabs { display: flex; gap: .5rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.tab {
    padding: .45rem .9rem;
    border-radius: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--muted);
    font-weight: 500;
    font-size: .9rem;
}
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.tab:hover { text-decoration: none; }

.admin-entries { display: flex; flex-direction: column; gap: 1rem; }
.admin-entry {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.2rem;
    box-shadow: var(--shadow);
}
.admin-entry-head { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .35rem; }
.admin-entry-meta { font-size: .82rem; margin-bottom: .5rem; }
.admin-entry-message { word-wrap: break-word; }
.admin-entry-actions { display: flex; gap: .5rem; margin-top: .9rem; flex-wrap: wrap; align-items: center; }
.admin-entry-actions form { margin: 0; }

.badge { font-size: .72rem; padding: .15rem .55rem; border-radius: 999px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.badge-success { background: var(--success-bg); color: #166534; }
.badge-danger { background: var(--danger-bg); color: #991b1b; }
.badge-warning { background: var(--warning-bg); color: #92400e; }

.form-actions { display: flex; gap: .6rem; margin-top: .5rem; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.2rem 0; }

/* ---------- Instalador ---------- */
.install-page { padding: 2rem 0; }
.install-page .container { max-width: 720px; }
.captcha-field strong { color: var(--primary); }

/* ---------- Lightbox ---------- */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 1rem;
    animation: fadeIn .25s ease;
}
.lightbox[hidden] { display: none; }
.lightbox img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 0 60px rgba(0,0,0,.5);
}
.lightbox-close {
    position: fixed;
    top: 18px;
    right: 24px;
    font-size: 38px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    z-index: 10001;
    line-height: 1;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.12);
    border-radius: 50%;
    transition: background .2s ease, transform .2s ease;
    user-select: none;
}
.lightbox-close:hover {
    background: rgba(255,255,255,.25);
    transform: scale(1.1);
}
.lightbox-caption {
    color: #ccc;
    margin-top: 1rem;
    font-size: .9rem;
    max-width: 90vw;
    text-align: center;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---------- Rodapé ---------- */
.site-footer {
    text-align: center;
    color: var(--muted);
    padding: 2rem 1rem;
    font-size: .85rem;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}

/* ---------- Responsivo ---------- */
@media (max-width: 640px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: 1fr 1fr; }
    .hero h1 { font-size: 1.6rem; }
    .header-inner { flex-direction: column; align-items: flex-start; }
    .entry-photos { grid-template-columns: repeat(2, 1fr); }
    .lightbox-close { top: 10px; right: 12px; width: 40px; height: 40px; font-size: 30px; }
}
