/*
 * SchoolDuos - Main Stylesheet
 * 
 * Este archivo contendrá el CSS compilado de Tailwind CSS.
 * En desarrollo se puede usar el CDN, pero en producción
 * debe compilarse para cumplir con CSP.
 * 
 * Para compilar:
 * npx tailwindcss -i ./static/css/input.css -o ./static/css/main.css --minify
 */

/* ============================================
   Tailwind CSS Base (CDN fallback para desarrollo)
   En producción, esto se reemplaza por el CSS compilado
   ============================================ */

/* Reset básico */
*, *::before, *::after {
    box-sizing: border-box;
}

* {
    margin: 0;
}

html {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    line-height: inherit;
}

/* ============================================
   CSS Variables - Design Tokens
   ============================================ */
:root {
    /* Primary - Se sobrescribe dinámicamente desde el template */
    --color-primary: #2c4a8c;
    --color-primary-light: #4361a8;
    --color-primary-dark: #243c72;
    
    /* Secondary - Se sobrescribe dinámicamente desde el template */
    --color-secondary: #10b981;
    
    /* Gray Scale */
    --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;
    
    /* Semantic Colors */
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-error: #ef4444;
    --color-info: #3b82f6;
    
    /* Spacing */
    --spacing-1: 0.25rem;
    --spacing-2: 0.5rem;
    --spacing-3: 0.75rem;
    --spacing-4: 1rem;
    --spacing-5: 1.25rem;
    --spacing-6: 1.5rem;
    --spacing-8: 2rem;
    --spacing-10: 2.5rem;
    --spacing-12: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* ============================================
   Utility Classes (Tailwind-like)
   ============================================ */

/* Display */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.block { display: block; }
.inline-block { display: inline-block; }
.hidden { display: none; }
.grid { display: grid; }

/* Flexbox */
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }

/* Sizing */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-7xl { max-width: 80rem; }
.h-5 { height: 1.25rem; }
.w-5 { width: 1.25rem; }
.h-8 { height: 2rem; }
.h-14 { height: 3.5rem; }
.h-16 { height: 4rem; }
.h-48 { height: 12rem; }
.w-auto { width: auto; }

/* Spacing - Padding */
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-10 { padding-top: 2.5rem; padding-bottom: 2.5rem; }
.py-12 { padding-top: 3rem; padding-bottom: 3rem; }
.pr-12 { padding-right: 3rem; }

/* Spacing - Margin */
.m-0 { margin: 0; }
.mt-1 { margin-top: 0.25rem; }
.mt-auto { margin-top: auto; }
.mb-1\.5 { margin-bottom: 0.375rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mr-4 { margin-right: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

/* Space between */
.space-y-2 > * + * { margin-top: 0.5rem; }
.space-y-5 > * + * { margin-top: 1.25rem; }

/* Position */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.top-4 { top: 1rem; }
.right-4 { right: 1rem; }
.right-3 { right: 0.75rem; }
.bottom-0 { bottom: 0; }
.bottom-4 { bottom: 1rem; }
.left-6 { left: 1.5rem; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.z-10 { z-index: 10; }
.z-50 { z-index: 50; }
.z-60 { z-index: 60; }

/* Transform */
.top-1\/2 { top: 50%; }
.-translate-y-1\/2 { transform: translateY(-50%); }

/* Typography */
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* Colors - Text */
.text-white { color: #ffffff; }
.text-gray-400 { color: var(--color-gray-400); }
.text-gray-500 { color: var(--color-gray-500); }
.text-gray-600 { color: var(--color-gray-600); }
.text-gray-700 { color: var(--color-gray-700); }
.text-gray-800 { color: var(--color-gray-800); }
.text-red-500 { color: #ef4444; }
.text-red-600 { color: #dc2626; }
.text-red-800 { color: #991b1b; }
.text-green-800 { color: #166534; }
.text-yellow-800 { color: #854d0e; }
.text-blue-800 { color: #1e40af; }
.text-primary-600 { color: var(--color-primary-600); }

/* Colors - Background */
.bg-white { background-color: #ffffff; }
.bg-gray-50 { background-color: var(--color-gray-50); }
.bg-gray-100 { background-color: var(--color-gray-100); }
.bg-red-50 { background-color: #fef2f2; }
.bg-red-100 { background-color: #fee2e2; }
.bg-green-100 { background-color: #dcfce7; }
.bg-yellow-100 { background-color: #fef9c3; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-primary-600 { background-color: var(--color-primary-600); }
.bg-primary-700 { background-color: var(--color-primary-700); }
.\!bg-\[\#f5f7fa\], .bg-\[\#f5f7fa\] { background-color: #f5f7fa; }

/* Border */
.border { border-width: 1px; }
.border-b { border-bottom-width: 1px; }
.border-gray-200 { border-color: var(--color-gray-200); }
.border-red-200 { border-color: #fecaca; }
.border-green-200 { border-color: #bbf7d0; }
.border-yellow-200 { border-color: #fef08a; }
.border-blue-200 { border-color: #bfdbfe; }

/* Border Radius */
.rounded { border-radius: var(--radius-md); }
.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-2xl { border-radius: var(--radius-2xl); }

/* Shadow */
.shadow { box-shadow: var(--shadow-md); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-xl { box-shadow: var(--shadow-xl); }

/* Opacity */
.opacity-90 { opacity: 0.9; }

/* Overflow */
.overflow-hidden { overflow: hidden; }

/* Outline */
.outline-none { outline: 2px solid transparent; outline-offset: 2px; }

/* Transitions */
.transition-colors { 
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; 
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1); 
    transition-duration: 150ms; 
}
.duration-200 { transition-duration: 200ms; }

/* Focus States */
.focus\:border-primary-500:focus { border-color: var(--color-primary-500); }
.focus\:ring-2:focus { 
    --tw-ring-offset-shadow: var(--tw-ring-inset, ) 0 0 0 var(--tw-ring-offset-width, 0px) var(--tw-ring-offset-color, #fff);
    --tw-ring-shadow: var(--tw-ring-inset, ) 0 0 0 calc(2px + var(--tw-ring-offset-width, 0px)) var(--tw-ring-color, currentColor);
    box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
}
.focus\:ring-primary-100:focus { --tw-ring-color: var(--color-primary-100); }
.focus\:ring-primary-500:focus { --tw-ring-color: var(--color-primary-500); }
.focus\:ring-offset-2:focus { --tw-ring-offset-width: 2px; }
.focus\:outline-none:focus { outline: 2px solid transparent; outline-offset: 2px; }

/* Hover States */
.hover\:text-gray-600:hover { color: var(--color-gray-600); }
.hover\:text-gray-700:hover { color: var(--color-gray-700); }
.hover\:text-primary-600:hover { color: var(--color-primary-600); }
.hover\:bg-primary-700:hover { background-color: var(--color-primary-700); }

/* SVG */
svg {
    display: block;
    vertical-align: middle;
}

/* Form Elements */
input, button, textarea, select {
    font-family: inherit;
    font-size: 100%;
    font-weight: inherit;
    line-height: inherit;
    color: inherit;
}

button {
    cursor: pointer;
}

/* ============================================
   Responsive Utilities
   ============================================ */
@media (min-width: 640px) {
    .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
}

@media (min-width: 768px) {
    .md\:p-10 { padding: 2.5rem; }
    .md\:h-64 { height: 16rem; }
}

@media (min-width: 1024px) {
    .lg\:px-8 { padding-left: 2rem; padding-right: 2rem; }
}

/* ============================================
   Custom Components
   ============================================ */

/* Button Primary - usa color dinámico */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1rem;
    font-weight: 500;
    color: white;
    background-color: var(--color-primary);
    border: none;
    border-radius: var(--radius-lg);
    transition: background-color 200ms, transform 100ms;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:focus {
    outline: none;
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--color-primary-light);
}

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

/* Input Field - usa color dinámico en focus */
.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    transition: border-color 150ms, box-shadow 150ms;
    outline: none;
    background-color: white;
}

.input-field:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.input-field.error,
.input-field:invalid:not(:placeholder-shown) {
    border-color: #ef4444;
}

/* Input legacy class */
.input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-gray-200);
    border-radius: var(--radius-lg);
    transition: border-color 150ms, box-shadow 150ms;
    outline: none;
}

.input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.05);
}

.input.error {
    border-color: #ef4444;
}

/* Card */
.card {
    background-color: white;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    padding: 2rem;
}

/* Alert */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-lg);
    font-size: 0.875rem;
}

/* ============================================
   HTMX Loading States
   ============================================ */
.htmx-request .htmx-indicator {
    display: inline-block;
}

.htmx-indicator {
    display: none;
}

.htmx-request.htmx-indicator {
    display: inline-block;
}

/* Loading spinner */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* Skeleton loading */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

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

/* Links sin underline */
.no-underline {
    text-decoration: none !important;
}

a.no-underline:hover {
    text-decoration: none !important;
}

/* Transition shadow */
.transition-shadow {
    transition-property: box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.hover\:shadow-md:hover {
    box-shadow: var(--shadow-md);
}

/* Whitespace */
.whitespace-nowrap {
    white-space: nowrap;
}

/* ============================================
   Grade Input Styles
   Styles for grade inputs with colors based
   on performance level.
   ============================================ */

.grade-input.grade-low {
    background-color: #FEE2E2;
    border-color: #FCA5A5;
    color: #DC2626;
}

.grade-input.grade-basic {
    background-color: #FEF3C7;
    border-color: #FCD34D;
    color: #D97706;
}

.grade-input.grade-high {
    background-color: #D1FAE5;
    border-color: #6EE7B7;
    color: #059669;
}

.grade-input.grade-superior {
    background-color: #DBEAFE;
    border-color: #93C5FD;
    color: #2563EB;
}

.grade-input.grade-invalid {
    background-color: #FEE2E2;
    border-color: #EF4444;
    color: #DC2626;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-4px); }
    75% { transform: translateX(4px); }
}

