/* 
   PetID Modern Design System 
   Style: Minimalist, Premium, Soft UI
*/

:root {
    /* Palette - Premium & Clean */
    --primary-color: #4F46E5;
    /* Indigo 600 - Deep, trustworthy */
    --primary-hover: #4338CA;
    /* Indigo 700 */
    --secondary-color: #F472B6;
    /* Pink 400 - Friendly accent */
    --accent-color: #818CF8;
    /* Indigo 400 */

    /* Neutral Scales */
    --bg-body: #F8FAFC;
    /* Slate 50 - Soft background */
    --bg-surface: #FFFFFF;
    /* White surface */
    --text-main: #1E293B;
    /* Slate 800 - High contrast text */
    --text-muted: #64748B;
    /* Slate 500 - Secondary text */
    --border-light: #E2E8F0;
    /* Slate 200 - Subtle borders */

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #4F46E5 0%, #818CF8 100%);
    --gradient-soft: linear-gradient(135deg, #F8FAFC 0%, #E2E8F0 100%);
    --gradient-glow: radial-gradient(circle at top right, rgba(79, 70, 229, 0.1), transparent 40%);

    /* Shadows - Soft & Diffused */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.05), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.06);

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;
    --radius-full: 9999px;

    /* Transitions */
    --transition-base: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset & Typography */
body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-main);
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: var(--transition-base);
}

a:hover {
    color: var(--primary-hover);
}

/* Utilities */
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bg-gradient-primary {
    background: var(--gradient-primary);
}

.glass-effect {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
}

.section-padding {
    padding-top: 5rem;
    padding-bottom: 5rem;
}

@media (max-width: 768px) {
    .section-padding {
        padding-top: 3rem;
        padding-bottom: 3rem;
    }
}

/* Components: Buttons */
.btn {
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-full);
    transition: var(--transition-base);
    border: none;
    letter-spacing: 0.01em;
}

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

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

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

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.btn-white:hover {
    background: #f8fafc;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Components: Cards */
.card {
    background: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: var(--transition-base);
    overflow: hidden;
}

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

.card-pet {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card-pet img {
    transition: var(--transition-smooth);
    width: 100%;
    height: 250px;
    object-fit: cover;
}

.card-pet:hover img {
    transform: scale(1.05);
}

.card-body {
    padding: 2rem;
}

/* Components: Navbar */
.navbar {
    padding-top: 1.5rem;
    padding-bottom: 1.5rem;
    transition: var(--transition-base);
}

.navbar-brand {
    font-weight: 800;
    font-size: 1.5rem;
    letter-spacing: -0.03em;
    color: var(--text-main) !important;
}

.nav-link {
    font-weight: 500;
    color: var(--text-muted) !important;
    margin-left: 1rem;
    margin-right: 1rem;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color) !important;
}

.nav-link::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 50%;
    background-color: var(--primary-color);
    transition: var(--transition-base);
    transform: translateX(-50%);
}

.nav-link:hover::after {
    width: 20px;
}

/* Components: Forms */
.form-control {
    background-color: #F1F5F9;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    color: var(--text-main);
    transition: var(--transition-base);
}

.form-control:focus {
    background-color: white;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.form-label {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-up {
    animation: fadeInUp 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.delay-100 {
    animation-delay: 0.1s;
}

.delay-200 {
    animation-delay: 0.2s;
}

.delay-300 {
    animation-delay: 0.3s;
}

@keyframes wobble-vertical {
  16.65% { transform: translateY(8px); }
  33.3% { transform: translateY(-6px); }
  49.95% { transform: translateY(4px); }
  66.6% { transform: translateY(-2px); }
  83.25% { transform: translateY(1px); }
  100% { transform: translateY(0); }
}

.wobble-vertical {
  animation-name: wobble-vertical;
  animation-duration: 1s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: 1;
}

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

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94A3B8;
}

/* Footer */
footer {
    background-color: white;
    border-top: 1px solid var(--border-light);
}

/* Pet Cards - Instagram Style */
.pet-card-instagram {
    transition: var(--transition-base);
    border-radius: 12px;
    overflow: hidden;
}

.pet-card-instagram:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px -8px rgba(0, 0, 0, 0.12);
}

.pet-card-instagram img {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pet-card-instagram:hover img {
    transform: scale(1.05);
}

/* Action bar icons */
.pet-card-instagram .card-body a,
.pet-card-instagram .card-body button {
    transition: var(--transition-base);
}

.pet-card-instagram .card-body a:hover,
.pet-card-instagram .card-body button:hover {
    transform: scale(1.15);
    color: var(--primary-color) !important;
}

/* Dropdown positioning fix */
.dropdown-menu {
    margin-top: 0.25rem !important;
    font-size: 0.9rem;
}

/* Badge improvements */
.badge {
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Compact spacing for grid */
.row.g-3 {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}

.row.g-3>* {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .pet-card-instagram .card-body {
        padding: 0.75rem !important;
    }

    .pet-card-instagram h3 {
        font-size: 0.9rem;
    }
}

/* Profile Header - Instagram Style */
.profile-header-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid white;
    box-shadow: var(--shadow-md);
}

@media (min-width: 768px) {
    .profile-header-img {
        width: 180px;
        height: 180px;
    }
}

.profile-stats {
    display: flex;
    justify-content: space-around;
    text-align: center;
}

.profile-stat-item {
    display: flex;
    flex-direction: column;
}

.profile-stat-value {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
}

.profile-stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Button Fixes */
.btn-check:checked+.btn,
.btn.active,
.btn.show,
.btn:first-child:active,
:not(.btn-check)+.btn:active {
    color: white;
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.btn-instagram {
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
    border: none;
    transition: var(--transition-base);
}

.btn-instagram:hover {
    opacity: 0.9;
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Sticky Sidebar */
.sticky-sidebar {
    position: sticky;
    top: 100px;
    z-index: 10;
}

/* Modern Message Form */
.message-form-card {
    border: none;
    background: var(--bg-surface);
    box-shadow: var(--shadow-md);
    transition: var(--transition-base);
}

.message-form-card:focus-within {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.message-input {
    background-color: #F8FAFC;
    border: 1px solid transparent;
    transition: var(--transition-base);
    resize: none;
}

.message-input:focus {
    background-color: white;
    border-color: var(--primary-color);
    box-shadow: none;
}

/* Dr. Rufos Chat Widget - Modern & Responsive */
.glass-effect-chat {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.bg-gradient-primary {
    background: linear-gradient(135deg, #4F46E5 0%, #818CF8 100%);
}

.btn-white-glass {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s;
}

.btn-white-glass:hover {
    background: rgba(255, 255, 255, 0.4);
    color: white;
    transform: scale(1.1);
}

.chat-toggle-btn {
    animation: pulse-soft 3s infinite;
    border: 4px solid rgba(255, 255, 255, 0.8);
}

.chat-toggle-btn:hover {
    transform: scale(1.1) rotate(-5deg);
    box-shadow: 0 15px 30px rgba(79, 70, 229, 0.4) !important;
}

@keyframes pulse-soft {
    0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(79, 70, 229, 0); }
    100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}

#dr-rufos-window {
    transform-origin: bottom right;
    animation: chatPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

@keyframes chatPopIn {
    from { opacity: 0; transform: scale(0.8) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Scrollbar Styling */
.scrollbar-hidden::-webkit-scrollbar {
    width: 6px;
}
.scrollbar-hidden::-webkit-scrollbar-track {
    background: transparent;
}
.scrollbar-hidden::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 20px;
}

/* Message Bubbles */
.chat-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    animation: messageSlideIn 0.3s ease-out forwards;
    opacity: 0;
    transform: translateY(10px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
}

.chat-bubble.user {
    background: linear-gradient(135deg, #4F46E5 0%, #6366F1 100%);
    color: white;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.chat-bubble.assistant {
    background: #FFFFFF;
    color: #1E293B;
    border-bottom-left-radius: 4px;
    margin-right: auto;
    border: 1px solid #E2E8F0;
}

@keyframes messageSlideIn {
    to { opacity: 1; transform: translateY(0); }
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    border: 1px solid #E2E8F0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #94A3B8;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chat Widget Base Styles */
#dr-rufos-widget-container {
    pointer-events: none; /* Permite clicar através da área vazia do container */
}

#dr-rufos-widget-container > * {
    pointer-events: auto; /* Reativa cliques nos filhos (botão, janela) */
}

#dr-rufos-window {
    width: 380px;
    height: 600px;
    border-radius: 1.5rem;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#dr-rufos-toggle {
    width: 80px;
    height: 80px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
}

/* Mobile Responsiveness */
@media (max-width: 576px) {
    #dr-rufos-widget-container {
        right: 0 !important;
        bottom: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100%;
        height: 100%; /* Ocupa tela toda para gerenciar layout, mas pointer-events: none evita bloqueio */
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        align-items: flex-end;
        z-index: 9999; /* Garante que fique acima de tudo */
    }

    #dr-rufos-toggle {
        margin-bottom: 20px;
        margin-right: 20px;
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
        min-height: 60px !important;
        flex: 0 0 auto !important;
        pointer-events: auto;
    }

    #dr-rufos-window {
        width: 100% !important;
        height: 100% !important; /* Full screen em mobile */
        max-height: 100% !important;
        border-radius: 0 !important;
        margin-bottom: 0 !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10000; /* Acima do toggle */
        pointer-events: auto;
    }
    
    #dr-rufos-window.d-none {
        display: none !important;
    }

    /* Ajustes internos do chat para mobile */
    #dr-rufos-window .card-header {
        padding: 1rem !important;
        border-radius: 0;
    }

    #dr-rufos-window .card-body {
        padding: 1rem !important;
    }

    #dr-rufos-window .card-footer {
        padding: 1rem !important;
        background: #fff; /* Garantir fundo sólido no input */
    }

    /* Esconder botão toggle quando chat aberto em mobile */
    #dr-rufos-window:not(.d-none) ~ #dr-rufos-toggle {
        display: none !important;
    }
}

/* ===============================================
   PWA STYLES
   =============================================== */

/* Modo PWA instalado */
body.pwa-mode {
    /* Ajustes quando rodando como app instalado */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

body.pwa-mode .navbar {
    /* Safe area para notch em iPhones */
    padding-top: env(safe-area-inset-top);
}

body.pwa-mode main {
    /* Safe area para home indicator */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Offline indicator */
#offline-indicator {
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* PWA Install Banner */
#pwa-install-banner {
    animation: slideUp 0.4s ease-out;
    backdrop-filter: blur(10px);
    background: rgba(79, 70, 229, 0.95) !important;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, 100%);
        opacity: 0;
    }
    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Página Offline */
.offline-illustration {
    width: 150px;
    height: 150px;
    background: linear-gradient(135deg, var(--bg-surface) 0%, var(--border-light) 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 20px rgba(79, 70, 229, 0);
    }
}

/* Splash screen styles (para quando o app carrega) */
.pwa-splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.5s ease;
}

.pwa-splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.pwa-splash-logo {
    animation: bounceIn 0.6s ease-out;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Pull to refresh indicator (para futura implementação) */
.ptr-element {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    color: var(--text-muted);
    z-index: 10;
    text-align: center;
    height: 50px;
    transition: all 0.25s ease;
}

.ptr-element .ptr-icon {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.ptr-element.ptr-loading .ptr-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Bottom navigation para PWA (opcional, para mobile) */
.pwa-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-light);
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    display: none;
    justify-content: space-around;
    z-index: 1000;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.05);
}

body.pwa-mode .pwa-bottom-nav {
    display: flex;
}

.pwa-bottom-nav .nav-item {
    flex: 1;
    text-align: center;
}

.pwa-bottom-nav .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.75rem;
    transition: var(--transition-base);
}

.pwa-bottom-nav .nav-link i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.pwa-bottom-nav .nav-link.active,
.pwa-bottom-nav .nav-link:hover {
    color: var(--primary-color);
}

/* Ajuste do main quando bottom nav está visível */
body.pwa-mode main {
    padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* Esconder Dr. Rufos button quando bottom nav visível em PWA mobile */
@media (max-width: 768px) {
    body.pwa-mode #dr-rufos-widget-container {
        bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    }
}