/**
 * Estilos Globais - Sistema de Apresentação de Bebês
 * Design UX estilo Apple com suporte a tema claro/escuro
 * Otimizado para iOS e Android
 */

/* ============================================
   ajuste mobile: iOS SAFE AREA & OPTIMIZATIONS
   ============================================ */

/* Safe Area Insets para iPhone X+ (notch) */
@supports (padding: max(0px)) {
    body {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
        padding-bottom: max(0px, env(safe-area-inset-bottom));
    }
    
    .public-header-content {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }
}

/* ajuste mobile: Performance Optimizations */
* {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ajuste mobile: Previne seleção acidental em gestos de swipe */
.banner-carousel-container,
.carousel,
.date-card {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* ============================================
   VARIÁVEIS DE TEMA
   ============================================ */

:root[data-theme="dark"] {
    --bg-primary: #070709;
    --bg-secondary: #0B0C10;
    --bg-card: #14151B;
    --bg-card-hover: #1F2028;
    --bg-input: #1F2028;
    --bg-button: #007AFF;
    --bg-button-hover: #0062CC;
    
    --text-primary: #F9FAFB;
    --text-secondary: #E5E7EB;
    --text-tertiary: #9CA3AF;
    --text-muted: #6B7280;
    
    --border-color: #2D2E38;
    --border-light: #1F2028;
    
    --color-primary: #007AFF;
    --color-secondary: #5856D6;
    --color-success: #34C759;
    --color-warning: #FF9500;
    --color-danger: #FF3B30;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.15);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.25);
    --shadow-lg: 0 18px 45px rgba(0,0,0,0.35);
}

:root[data-theme="light"] {
    --bg-primary: #F5F5F7;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F9FAFB;
    --bg-input: #F5F5F7;
    --bg-button: #007AFF;
    --bg-button-hover: #0062CC;
    
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6B7280;
    --text-muted: #9CA3AF;
    
    --border-color: #E5E7EB;
    --border-light: #F3F4F6;
    
    --color-primary: #007AFF;
    --color-secondary: #5856D6;
    --color-success: #34C759;
    --color-warning: #FF9500;
    --color-danger: #FF3B30;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 8px 24px rgba(0,0,0,0.08);
    --shadow-lg: 0 18px 45px rgba(0,0,0,0.12);
}

/* ============================================
   RESET E BASE
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

/* ============================================
   TIPOGRAFIA
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    color: var(--text-primary);
}

h1 { font-size: clamp(28px, 5vw, 42px); }
h2 { font-size: clamp(24px, 4vw, 32px); }
h3 { font-size: clamp(20px, 3vw, 24px); }
h4 { font-size: clamp(18px, 2.5vw, 20px); }

p {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: var(--color-secondary);
}

/* ============================================
   BOTÕES
   ============================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 8px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 18px;
    border-radius: 14px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

/* ============================================
   FORMULÁRIOS
   ============================================ */

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="date"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.12);
    transform: translateY(-1px);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

/* ============================================
   CARDS
   ============================================ */

.card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: var(--shadow-lg);
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    color: var(--text-secondary);
}

/* ============================================
   ALERTAS
   ============================================ */

.alert {
    padding: 14px 18px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(52, 199, 89, 0.1);
    color: var(--color-success);
    border: 1px solid rgba(52, 199, 89, 0.3);
}

.alert-error {
    background: rgba(255, 59, 48, 0.1);
    color: var(--color-danger);
    border: 1px solid rgba(255, 59, 48, 0.3);
}

.alert-warning {
    background: rgba(255, 149, 0, 0.1);
    color: var(--color-warning);
    border: 1px solid rgba(255, 149, 0, 0.3);
}

.alert-info {
    background: rgba(0, 122, 255, 0.1);
    color: var(--color-primary);
    border: 1px solid rgba(0, 122, 255, 0.3);
}

/* ============================================
   TOGGLE TEMA (Header)
   ============================================ */

.theme-toggle {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--bg-card-hover);
    transform: scale(1.05);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    fill: var(--text-primary);
}

/* ============================================
   UTILITÁRIOS
   ============================================ */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.flex {
    display: flex;
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* ============================================
   HEADER PÚBLICO RESPONSIVO (ajuste mobile)
   ============================================ */

.public-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.public-header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.public-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.public-logo img {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.public-logo-text {
    min-width: 0;
}

.public-logo-text h1 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.public-logo-text p {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ajuste mobile: Menu Hamburguer */
.menu-hamburger {
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 8px;
    border-radius: 12px;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.menu-hamburger:hover {
    background: var(--bg-input);
}

.menu-hamburger:active {
    transform: scale(0.95);
}

.menu-hamburger span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.3s ease;
    display: block;
}

.menu-hamburger.active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.menu-hamburger.active span:nth-child(2) {
    opacity: 0;
}

.menu-hamburger.active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* ajuste mobile: Menu Mobile */
.mobile-menu {
    max-height: 0;
    overflow: hidden;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.mobile-menu.active {
    max-height: 500px;
    padding: 12px 0;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-primary);
    text-decoration: none;
    transition: background 0.2s ease;
    font-size: 16px;
    font-weight: 500;
}

.mobile-menu-item:hover {
    background: var(--bg-input);
}

.mobile-menu-item svg {
    flex-shrink: 0;
}

/* ============================================
   RESPONSIVIDADE MOBILE-FIRST (ajuste mobile)
   ============================================ */

/* Base: Mobile First (< 480px) */
.container {
    width: 100%;
    padding: 0 16px;
    margin: 0 auto;
}

/* Botões mobile-friendly */
.btn {
    min-height: 44px; /* ajuste mobile: mínimo para touch */
    padding: 12px 20px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.98);
}

/* Cards empilhados */
.card {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
}

/* Inputs mobile-friendly */
.input, input[type="text"], input[type="email"], 
input[type="password"], input[type="tel"], 
input[type="url"], input[type="date"], 
input[type="number"], select, textarea {
    min-height: 44px; /* ajuste mobile: mínimo para touch */
    font-size: 16px; /* ajuste mobile: previne zoom no iOS */
    padding: 12px 16px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ajuste mobile: Remove destaque azul ao tocar (iOS/Android) */
a, button, input, select, textarea {
    -webkit-tap-highlight-color: transparent;
}

/* ajuste mobile: Smooth scroll nativo */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Imagens responsivas */
img {
    max-width: 100%;
    height: auto;
}

/* Tablet (≥ 768px) */
@media (min-width: 768px) {
    .container {
        max-width: 720px;
        padding: 0 24px;
    }
    
    .card {
        padding: 24px;
        border-radius: 16px;
    }
    
    /* Botões não ocupam 100% em tablet+ */
    .btn:not(.btn-block) {
        width: auto;
    }
    
    h1 { font-size: 36px; }
    h2 { font-size: 28px; }
    h3 { font-size: 22px; }
}

/* Desktop (≥ 1024px) */
@media (min-width: 1024px) {
    .container {
        max-width: 960px;
    }
    
    .card {
        padding: 32px;
        border-radius: 20px;
    }
}

/* Desktop Large (≥ 1280px) */
@media (min-width: 1280px) {
    .container {
        max-width: 1200px;
    }
}

/* Utilitários de responsividade */
@media (max-width: 767px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    
    /* ajuste mobile: Otimizações específicas para celular */
    body {
        font-size: 15px;
        line-height: 1.5;
    }
    
    /* ajuste mobile: Botões com feedback visual */
    .btn,
    .date-card,
    .mobile-menu-item,
    .banner-dot,
    .carousel-indicator {
        transition: transform 0.15s ease, background 0.2s ease;
    }
    
    .btn:active,
    .date-card:active,
    .mobile-menu-item:active {
        transform: scale(0.97);
    }
    
    /* ajuste mobile: Scroll suave em contêineres */
    .table-wrapper,
    .banner-carousel-container {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }
    
    /* ajuste mobile: Modal ocupa tela toda */
    .modal-overlay {
        padding: 0 !important;
    }
    
    /* ajuste mobile: Texto otimizado para leitura mobile */
    p, li {
        font-size: 15px;
        line-height: 1.6;
    }
    
    /* ajuste mobile: Links com área de toque maior */
    a:not(.btn):not(.mobile-menu-item) {
        padding: 4px 0;
        margin: -4px 0;
    }
}

@media (min-width: 768px) {
    .hide-desktop { display: none !important; }
    .show-desktop { display: block !important; }
    .show-mobile { display: none !important; }
}
