:root {
    --primary-color: #0D3C31;
    --primary-light: #155e4e;
    --accent-color: #E2B22E; /* Gold/Yellow as accent */
    --text-dark: #1F2937;
    --text-light: #6B7280;
    --bg-color: #F3F4F6;
    --white: #FFFFFF;
    --border-color: #E5E7EB;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

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

html, body {
    overflow-x: hidden; /* Evita que o fundo do body e do header "cortem" */
    width: 100%;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-dark);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
    background-color: var(--primary-color);
    color: var(--white);
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: var(--shadow-md);
    text-align: center;
}

@media (min-width: 640px) {
    .app-header {
        flex-direction: column;
        padding: 1.5rem 2rem;
        gap: 1rem;
    }
}

.logo {
    height: 50px;
    width: auto;
    object-fit: contain;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

/* Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .container {
        grid-template-columns: 1fr 1fr;
        padding: 2.5rem 1.5rem;
    }
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

.form-card h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
}

/* Forms */
.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.input-group input {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: #F9FAFB;
    box-sizing: border-box;
    min-height: 48px;
    -webkit-appearance: textfield;
    appearance: textfield;
}

input[type="date"],
input[type="time"] {
    padding-left: 0 !important;
    padding-right: 0 !important;
    text-align: center;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(13, 60, 49, 0.1);
    background-color: var(--white);
}

/* Visits Section */
.visits-container h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 1.5rem 0 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    color: var(--primary-color);
}

.visit-item {
    background-color: #F9FAFB;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    position: relative;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.visit-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 480px) {
    .visit-row {
        grid-template-columns: 100px 1fr 1fr;
    }
}

.btn-remove {
    position: absolute;
    top: -10px;
    right: -10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-color: #EF4444;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}

.btn-remove:hover {
    transform: scale(1.1);
}

.btn-remove svg {
    width: 14px;
    height: 14px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    width: 100%;
}

.btn-outline {
    background-color: transparent;
    border: 2px dashed var(--primary-light);
    color: var(--primary-light);
}

.btn-outline:hover {
    background-color: rgba(13, 60, 49, 0.05);
}

.btn-primary {
    background-color: var(--primary-color);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

/* Preview Section */
.preview-wrapper {
    background-color: #F9FAFB;
    display: flex;
    flex-direction: column;
}

.preview-header {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

@media (min-width: 640px) {
    .preview-header {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}

.preview-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
}

.canvas-container {
    display: flex;
    align-items: center;
    padding-bottom: 1rem;
    width: 100%;
    /* Removido o overflow-x: auto fixo porque o próprio card agora é responsivo e cabe na tela */
}

/* ========================================================
   CARTÃO DE AGENDA (O elemento que vira imagem) 
   ======================================================== */
.agenda-card {
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    min-height: 500px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #06241c 100%);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-lg);
    color: var(--white);
    display: flex;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
}

/* Formas decorativas no background do cartão */
.agenda-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(226, 178, 46, 0.2) 0%, rgba(226, 178, 46, 0) 70%);
    border-radius: 50%;
}

.agenda-card::after {
    content: '';
    position: absolute;
    bottom: 50px;
    left: -50px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0) 70%);
    border-radius: 50%;
}

.card-branding {
    padding: 1.25rem 1.5rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    z-index: 2;
}

@media (min-width: 400px) {
    .card-branding {
        padding: 1.5rem 2rem 0.75rem;
    }
}

.card-logo {
    height: 40px;
    width: auto;
    max-width: 70%;
    object-fit: contain;
}

.card-tagline {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 3px;
    color: var(--accent-color);
    text-transform: uppercase;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 0.5rem;
    width: 100%;
    text-align: center;
}

.card-header {
    padding: 0 1.5rem 1rem;
    position: relative;
    z-index: 2;
}

@media (min-width: 400px) {
    .card-header {
        padding: 0 2rem 1rem;
    }
}

.card-city {
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

@media (min-width: 400px) {
    .card-city {
        font-size: 1.6rem;
    }
}

.card-date {
    font-size: 1rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body {
    flex: 1;
    background-color: var(--white);
    color: var(--text-dark);
    margin: 0 1rem 1rem;
    border-radius: 12px;
    padding: 1rem;
    position: relative;
    z-index: 2;
}

/* Timeline */
.timeline {
    position: relative;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 24px;
    top: 10px;
    bottom: 10px;
    width: 2px;
    background-color: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-left: 55px;
    margin-bottom: 0.75rem;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-time {
    position: absolute;
    left: 0;
    top: 0;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    z-index: 2;
}

.timeline-content {
    background-color: #F9FAFB;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.3;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.timeline-empty {
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
    padding: 2rem 0;
    font-style: italic;
}

.card-footer {
    text-align: center;
    padding: 0 0 1.5rem;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.6);
    position: relative;
    z-index: 2;
    letter-spacing: 1px;
}

/* ========================================================
   MODAL DE OBSERVAÇÃO INTERNA (Glassmorphism & Blur)
   ======================================================== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(13, 60, 49, 0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    animation: fadeIn 0.2s ease-out;
}

.modal-backdrop.hidden {
    display: none;
}

.modal-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    animation: scaleUp 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleUp {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.125rem;
    color: var(--primary-color);
    margin: 0;
    font-weight: 600;
}

.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 50%;
    transition: background 0.2s;
}

.btn-icon:hover {
    background: #F3F4F6;
    color: var(--text-dark);
}

.modal-body label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
}

.modal-body textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    resize: vertical;
    background-color: #F9FAFB;
}

.modal-body textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(13, 60, 49, 0.1);
    background-color: var(--white);
}

.modal-footer {
    margin-top: 1.25rem;
    display: flex;
    justify-content: flex-end;
}

/* Botão em verde para Adicionar Observação */
.btn-obs-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.875rem;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem 0 0 0;
    margin-top: 0.5rem;
    transition: color 0.2s;
}

.btn-obs-link:hover {
    color: var(--primary-light);
    text-decoration: underline;
}

.btn-obs-link.has-obs {
    color: #059669; /* Verde esmeralda quando possui observação cadastrada */
}

.btn-obs-link svg {
    width: 14px;
    height: 14px;
}

/* Custom Autocomplete */
.autocomplete-items {
    position: absolute;
    border: 1px solid var(--border-color);
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--white);
    max-height: 200px;
    overflow-y: auto;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-md);
    display: none;
}
.autocomplete-items div {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}
.autocomplete-items div:hover {
    background-color: #F9FAFB;
}
