:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-main: #2c3e50;
    --text-muted: #6c757d;
    --primary: #008b8b;
    /* Dark Cyan - Elegante */
    --primary-hover: #007676;
    --secondary-color: #16a085;
    /* Used in dashboard cards */
    --accent-color: #2980b9;
    /* Used in dashboard/badges */
    --danger: #e74c3c;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.04);
    --radius: 8px;
    --header-height: 60px;
}

/* =========================================
   1. RESET & BASE
   ========================================= */
body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding-top: var(--header-height);
    line-height: 1.6;
}

a {
    text-decoration: none;
    color: inherit;
    transition: 0.3s;
}

* {
    box-sizing: border-box;
}

/* =========================================
   2. HEADER FIXO
   ========================================= */
header,
.main-header {
    background: #fff;
    height: var(--header-height);
    position: fixed;
    top: 0;
    width: 100%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary);
    letter-spacing: 0.5px;
}

nav a {
    margin-left: 20px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
}

nav a:hover {
    color: var(--primary);
}

/* =========================================
   3. LAYOUT & CONTAINERS
   ========================================= */
.container {
    max-width: 1000px;
    margin: 30px auto;
    background: var(--card-bg);
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 30px;
    margin-bottom: 30px;
}

h1 {
    font-weight: 300;
    text-align: center;
    margin-bottom: 30px;
    color: var(--text-main);
}

h1.page-title {
    text-align: left;
    margin: 0;
    font-size: 1.8em;
    color: var(--primary);
}

h2 {
    font-size: 1.4em;
    color: var(--text-main);
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
    margin-top: 25px;
}

/* =========================================
   4. FORMULÁRIOS ELEGANTES
   ========================================= */
fieldset {
    border: 1px solid #eee;
    border-radius: var(--radius);
    padding: 25px;
    margin-bottom: 25px;
    background-color: #fafafa;
}

legend {
    font-weight: 600;
    color: var(--primary);
    padding: 0 10px;
    font-size: 1.1em;
    background: var(--card-bg);
    border-radius: 4px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border 0.3s;
    background: #fff;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    outline: none;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 139, 139, 0.1);
}

/* Helpers de Formulário */
.field-group {
    margin-bottom: 15px;
}

/* Legacy support */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.form-row .form-group {
    flex: 1;
    min-width: 280px;
}

/* Checkboxes & Radios */
.checkbox-group label,
.radio-group label {
    margin-right: 15px;
    display: inline-flex;
    align-items: center;
    font-weight: normal;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"],
.radio-group input {
    margin-right: 8px;
    width: auto;
}

/* =========================================
   5. BOTÕES MODERNOS
   ========================================= */
button,
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    text-align: center;
    color: white;
    text-decoration: none;
}

button[type="submit"],
.btn-primary {
    background-color: var(--primary);
    color: white;
    box-shadow: 0 4px 6px rgba(0, 139, 139, 0.2);
}

button[type="submit"]:hover,
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

button:disabled {
    background-color: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background-color: var(--text-muted);
    color: white;
}

.btn-gallery {
    background-color: #8e44ad;
    color: white;
}

/* Roxo */
.btn-danger,
.icon-btn-delete {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-back {
    background-color: #95a5a6;
    color: white;
}

.btn-back:hover {
    background-color: #7f8c8d;
}

.btn-print {
    background-color: var(--accent-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background-color: var(--primary);
    color: white;
}

/* Action Icons - Small Helper Buttons */
.action-links {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.icon-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85em;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

/* Variation for gerenciar_clientes actions */
.btn-new-anamnese {
    background-color: #e3f2fd;
    color: #1565c0;
}

.btn-new-anamnese:hover {
    background-color: #bbdefb;
}

.btn-new-ficha {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.btn-new-ficha:hover {
    background-color: #c8e6c9;
}

.btn-view-fichas {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.btn-view-fichas:hover {
    background-color: #e1bee7;
}


/* =========================================
   6. TABELAS CLEAN
   ========================================= */
.table-container {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0;
    min-width: 600px;
}

th {
    text-align: left;
    padding: 15px;
    background: #f8f9fa;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 2px solid #eee;
    text-transform: uppercase;
    font-size: 0.9em;
}

td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    color: #555;
    vertical-align: middle;
}

tr:hover {
    background-color: #fcfcfc;
}

.actions-cell {
    text-align: right;
}

/* =========================================
   7. BADGES (MODULE)
   ========================================= */
.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    display: inline-block;
}

.badge-anamnese {
    background-color: #e3f2fd;
    color: #1565c0;
}

.badge-generica {
    background-color: #e8f5e9;
    color: #2e7d32;
}

/* =========================================
   8. DASHBOARD MODULE
   ========================================= */
.welcome-section {
    background-color: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    border-left: 5px solid var(--secondary-color);
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.dash-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 180px;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.dash-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

.card-icon {
    font-size: 2.5em;
    margin-bottom: 15px;
}

.card-title {
    font-size: 1.4em;
    font-weight: 600;
    color: var(--primary);
}

.card-desc {
    color: #7f8c8d;
    font-size: 0.9em;
    margin-top: 5px;
}

.card-stat {
    position: absolute;
    bottom: 20px;
    right: 20px;
    font-size: 2.5em;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.05);
}

.card-clients {
    border-bottom: 4px solid var(--accent-color);
}

.card-clients .card-icon {
    color: var(--accent-color);
}

.card-new {
    border-bottom: 4px solid var(--secondary-color);
}

.card-new .card-icon {
    color: var(--secondary-color);
}

/* =========================================
   9. GALLERY MODULE
   ========================================= */
.page-header {
    background-color: var(--card-bg);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
}

.filter-btn {
    background-color: var(--card-bg);
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 20px;
    cursor: pointer;
    color: var(--text-main);
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    font-family: inherit;
}

.filter-btn:hover,
.filter-btn.active {
    background-color: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

.gallery-item {
    background-color: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 10px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    position: relative;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.image-container {
    height: 200px;
    overflow: hidden;
    border-radius: 6px;
    position: relative;
    cursor: zoom-in;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.gallery-item:hover .image-container img {
    transform: scale(1.05);
}

.category-tag {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    text-transform: uppercase;
    font-weight: 600;
}

.delete-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(231, 76, 60, 0.9);
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 5;
    font-size: 14px;
}

.image-container:hover .delete-btn {
    opacity: 1;
}

.delete-btn:hover {
    transform: scale(1.1);
    background-color: #c0392b;
}

.item-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 5px 0;
    font-size: 0.85em;
    color: var(--text-muted);
}

.origin-badge {
    color: var(--accent-color);
    font-weight: 600;
    background-color: rgba(52, 152, 219, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.lightbox img {
    max-width: 90%;
    max-height: 90vh;
    border-radius: 4px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s;
}

@keyframes zoomIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: #fff;
    font-size: 40px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.3s;
}

.lightbox-close:hover {
    opacity: 1;
}

/* =========================================
   10. MEDIA VAULT & UPLOAD (Novos)
   ========================================= */
.upload-area {
    border: 2px dashed #9b59b6;
    padding: 30px;
    text-align: center;
    border-radius: var(--radius);
    background-color: #fbf6ff;
    margin-bottom: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.upload-area:hover {
    background-color: #f5eef9;
}

.upload-area p {
    color: #8e44ad;
    font-weight: 600;
    margin: 0;
}

.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.preview-item {
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    padding: 8px;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.preview-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 10px;
}

.preview-item select {
    margin-bottom: 0;
    font-size: 0.9em;
    padding: 6px;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.existing-media-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

.existing-item {
    width: 130px;
    text-align: center;
}

.existing-item img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #ddd;
    transition: transform 0.2s;
    cursor: pointer;
}

.existing-item img:hover {
    transform: scale(1.05);
}

.existing-item span {
    display: block;
    font-size: 0.75em;
    color: #7f8c8d;
    margin-top: 5px;
    text-transform: uppercase;
    font-weight: 600;
}

/* =========================================
   11. SIGNATURE PAD & MODALS
   ========================================= */
.signature-pad {
    border: 2px dashed #bdc3c7;
    border-radius: 6px;
    width: 100%;
    height: 160px;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.signature-pad:hover {
    border-color: var(--primary);
    background-color: #f9f9f9;
}

.signature-image {
    border: 1px solid #ddd;
    background: #fff;
    padding: 5px;
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-top: 10px;
}

.signature-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
}

.signature-modal-content {
    background-color: #fff;
    padding: 25px;
    border-radius: 8px;
    width: 95%;
    height: 85%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
}

#modal-signature-canvas {
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    flex-grow: 1;
    margin: 15px 0;
    touch-action: none;
    background: #fff;
}

.modal-buttons {
    text-align: center;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.action-button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: white;
    font-weight: 600;
}

.success-message {
    display: none;
    padding: 15px;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    text-align: center;
    margin-bottom: 20px;
}

.legal-term {
    background-color: #edf2f7;
    border-left: 4px solid var(--primary);
    padding: 15px;
    font-size: 0.9em;
    color: var(--text-main);
    margin-bottom: 20px;
    border-radius: 0 4px 4px 0;
}

.hidden-field-details {
    display: none;
    margin-top: 10px;
    padding-left: 15px;
    border-left: 3px solid var(--secondary-color);
}

/* =========================================
   12. LOGIN PAGE
   ========================================= */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    background-color: var(--bg-color);
}

.login-container {
    background: #fff;
    padding: 40px;
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo {
    margin-bottom: 20px;
    font-size: 3em;
    color: var(--secondary-color);
}

.error-message {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 25px;
    font-size: 0.9em;
}

/* =========================================
   13. RESPONSIVE & PRINT
   ========================================= */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 15px;
    }

    nav a {
        display: block;
        margin: 10px 0;
    }

    .page-header {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .filters {
        gap: 5px;
    }

    .filter-btn {
        padding: 6px 15px;
        font-size: 0.9em;
    }

    .form-row {
        flex-direction: column;
    }

    .dash-grid {
        grid-template-columns: 1fr;
    }
}

@media print {

    .main-header,
    .header-actions,
    .btn,
    .lightbox,
    header,
    .action-links,
    .upload-area,
    .button-container {
        display: none !important;
    }

    body {
        background: white;
        margin: 0;
        padding-top: 0;
    }

    .container {
        max-width: 100%;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: none;
    }

    .card {
        box-shadow: none;
        padding: 0;
        margin: 0;
        border: none;
    }

    .content-box {
        border: 1px solid #ddd;
    }

    @page {
        margin: 2cm;
    }
}