@import 'tailwindcss';

@custom-variant dark (&:where(.dark, .dark *));

@source '../../vendor/laravel/framework/src/Illuminate/Pagination/resources/views/*.blade.php';
@source '../../storage/framework/views/*.php';
@source '../views/**/*.blade.php';
@source '../js/**/*.js';

@theme {
    --font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';

    --color-brand-50: #effcf5;
    --color-brand-100: #d8f8e6;
    --color-brand-200: #b3efcf;
    --color-brand-300: #7de0ad;
    --color-brand-400: #45c987;
    --color-brand-500: #20ad6b;
    --color-brand-600: #158a55;
    --color-brand-700: #146f47;
    --color-brand-800: #14583b;
    --color-brand-900: #124932;
    --color-brand-950: #072c1d;
}

html {
    color-scheme: light;
}

input[aria-invalid='true'], select[aria-invalid='true'], textarea[aria-invalid='true'] {
    border-color: #ef4444 !important;
    outline-color: #ef4444;
}

input[aria-invalid='true']:focus, select[aria-invalid='true']:focus, textarea[aria-invalid='true']:focus {
    border-color: #dc2626 !important;
    box-shadow: 0 0 0 3px rgb(239 68 68 / 15%);
}

/* Desktop: sidebar fijo respecto al viewport, sin perder scroll en la pantalla principal. */
.agrocloud-shell {
    --agrocloud-sidebar-width: 264px;
}

.agrocloud-sidebar-nav {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

@media (min-width: 1024px) {
    .agrocloud-shell {
        grid-template-columns: var(--agrocloud-sidebar-width) minmax(0, 1fr);
        transition: grid-template-columns 200ms ease;
    }

    .agrocloud-sidebar {
        width: var(--agrocloud-sidebar-width);
        transition: width 200ms ease;
    }

    .agrocloud-shell[data-sidebar-collapsed="true"] {
        --agrocloud-sidebar-width: 76px;
    }

    .agrocloud-shell[data-sidebar-collapsed="true"] [data-sidebar-brand-text],
    .agrocloud-shell[data-sidebar-collapsed="true"] [data-sidebar-label],
    .agrocloud-shell[data-sidebar-collapsed="true"] [data-sidebar-section] {
        display: none;
    }

    .agrocloud-shell[data-sidebar-collapsed="true"] .agrocloud-sidebar-link {
        justify-content: center;
        gap: 0;
    }

    .agrocloud-shell[data-sidebar-collapsed="true"] .agrocloud-sidebar-nav {
        padding-top: 1rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .agrocloud-shell,
    .agrocloud-sidebar {
        transition: none;
    }
}

/*
 * Select nativo con flecha unificada. 18px de margen derecho desde el borde,
 * y espacio reservado para que el texto no se superponga a la flecha.
 * Aplica a los select existentes, incluido ESTADO / ROL.
 */
select:not([multiple]):not([size]) {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 3.25rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23334155' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-position: right 1.125rem center;
    background-size: 1rem 1rem;
    background-repeat: no-repeat;
}

select:not([multiple]):not([size]):disabled {
    cursor: not-allowed;
    opacity: 0.65;
}

@media (forced-colors: active) {
    select:not([multiple]):not([size]) {
        -webkit-appearance: auto;
        appearance: auto;
        background-image: none;
        padding-right: 1rem;
    }
}

/* --- AGROCLOUD DARK MODE: INICIO --- */
/* Tailwind aplica las variantes `dark:` sobre html.dark. */
html.dark {
    color-scheme: dark;
}

/* Superficies principales con profundidad sin negro puro. */
html.dark body {
    background-color: #0f172a;
}

html.dark .agrocloud-sidebar {
    background-color: #111c2e;
}

html.dark ::selection {
    background: #166534;
    color: #f0fdf4;
}

html.dark .agrocloud-sidebar-nav {
    scrollbar-color: #475569 transparent;
}

html.dark .agrocloud-sidebar-nav::-webkit-scrollbar-thumb {
    background-color: #475569;
}

/* El SVG de la flecha del select en app.css usa un color oscuro fijo. */
html.dark select:not([multiple]):not([size]) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

html.dark select option,
html.dark select optgroup {
    background-color: #0f172a;
    color: #f1f5f9;
}

html.dark input::placeholder,
html.dark textarea::placeholder {
    color: #94a3b8;
    opacity: 1;
}

/* Los iconos nativos de calendario y reloj deben verse sobre un input oscuro. */
html.dark input[type='date']::-webkit-calendar-picker-indicator,
html.dark input[type='datetime-local']::-webkit-calendar-picker-indicator,
html.dark input[type='time']::-webkit-calendar-picker-indicator {
    filter: invert(0.85);
}

/* Mejor legibilidad de autofill de Chrome / navegadores Chromium. */
html.dark input:-webkit-autofill,
html.dark input:-webkit-autofill:hover,
html.dark input:-webkit-autofill:focus {
    -webkit-text-fill-color: #f1f5f9;
    -webkit-box-shadow: 0 0 0 1000px #0f172a inset;
    caret-color: #f1f5f9;
}

/* Los botones de tema son accesibles con teclado y muestran el estado elegido. */
[data-theme-option][aria-pressed='true'] {
    background-color: #dcfce7;
    color: #166534;
    font-weight: 600;
}

html.dark [data-theme-option][aria-pressed='true'] {
    background-color: rgba(21, 128, 61, 0.3);
    color: #86efac;
}

@media (forced-colors: active) {
    html.dark select:not([multiple]):not([size]) {
        background-image: none;
    }

    [data-theme-option][aria-pressed='true'] {
        outline: 2px solid Highlight;
        outline-offset: -2px;
    }
}
/* --- AGROCLOUD DARK MODE: FIN --- */

/* Los avisos de búsqueda no deben cambiar el centro vertical de los iconos. */
.relative:has(> [data-search-input]) > svg.absolute {
    top: 1.375rem;
    bottom: auto;
    height: 1rem;
    translate: 0 -50%;
    transform: none;
}

[data-search-input][aria-invalid='true'] {
    border-color: var(--color-red-500);
}

[data-search-input][aria-invalid='true']:focus {
    --tw-ring-color: var(--color-red-100);
}

html.dark [data-search-input][aria-invalid='true']:focus {
    --tw-ring-color: var(--color-red-900);
}


/* Navegación de la landing; respeta la preferencia de movimiento reducido. */
@media (prefers-reduced-motion: no-preference) {
    html:has([data-public-landing]) { scroll-behavior: smooth; }
}
[data-public-landing] a:focus-visible,
[data-public-landing] summary:focus-visible {
    outline: 2px solid var(--color-brand-500);
    outline-offset: 4px;
    border-radius: 0.5rem;
}
