/* ===== VARIÁVEIS =====*/
:root {
    --primary: #4f46e5;      /* Indigo 600 */
    --primary-dark: #4338ca; /* Indigo 700 */
    --primary-light: #e0e7ff;/* Indigo 100 */
    --secondary: #ec4899;    /* Pink 500 */
    --success: #10b981;      /* Emerald 500 */
    --warning: #f59e0b;      /* Amber 500 */
    --danger: #ef4444;       /* Red 500 */
    
    --bg-color: #f3f4f6;     /* Gray 100 */
    --bg-card: #ffffff;
    
    --text-main: #111827;    /* Gray 900 */
    --text-muted: #6b7280;   /* Gray 500 */
    --border-color: #e5e7eb; /* Gray 200 */
    
    --border-radius: 16px;
    --border-radius-sm: 12px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 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);
    --shadow-fab: 0 8px 20px rgba(79, 70, 229, 0.4);
    
    --nav-height: 70px;
    --header-height: 80px;
}

/* ===== RESET & BASE =====*/
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden; /* Prevent body scroll, manage scroll in app-container */
}

body {
    position: fixed;
    display: flex;
    flex-direction: column;
}

/* ===== APP CONTAINER =====*/
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    width: 100vw;
    background: var(--bg-color);
    position: relative;
}

/* ===== HEADER =====*/
.header {
    height: var(--header-height);
    background: var(--bg-color);
    padding: max(16px, env(safe-area-inset-top)) 24px 16px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-titles .subtitle {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 2px;
}

.header-titles h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.header-profile img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: var(--shadow-sm);
    object-fit: cover;
}

/* ===== MAIN CONTENT =====*/
.main-content {
    flex: 1;
    overflow: hidden;
    position: relative;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
}

.tab-content {
    display: none;
    height: 100%;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 20px 24px;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== BOTTOM NAV =====*/
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding-bottom: env(safe-area-inset-bottom);
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.03);
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    height: 100%;
    transition: color 0.2s ease;
}

.nav-item i {
    font-size: 24px;
    transition: transform 0.2s ease;
}

.nav-item.active {
    color: var(--primary);
}

.nav-item.active i {
    font-family: 'Phosphor-Fill'; /* Switch to filled icon if using phosphor */
    transform: translateY(-2px);
}

/* FAB within Bottom Nav */
.fab-item {
    position: relative;
    top: -20px;
}

.fab-button {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: var(--shadow-fab);
    margin-bottom: 6px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fab-item span {
    margin-top: 2px;
}

.fab-item:active .fab-button {
    transform: scale(0.95);
    box-shadow: 0 4px 10px rgba(79, 70, 229, 0.4);
}

.fab-button i {
    font-size: 28px;
    color: white !important;
}

/* ===== CALENDAR CARD =====*/
.calendar-card {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    flex-shrink: 0;
}

.month-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.btn-nav {
    background: var(--bg-color);
    color: var(--text-main);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-nav:active {
    background: var(--border-color);
}

#monthYear {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
}

/* WEEKDAYS */
.weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    margin-bottom: 12px;
}

.weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
}

/* CALENDAR GRID */
.calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.day {
    aspect-ratio: 0.85; /* A bit taller than square */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 4px 1px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-top-width: 3px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    
    /* Prevenir seleção de texto e menus nativos ao segurar no celular */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Status do Dia (Cores da Borda Superior e Fundo leve) */
.day.status-livre { border-top-color: var(--success); }
.day.status-desativado { border-top-color: var(--danger); background-color: #fef2f2; color: var(--danger); opacity: 0.8; }
.day.status-lotado { border-top-color: var(--warning); background-color: #fffbeb; }
.day.status-parcial { border-top-color: var(--primary); }

.day:active {
    transform: scale(0.95);
}

.day.other-month {
    color: #cbd5e1;
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

.day.today {
    border: 2px solid var(--primary);
    background: white;
}

.day-number {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: auto;
}

.day-badge {
    font-size: 8px;
    background: var(--border-color);
    color: var(--text-main);
    padding: 2px 2px;
    border-radius: 4px;
    font-weight: 700;
    margin-top: 2px;
    width: 95%;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.day.status-parcial .day-badge { background: var(--primary-light); color: var(--primary-dark); }
.day.status-lotado .day-badge { background: #fef3c7; color: #b45309; }
.day.status-desativado .day-badge { background: #fee2e2; color: #991b1b; }

.calendar-legend {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-muted);
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
}
.legend-color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.config-status-card {
    padding: 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    text-align: center;
    margin-top: 16px;
    background: #f8fafc;
}
.config-status-card h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}
.config-status-card p {
    margin: 4px 0 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

.day.selected {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: var(--shadow);
}

.day.selected .day-badge {
    background: rgba(255, 255, 255, 0.3);
    color: white;
}

/* ===== APPOINTMENTS SECTION =====*/
.appointments-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.appointments-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.appointments-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.count-badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.appointments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 20px;
}

/* APPOINTMENT ITEM */
.appointment-item {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 16px;
    display: flex;
    gap: 16px;
    align-items: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.appointment-item:active {
    transform: scale(0.98);
}

.apt-time-box {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 10px;
    border-radius: var(--border-radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
}

.apt-time-box i {
    font-size: 16px;
    margin-bottom: 2px;
}

.apt-time-box span {
    font-size: 13px;
    font-weight: 700;
}

.apt-info {
    flex: 1;
    overflow: hidden;
}

.apt-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.apt-desc {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* EMPTY STATE */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 64px;
    color: #cbd5e1;
    margin-bottom: 16px;
}

.empty-state h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
}

/* ===== FORM SECTION =====*/
.form-section {
    padding-top: 10px;
}

.form-header {
    margin-bottom: 24px;
}

.form-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.form-header p {
    font-size: 14px;
    color: var(--text-muted);
}

.form-novo {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-left: 4px;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrapper i {
    position: absolute;
    left: 16px;
    font-size: 20px;
    color: var(--text-muted);
    pointer-events: none;
}

.input-wrapper input,
.input-wrapper textarea {
    width: 100%;
    padding: 16px 16px 16px 44px;
    border: 2px solid transparent;
    border-radius: var(--border-radius-sm);
    background: var(--bg-card);
    font-family: inherit;
    font-size: 15px;
    color: var(--text-main);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    -webkit-appearance: none;
}

.textarea-wrapper i {
    top: 16px;
}

.input-wrapper input:focus,
.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.input-wrapper input::placeholder,
.input-wrapper textarea::placeholder {
    color: #9ca3af;
}

.btn-submit {
    background: var(--primary);
    color: white;
    border: none;
    padding: 18px;
    border-radius: var(--border-radius-sm);
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
    margin-top: 10px;
}

.btn-submit i {
    font-size: 20px;
}

.btn-submit:active {
    transform: scale(0.98);
    background: var(--primary-dark);
}

/* ===== BOTTOM SHEET MODAL =====*/
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    bottom: -100%;
    transition: bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal.show {
    visibility: visible;
    opacity: 1;
}

.modal.show .modal-content {
    bottom: 0;
}

.modal-content {
    background: var(--bg-card);
    width: 100%;
    max-height: 90vh; /* Permite scroll se o teclado subir */
    overflow-y: auto;
    border-radius: 24px 24px 0 0;
    padding: 24px 20px 48px; /* Mais padding embaixo */
    position: relative;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1);
}

.modal-drag-handle {
    width: 40px;
    height: 5px;
    background: var(--border-color);
    border-radius: 3px;
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
}

.close {
    position: absolute;
    top: 24px;
    right: 24px;
    background: var(--bg-color);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

.close:active {
    background: var(--border-color);
}

#modalBody {
    overflow-y: auto;
    padding-top: 10px;
}

.modal-header-info {
    margin-bottom: 24px;
}

.modal-header-info h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.modal-header-info p {
    color: var(--text-muted);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.modal-details-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--bg-color);
    padding: 20px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 24px;
}

.detail-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.detail-icon {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 18px;
    box-shadow: var(--shadow-sm);
}

.detail-text {
    flex: 1;
}

.detail-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 2px;
}

.detail-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    word-break: break-word;
}

.btn-delete {
    background: var(--danger);
    color: white;
    border: none;
    padding: 16px;
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

.btn-delete:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* ===== TOAST =====*/
.toast {
    position: fixed;
    top: -100px; /* Start hidden above */
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: white;
    padding: 12px 20px;
    border-radius: 100px;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transition: top 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show {
    top: max(20px, env(safe-area-inset-top));
}

.toast.success { background: var(--text-main); }
.toast.success i { color: var(--success); }

.toast.error { background: var(--danger); }
.toast.error i { color: white; }

.toast.warning { background: var(--warning); }
.toast.warning i { color: white; }

.toast i {
    font-size: 20px;
}

/* ===== LOGIN SCREEN ===== */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 24px;
}

.login-card {
    background: var(--bg-card);
    width: 100%;
    max-width: 400px;
    padding: 40px 24px;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-logo {
    font-size: 56px;
    margin-bottom: 16px;
}

.login-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
}

.login-card p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 32px;
}

/* ===== SCROLLBAR HIDDEN =====*/
::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

@keyframes pulse-record {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.recording {
    background: var(--danger) !important;
    animation: pulse-record 1.5s infinite;
}

/* ===== DYNAMIC CALENDAR ICON ===== */
.dynamic-calendar {
    width: 60px;
    height: 60px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 auto;
    border: 1px solid var(--border-color);
}
.dynamic-calendar-header {
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    text-align: center;
    padding: 4px 0;
}
.dynamic-calendar-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 800;
    color: var(--text-main);
    background: white;
}

