/* ============================================
   Raiar - Global Styles
   Plataforma de RSE/ESG para Moçambique
   ============================================ */

/* ============================================
   MOBILE EMULATION FOR DESKTOP
   This app is mobile-only, so on larger screens
   we emulate a mobile viewport centered on screen
   ============================================ */

:root {
    --mobile-width: 375px;
    --mobile-max-width: 480px;
    --primary: #2563eb;
    --secondary: #f59e0b;
}

/* Base reset and font settings */
* {
    box-sizing: border-box;
}

/* Mobile-first responsive layout */
html {
    background-color: #e5e7eb;
    display: flex;
    justify-content: center;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

/* Desktop: Enhanced styling */
@media (min-width: 481px) {
    html {
        background: linear-gradient(135deg, #1e3a5f 0%, #0f172a 100%);
        min-height: 100vh;
    }
    
    body {
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
    }
}

/* Constrain fixed elements to mobile width and center them */
nav.fixed,
.fixed.top-0,
.fixed.bottom-0 {
    max-width: var(--mobile-max-width);
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
}

/* Constrain floating buttons to mobile width */
button.fixed,
a.fixed {
    left: auto !important;
    right: calc(50% - var(--mobile-max-width)/2 + 1rem) !important;
    transform: none !important;
    max-width: none;
}

/* Modals and overlays - full screen but content centered */
.fixed.inset-0 {
    max-width: none !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
}

.fixed.inset-0 > div {
    max-width: var(--mobile-max-width);
    margin: 0 auto;
}

/* Toast notifications */
.toast-notification {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%) !important;
    max-width: calc(var(--mobile-max-width) - 32px);
    width: calc(100% - 32px);
}

/* Mobile: Normal behavior */
@media (max-width: 480px) {
    nav.fixed,
    .fixed.top-0,
    .fixed.bottom-0 {
        left: 0 !important;
        transform: none !important;
    }
    
    button.fixed,
    a.fixed {
        right: 1rem !important;
    }
    
    .toast-notification {
        left: 1rem !important;
        right: 1rem !important;
        transform: none !important;
        max-width: none;
        width: auto;
    }
}

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

/* ============================================
   CUSTOM SELECT DROPDOWN
   ============================================ */
.custom-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 1.3em;
}

/* ============================================
   NUMBER INPUT STYLING
   Remove spinner arrows
   ============================================ */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}

/* ============================================
   TOGGLE SWITCH STYLES
   ============================================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
    background-color: var(--primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* ============================================
   SCROLLBAR STYLING (for desktop view)
   ============================================ */
@media (min-width: 481px) {
    body::-webkit-scrollbar {
        width: 6px;
    }
    
    body::-webkit-scrollbar-track {
        background: #f1f1f1;
    }
    
    body::-webkit-scrollbar-thumb {
        background: var(--primary);
        border-radius: 3px;
    }
    
    body::-webkit-scrollbar-thumb:hover {
        background: #1d4ed8;
    }
}

/* ============================================
   ANIMATION UTILITIES
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}

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

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

/* ============================================
   BUTTON HOVER STATES (for desktop)
   ============================================ */
@media (min-width: 481px) {
    button:not(:disabled):hover,
    a.cursor-pointer:hover {
        opacity: 0.9;
        transition: opacity 0.2s ease;
    }
    
    .bg-primary:hover {
        background-color: #1d4ed8;
    }
    
    .bg-secondary:hover {
        background-color: #d97706;
    }
}

/* ============================================
   CARD HOVER EFFECTS (for desktop)
   ============================================ */
@media (min-width: 481px) {
    .bg-white.rounded-lg.shadow-sm:hover {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
        transition: box-shadow 0.2s ease;
    }
}

/* ============================================
   LOADING SKELETON
   ============================================ */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
}

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

/* ============================================
   SAFE AREA INSETS (for notched devices)
   ============================================ */
@supports (padding: env(safe-area-inset-bottom)) {
    nav.fixed.bottom-0 {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    nav.fixed,
    button.fixed {
        display: none !important;
    }
    
    body {
        max-width: 100%;
        box-shadow: none;
    }
    
    main {
        padding-top: 0 !important;
        padding-bottom: 0 !important;
    }
}
