/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #EDEEF7 0%, #E4FBFF 100%);
    min-height: 100vh;
    position: relative;
}

/* Paper Texture Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.3) 1px, transparent 0);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: -1;
}

/* Color Palette Variables */
:root {
    --primary-color: #7868E6;
    --secondary-color: #B8B5FF;
    --accent-color: #FFB4B4;
    --background-light: #EDEEF7;
    --background-blue: #E4FBFF;
    --text-dark: #333;
    --text-light: #666;
    --white: #ffffff;
    --shadow: 0 4px 20px rgba(120, 104, 230, 0.15);
    --shadow-hover: 0 8px 30px rgba(120, 104, 230, 0.25);
    --border-radius: 16px;
    --transition: all 0.3s ease;
    
    /* Safe Area Insets - será sobrescrito pelo JavaScript */
    --statusbar-height: 28px;
    --actionbar-height: 45px;
    
    /* Native safe area support */
    --sat: env(safe-area-inset-top);
    --sar: env(safe-area-inset-right);
    --sab: env(safe-area-inset-bottom);
    --sal: env(safe-area-inset-left);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 2rem 0;
    text-align: center;
    box-shadow: var(--shadow);
    /* Padding-top será sobrescrito pela safe area abaixo */
}

.header__logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.header__logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    padding: 8px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.header__text {
    text-align: left;
}

.header__title {
    margin-bottom: 0.3rem;
    font-size: 2rem;
    font-weight: 700;
}

.header__icon {
    font-size: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

.header__icon svg {
    width: 32px;
    height: 32px;
    stroke: currentColor;
}

.header__subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
    margin: 0;
}

/* Main Content */
.main {
    padding: 3rem 0;
    min-height: calc(100vh - 200px);
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
}

.loading__spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--background-light);
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.card__title {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Forms */
.form-section {
    max-width: 600px;
    margin: 0 auto;
}

.form__group {
    margin-bottom: 1.5rem;
}

.form__label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
}

.form__input {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--background-light);
    border-radius: 12px;
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
}

.form__input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(120, 104, 230, 0.1);
}

.form__help {
    display: block;
    margin-top: 0.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 1rem 2rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    gap: 0.5rem;
    min-height: 48px;
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    box-shadow: var(--shadow);
}

.btn--primary:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.btn--secondary {
    background: var(--background-light);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn--secondary:hover {
    background: var(--primary-color);
    color: var(--white);
}

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

.btn--outline:hover {
    background: var(--primary-color);
    color: var(--white);
}

/* Current Week Card */
.current-week-card {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    border-radius: var(--border-radius);
    padding: 2.5rem 1.75rem;
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-hover);
}

.current-week-card__title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.current-week-card__week {
    margin: 1.25rem 0;
}

.week-number {
    font-size: 3.2rem;
    font-weight: bold;
    display: block;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.current-week-card__subtitle {
    font-size: 1rem;
    margin-bottom: 1rem;
    opacity: 0.9;
}

.current-week-card__dates {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Baby Info Card */
.baby-info-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    border-left: 4px solid var(--accent-color);
}

.baby-info-card__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.baby-info-card__icon {
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.baby-info-card__icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

.baby-development {
    line-height: 1.8;
}

.baby-development__item {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--background-light);
    border-radius: 8px;
    border-left: 3px solid var(--accent-color);
}

.baby-development__title {
    font-weight: 600;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

/* Calendar Section */
.calendar-section {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.calendar-section__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.calendar-section__icon {
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.calendar-section__icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

/* Calendar base styles */
.pregnancy-calendar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
    gap: 1rem;
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 1rem;
    justify-items: center;
    align-items: center;
}

.calendar-week {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid transparent;
    position: relative;
    width: 100%;
    max-width: 90px;
    min-width: 50px;
}

.calendar-week--past {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    color: var(--text-light);
    border: 1px solid #dee2e6;
}

.calendar-week--past:hover {
    background: linear-gradient(135deg, #e9ecef, #dee2e6);
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.calendar-week--current {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    box-shadow: 0 12px 35px rgba(120, 104, 230, 0.6);
    transform: scale(1.1);
    border: 3px solid var(--white);
}

.calendar-week--current::before {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 16px;
    z-index: -1;
    opacity: 0.3;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.05); opacity: 0.5; }
}

.calendar-week--future {
    background: linear-gradient(135deg, var(--background-blue), #f0f8ff);
    color: var(--primary-color);
    border: 1px solid var(--secondary-color);
}

.calendar-week--future:hover {
    background: linear-gradient(135deg, #e6f3ff, var(--background-blue));
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(120, 104, 230, 0.4);
    border-color: var(--primary-color);
}

/* Actions */
.actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 2rem;
}

/* Error Message */
.error-message {
    background: var(--accent-color);
    color: var(--white);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: center;
}

.error-message__content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.error-message__icon {
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.error-message__icon svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }

/* Footer */
.footer {
    background: var(--text-dark);
    color: var(--white);
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    /* padding-bottom: 80px;  */
}

.footer__text {
    opacity: 0.8;
}

.footer__text a {
    color: var(--secondary-color);
    text-decoration: none;
    transition: var(--transition);
}

.footer__text a:hover {
    color: var(--white);
    text-decoration: underline;
}

/* Mobile Navigation */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(120, 104, 230, 0.1);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: none; /* Hidden by default, shown only on mobile */
    /* padding: 8px 0 12px 0; */
    /* margin-bottom: 60px; */
}

/* Fallback for browsers that don't support backdrop-filter */
@supports not (backdrop-filter: blur(20px)) {
    .mobile-nav {
        background: var(--white);
        border-top: 1px solid var(--background-light);
    }
}

.mobile-nav__container {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 100%;
    margin: 0;
    padding: 0 16px;
}

.mobile-nav__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-light);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: 1;
    min-height: 56px;
    position: relative;
    border-radius: 12px;
    margin: 0 4px;
}

.mobile-nav__link:hover {
    color: var(--primary-color);
    background: rgba(120, 104, 230, 0.08);
    transform: translateY(-2px);
}

.mobile-nav__link--active {
    color: var(--primary-color);
    background: rgba(120, 104, 230, 0.12);
    transform: translateY(-2px);
}

.mobile-nav__link--active::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px;
    height: 4px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(120, 104, 230, 0.4);
}

.mobile-nav__icon {
    font-size: 1.4rem;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.mobile-nav__icon svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
}

.mobile-nav__link--active .mobile-nav__icon {
    transform: scale(1.1);
}

.mobile-nav__text {
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
    line-height: 1;
    letter-spacing: 0.3px;
}

/* Show mobile nav only on mobile devices */
@media (max-width: 768px) {
    .mobile-nav {
        display: block;
    }
    
    .footer {
        padding-bottom: 90px;
    }
    
    body {
        padding-bottom: 76px;
    }
    
    /* Touch improvements for mobile nav */
    .mobile-nav__link {
        min-height: 64px;
        padding: 12px 8px;
        -webkit-tap-highlight-color: rgba(120, 104, 230, 0.2);
    }
    
    .mobile-nav__icon {
        font-size: 1.6rem;
        margin-bottom: 4px;
    }
    
    .mobile-nav__icon svg {
        width: 22px;
        height: 22px;
    }
    
    .mobile-nav__text {
        font-size: 0.75rem;
    }
    
    /* Header responsivo */
    .header__logo-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .header__logo {
        width: 70px;
        height: 70px;
    }
    
    .header__text {
        text-align: center;
    }
    
    .header__title {
        font-size: 1.5rem;
    }
    
    .header__subtitle {
        font-size: 0.95rem;
    }
}

/* Responsive Design */
@media (max-width: 1200px) and (min-width: 1025px) {
    .pregnancy-calendar {
        grid-template-columns: repeat(auto-fit, minmax(65px, 1fr));
        gap: 0.85rem;
        max-width: 850px;
    }
    
    .calendar-week {
        font-size: 1rem;
        max-width: 85px;
    }
    
    .calendar-section {
        padding: 1.8rem;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .pregnancy-calendar {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
        gap: 0.7rem;
        max-width: 750px;
    }
    
    .calendar-week {
        font-size: 0.95rem;
        max-width: 80px;
    }
    
    .calendar-section {
        padding: 1.5rem;
    }
}

@media (max-width: 768px) and (min-width: 481px) {
    .container {
        padding: 0 15px;
    }
    
    .header__title {
        font-size: 2rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header__subtitle {
        font-size: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .calendar-section {
        padding: 1.25rem;
    }
    
    .current-week-card {
        padding: 2rem 1.5rem;
    }
    
    .week-number {
        font-size: 3rem;
    }
    
    .pregnancy-calendar {
        grid-template-columns: repeat(auto-fit, minmax(55px, 1fr));
        gap: 0.6rem;
        max-width: 650px;
        padding: 0.75rem;
    }
    
    .calendar-week {
        font-size: 0.9rem;
        border-radius: 10px;
        max-width: 75px;
        min-width: 45px;
    }
    
    .actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .btn {
        width: 100%;
    }
}

/* Small Mobile */
@media (max-width: 480px) and (min-width: 361px) {
    .main {
        padding: 2rem 0;
    }
    
    .header {
        padding: 1.5rem 0;
    }
    
    .header__logo {
        width: 60px;
        height: 60px;
    }
    
    .header__title {
        font-size: 1.3rem;
    }
    
    .header__subtitle {
        font-size: 0.85rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .calendar-section {
        padding: 1rem;
    }
    
    .current-week-card {
        padding: 1.5rem 1rem;
    }
    
    .week-number {
        font-size: 2.5rem;
    }
    
    .pregnancy-calendar {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 0.5rem;
        max-width: 100%;
        padding: 0.5rem;
    }
    
    .calendar-week {
        font-size: 0.85rem;
        border-radius: 8px;
        max-width: 65px;
        min-width: 40px;
    }
    
    .calendar-week--current {
        transform: scale(1.08);
    }
    
    .calendar-week--current::before {
        animation: pulse 2s infinite;
        opacity: 0.3;
    }
    
    .calendar-week:hover {
        transform: translateY(-2px);
    }
}

/* Extra Small Mobile */
@media (max-width: 360px) {
    .main {
        padding: 1.5rem 0;
    }
    
    .header {
        padding: 1rem 0;
    }
    
    .header__logo {
        width: 50px;
        height: 50px;
    }
    
    .header__title {
        font-size: 1.15rem;
    }
    
    .header__subtitle {
        font-size: 0.8rem;
    }
    
    .card {
        padding: 0.9rem;
    }
    
    .calendar-section {
        padding: 0.85rem;
    }
    
    .current-week-card {
        padding: 1.2rem 0.8rem;
    }
    
    .week-number {
        font-size: 2.2rem;
    }
    
    .pregnancy-calendar {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
        gap: 0.4rem;
        max-width: 100%;
        padding: 0.4rem;
    }
    
    .calendar-week {
        font-size: 0.75rem;
        border-radius: 7px;
        max-width: 55px;
        min-width: 38px;
    }
    
    .calendar-week--current {
        transform: scale(1.05);
    }
    
    .calendar-week--current::before {
        animation: none;
        opacity: 0.25;
    }
    
    .calendar-week:hover {
        transform: translateY(-1px);
    }
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .actions {
        display: none;
    }
    
    .main {
        padding: 0;
    }
    
    .card,
    .current-week-card,
    .baby-info-card,
    .calendar-section {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Styles for Better Accessibility */
button:focus,
input:focus,
.calendar-week:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
    :root {
        --shadow: 0 2px 8px rgba(0,0,0,0.5);
        --shadow-hover: 0 4px 16px rgba(0,0,0,0.6);
    }
    
    .card,
    .current-week-card,
    .baby-info-card,
    .calendar-section {
        border: 2px solid var(--text-dark);
    }
}

/* Tips Category Icons */
.tips-category__icon svg {
    vertical-align: middle;
}

/* Device Bar Spacers - Integração com as barras do sistema */
#device-statusbar-spacer {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--statusbar-height, 28px);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    z-index: 99999 !important;
    pointer-events: none !important;
    display: block !important;
    box-shadow: 0 2px 8px rgba(120, 104, 230, 0.2);
    margin: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

#device-actionbar-spacer {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: var(--actionbar-height, 45px);
    background: rgba(255, 255, 255, 0.98);
    z-index: 9998 !important;
    pointer-events: none !important;
    display: block !important;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
    margin: 0 !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Ajuste do header para acomodar a status bar com safe area */
.header {
    /* A statusbar-spacer é fixed, então precisamos empurrar o header para baixo */
    padding-top: calc(2rem + var(--statusbar-height, 28px));
    padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px));
}

/* Ajuste da navegação mobile para acomodar a action bar com safe area */
.mobile-nav {
    bottom: calc(var(--actionbar-height, 45px) + env(safe-area-inset-bottom, 0px));
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* Ajuste do footer para acomodar a action bar com safe area */
.footer {
    padding-bottom: calc(20px + var(--actionbar-height, 45px) + env(safe-area-inset-bottom, 0px));
    /* padding-left: max(20px, env(safe-area-inset-left, 0px));
    padding-right: max(20px, env(safe-area-inset-right, 0px)); */
}

/* Ajuste do padding do body com safe area */
body {
    padding-top: 0 !important;
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
}

/* Ajuste do container para safe area */
.container {
    padding-left: max(20px, env(safe-area-inset-left, 20px));
    padding-right: max(20px, env(safe-area-inset-right, 20px));
}
