/* =====================================================
   CESTOO - Global Styles
   Marketplace de Nutrição Saudável
   ===================================================== */

/* ----------------------------------------------------- 
   CSS VARIABLES & ROOT CONFIGURATION
   ----------------------------------------------------- */
:root {
    /* Brand Colors - Cestoo Visual Identity */
    --color-primary: #2E7D32;       /* Verde Machamba */
    --color-primary-hover: #1B5E20;
    --color-secondary: #4CAF50;      /* Verde Claro */
    --color-accent: #FF8F00;         /* Laranja Tropical */
    --color-highlight: #FBC02D;      /* Amarelo Milho */

    /* Neutral Colors */
    --color-gray-50: #f9fafb;
    --color-gray-100: #f3f4f6;
    --color-gray-200: #e5e7eb;
    --color-gray-300: #d1d5db;
    --color-gray-400: #9ca3af;
    --color-gray-500: #6b7280;
    --color-gray-600: #4b5563;
    --color-gray-700: #374151;
    --color-gray-800: #1f2937;
    --color-gray-900: #111827;

    /* Status Colors */
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;

    /* Mobile App Dimensions */
    --app-max-width: 480px;
    --app-min-height: 100vh;

    /* Spacing */
    --header-height: 56px;
    --footer-height: 64px;
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
}

/* ----------------------------------------------------- 
   MOBILE EMULATION (Clean - No Phone Frame)
   ----------------------------------------------------- */

html {
    display: flex;
    justify-content: center;
    background: #f1f5f9;
    min-height: 100vh;
}

body {
    max-width: var(--app-max-width);
    width: 100%;
    min-height: 100vh;
    margin: 0;
    background: white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow-x: hidden;
}

/* On mobile devices - no shadow, full width */
@media (max-width: 480px) {
    html {
        background: white;
    }
    body {
        box-shadow: none;
        max-width: 100%;
    }
}

/* Constrain fixed elements to mobile width */
nav.fixed,
.fixed.top-0,
.fixed.bottom-0:not([id$="-modal"]) {
    max-width: var(--app-max-width);
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
}

/* Floating cart button - constrained to mobile container */
button[data-cart-button] {
    position: fixed !important;
    bottom: 5.5rem !important;
    z-index: 40 !important;
}

/* Desktop: position relative to centered container */
@media (min-width: 481px) {
    button[data-cart-button] {
        right: calc(50% - var(--app-max-width) / 2 + 1rem) !important;
        left: auto !important;
    }
}

/* Modals and overlays - FULL WIDTH for proper display */
.fixed.inset-0,
[id$="-modal"],
[id$="-panel"] {
    max-width: var(--app-max-width) !important;
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    width: 100% !important;
}

/* Modal inner content - ensure proper width */
[id$="-modal"] > div,
[id$="-panel"] > div {
    width: 100% !important;
    max-width: 100% !important;
}

/* Modal animations */
[id$="-modal"]:not(.hidden) {
    animation: fadeIn 0.2s ease-out;
}

[id$="-modal"]:not(.hidden) > div {
    animation: slideUpModal 0.3s ease-out;
}

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

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

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

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

/* Modal closing state */
.modal-closing {
    animation: fadeOut 0.25s ease-in forwards !important;
}

@media (max-width: 480px) {
    nav.fixed,
    .fixed.top-0,
    .fixed.bottom-0:not([data-cart-button]) {
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        max-width: 100% !important;
    }

    button[data-cart-button] {
        right: 1rem !important;
        left: auto !important;
    }

    .fixed.inset-0,
    [id$="-modal"],
    [id$="-panel"] {
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        max-width: 100% !important;
    }
}

/* ----------------------------------------------------- 
   GLOBAL MICRO-INTERACTIONS
   ----------------------------------------------------- */
*, *::before, *::after {
    transition: background-color 0.2s ease, 
                border-color 0.2s ease, 
                color 0.2s ease, 
                opacity 0.2s ease,
                box-shadow 0.2s ease;
}

/* Elements that need transform transitions */
button, a, .product-card, .card {
    transition: background-color 0.2s ease, 
                border-color 0.2s ease, 
                color 0.2s ease, 
                opacity 0.2s ease,
                transform 0.2s ease,
                box-shadow 0.2s ease;
}

/* ----------------------------------------------------- 
   REUSABLE COMPONENT CLASSES
   ----------------------------------------------------- */

/* Buttons */
.btn-primary {
    background-color: var(--color-primary);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    border: none;
}

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

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: var(--color-gray-100);
    color: var(--color-gray-700);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    border: none;
}

.btn-secondary:hover {
    background-color: var(--color-gray-200);
}

.btn-outline {
    background-color: transparent;
    color: var(--color-primary);
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    border: 2px solid var(--color-primary);
}

.btn-outline:hover {
    background-color: rgba(34, 197, 94, 0.1);
}

/* Cards */
.card {
    background-color: white;
    border-radius: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-gray-100);
}

/* Input Fields */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-gray-300);
    border-radius: 0.75rem;
    font-size: 0.875rem;
    background-color: white;
    min-height: 44px;
}

.input-field:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.input-field.input-error {
    border-color: var(--color-error);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.input-field.input-success {
    border-color: var(--color-success);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

/* ----------------------------------------------------- 
   LOADING STATES
   ----------------------------------------------------- */

/* Loading Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-white {
    border-top-color: white;
}

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

/* Button Loading State */
.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading .btn-text {
    opacity: 0;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-gray-200) 0%,
        var(--color-gray-100) 50%,
        var(--color-gray-200) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

/* ----------------------------------------------------- 
   TYPOGRAPHY
   ----------------------------------------------------- */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Pacifico font for logo/brand */
.font-brand {
    font-family: 'Pacifico', cursive;
}

/* ----------------------------------------------------- 
   REMIX ICON FIX
   ----------------------------------------------------- */
:where([class^="ri-"])::before {
    content: "\f3c2";
}

/* ----------------------------------------------------- 
   LOADING STATES & ANIMATIONS
   ----------------------------------------------------- */

/* Shimmer effect for loading skeletons */
.shimmer {
    background: linear-gradient(
        90deg, 
        var(--color-gray-200) 0%, 
        var(--color-gray-100) 50%, 
        var(--color-gray-200) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Pulse animation */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Fade in animation */
.fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

/* Slide up animation for modals */
.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* Scale animation for buttons */
.scale-press:active {
    transform: scale(0.96);
}

/* ----------------------------------------------------- 
   ORDER STATUS BADGES
   ----------------------------------------------------- */
.status-em-andamento {
    background-color: #fef3c7;
    color: #92400e;
}

.status-entregue {
    background-color: #d1fae5;
    color: #065f46;
}

.status-cancelado {
    background-color: #fee2e2;
    color: #991b1b;
}

/* ----------------------------------------------------- 
   TOAST NOTIFICATIONS
   ----------------------------------------------------- */
.toast-container {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: calc(100% - 2rem);
    max-width: calc(var(--app-max-width) - 2rem);
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 0.75rem;
    padding: 0.875rem 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease-out;
    border-left: 4px solid transparent;
}

.toast-success {
    border-left: 4px solid var(--color-success);
}

.toast-error {
    border-left: 4px solid var(--color-error);
}

.toast-warning {
    border-left: 4px solid var(--color-warning);
}

.toast-info {
    border-left: 4px solid var(--color-info);
}

.toast-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-success .toast-icon {
    background-color: #dcfce7;
    color: var(--color-success);
}

.toast-error .toast-icon {
    background-color: #fee2e2;
    color: var(--color-error);
}

.toast-warning .toast-icon {
    background-color: #fef3c7;
    color: var(--color-warning);
}

.toast-info .toast-icon {
    background-color: #dbeafe;
    color: var(--color-info);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--color-gray-800);
}

.toast-dismiss {
    background: none;
    border: none;
    color: var(--color-gray-400);
    cursor: pointer;
    padding: 4px;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.toast-exit {
    animation: toastSlideOut 0.3s ease-in forwards;
}

/* ----------------------------------------------------- 
   CART BADGE
   ----------------------------------------------------- */
.cart-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--color-error);
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: badgePop 0.3s ease-out;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }
    70% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* ----------------------------------------------------- 
   VOICE RECORDING ANIMATION
   ----------------------------------------------------- */
.voice-recording {
    background-color: var(--color-error);
    border-radius: 50%;
    animation: voicePulse 1s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

/* ----------------------------------------------------- 
   NAVIGATION ACTIVE STATE
   ----------------------------------------------------- */
nav a.active,
nav a[data-active="true"],
nav button.active {
    color: var(--color-primary) !important;
}

nav a.active i,
nav a[data-active="true"] i,
nav button.active i {
    color: var(--color-primary) !important;
}

/* Navigation transition */
nav a, nav button {
    transition: color 0.2s ease;
}

/* ----------------------------------------------------- 
   FORM ELEMENTS
   ----------------------------------------------------- */

/* Custom checkbox styling */
input[type="checkbox"]:checked + div {
    border-color: var(--color-primary);
    background-color: var(--color-primary);
}

input[type="checkbox"]:checked + div i {
    display: block !important;
    color: white !important;
}

/* Custom radio styling */
input[type="radio"]:checked + div {
    border-color: var(--color-primary);
}

input[type="radio"]:checked + div > div {
    display: block !important;
}

/* Range input styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: var(--color-gray-200);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--color-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Toggle switch styling (for notification preferences) */
.peer:checked ~ div {
    background-color: var(--color-primary);
}

/* Focus states */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}

/* Accent buttons - CTA style */
.btn-accent {
    background-color: var(--color-accent);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    font-weight: 600;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s ease;
}

.btn-accent:hover {
    background-color: #E65100;
}

/* ----------------------------------------------------- 
   SCROLLBAR STYLING
   ----------------------------------------------------- */

/* Hide scrollbar for horizontal scroll containers */
.overflow-x-auto::-webkit-scrollbar {
    display: none;
}

.overflow-x-auto {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Custom scrollbar for modal content */
.overflow-y-auto::-webkit-scrollbar {
    width: 4px;
}

.overflow-y-auto::-webkit-scrollbar-track {
    background: transparent;
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background: var(--color-gray-300);
    border-radius: 2px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: var(--color-gray-400);
}

/* ----------------------------------------------------- 
   UTILITY CLASSES
   ----------------------------------------------------- */

/* Safe area padding for notched devices */
.pb-safe {
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

/* Hide on mobile, show on desktop */
.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .desktop-only {
        display: block;
    }
}

/* Hide on desktop, show on mobile */
.mobile-only {
    display: block;
}

@media (min-width: 768px) {
    .mobile-only {
        display: none;
    }
}

/* No select (for buttons and interactive elements) */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Touch action optimization */
.touch-action-pan-y {
    touch-action: pan-y;
}

/* ----------------------------------------------------- 
   BUTTON HOVER EFFECTS
   ----------------------------------------------------- */
button:not(:disabled):hover,
a:not(:disabled):hover {
    transition: all 0.2s ease;
}

.bg-primary:hover {
    background-color: var(--color-primary-hover) !important;
}

/* ----------------------------------------------------- 
   IMAGE LOADING PLACEHOLDER
   ----------------------------------------------------- */
img {
    background-color: var(--color-gray-100);
}

img[src=""],
img:not([src]) {
    background: linear-gradient(
        90deg, 
        var(--color-gray-200) 0%, 
        var(--color-gray-100) 50%, 
        var(--color-gray-200) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* ----------------------------------------------------- 
   MODAL BACKDROP
   ----------------------------------------------------- */
.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

/* ----------------------------------------------------- 
   PRODUCT CARD HOVER EFFECTS
   ----------------------------------------------------- */
.product-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ----------------------------------------------------- 
   PRINT STYLES
   ----------------------------------------------------- */
@media print {
    .app-shell-body {
        background: white !important;
        padding: 0 !important;
    }

    .app-shell {
        box-shadow: none !important;
        border: none !important;
        max-width: 100% !important;
        border-radius: 0 !important;
    }

    nav.fixed,
    .fixed.bottom-6 {
        display: none !important;
    }
}

/* ----------------------------------------------------- 
   RIPPLE EFFECT
   ----------------------------------------------------- */
@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

.ripple {
    position: relative;
    overflow: hidden;
}

/* ----------------------------------------------------- 
   FIELD FEEDBACK
   ----------------------------------------------------- */
.field-feedback {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.75rem;
    color: var(--color-error);
    animation: fadeIn 0.2s ease;
}

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

/* ----------------------------------------------------- 
   SLIDE UP ANIMATION (FOR MODALS)
   ----------------------------------------------------- */
.slide-up {
    animation: slideUp 0.3s ease-out;
}

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

/* ----------------------------------------------------- 
   FAVORITES BADGE
   ----------------------------------------------------- */
.favorites-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: var(--color-primary);
    color: white;
    font-size: 10px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    animation: badgePop 0.3s ease-out;
}

/* ----------------------------------------------------- 
   EMPTY STATE STYLING
   ----------------------------------------------------- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: var(--color-gray-100);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
}

/* ----------------------------------------------------- 
   FOCUS RING FOR ACCESSIBILITY
   ----------------------------------------------------- */
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* ----------------------------------------------------- 
   CHECKBOX & RADIO CUSTOM STYLES
   ----------------------------------------------------- */
input[type="checkbox"]:checked + label,
input[type="radio"]:checked + label {
    color: var(--color-primary);
}

