/**
 * Estilos Compartidos - Herramientas Académicas IPCH
 * Basados en Material Design
 */

:root {
    --md-primary: #A60000;
    --md-primary-dark: #7A0000;
    --md-primary-light: #D32F2F;
    --md-secondary: #03DAC6;
    --md-surface: #FFFFFF;
    --md-background: #FAFAFA;
    --md-error: #B00020;
    --md-on-primary: #FFFFFF;
    --md-on-surface: #000000;
    --md-on-surface-variant: #616161;
}

/* Wrapper principal para todas las herramientas */
.herramientas-ipch-wrapper {
    font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
    background-color: transparent;
    padding: 1rem;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

/* Cards Material Design */
.md-card {
    background: var(--md-surface);
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.08);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.md-card:hover {
    box-shadow: 0 4px 8px rgba(0,0,0,0.12), 0 2px 4px rgba(0,0,0,0.08);
}

/* Botones Material Design */
.md-button {
    background-color: var(--md-primary);
    color: var(--md-on-primary);
    border: none;
    border-radius: 4px;
    padding: 0.875rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.0892857143em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    position: relative;
    overflow: hidden;
    min-width: 64px;
    z-index: 10;
    pointer-events: auto;
}

.md-button:hover:not(:disabled) {
    background-color: var(--md-primary-dark);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.md-button:focus {
    outline: 2px solid var(--md-primary);
    outline-offset: 2px;
}

.md-button:active:not(:disabled) {
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.md-button:disabled {
    background-color: rgba(0,0,0,0.12);
    color: rgba(0,0,0,0.38);
    cursor: not-allowed;
    box-shadow: none;
}

.md-button-secondary {
    background-color: transparent;
    color: var(--md-primary);
    box-shadow: none;
    border: 1px solid var(--md-primary);
}

.md-button-secondary:hover:not(:disabled) {
    background-color: rgba(166, 0, 0, 0.04);
}

.md-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.md-button:active::after {
    width: 300px;
    height: 300px;
}

/* Campos de texto Material Design */
.md-textfield {
    background-color: transparent;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.42);
    border-radius: 0;
    padding: 0.75rem 0.5rem 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    width: 100%;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.md-textfield:focus {
    border-bottom-color: var(--md-primary);
    border-bottom-width: 2px;
    padding-bottom: calc(0.5rem - 1px);
    outline: none;
}

.md-textfield:focus-visible {
    outline: 2px solid var(--md-primary);
    outline-offset: 2px;
}

/* Select Material Design */
.md-select {
    background-color: transparent;
    border: none;
    border-bottom: 1px solid rgba(0,0,0,0.42);
    border-radius: 0;
    padding: 0.75rem 0.5rem 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23626262' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 2rem;
    width: 100%;
    position: relative;
    z-index: 10;
    pointer-events: auto;
}

.md-select:focus {
    border-bottom-color: var(--md-primary);
    border-bottom-width: 2px;
    padding-bottom: calc(0.5rem - 1px);
    outline: none;
}

.md-select:focus-visible {
    outline: 2px solid var(--md-primary);
    outline-offset: 2px;
}

/* Textarea Material Design */
.md-textarea {
    background-color: transparent;
    border: 1px solid rgba(0,0,0,0.42);
    border-radius: 4px;
    padding: 0.75rem;
    font-size: 1rem;
    transition: border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    width: 100%;
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.md-textarea:focus {
    border-color: var(--md-primary);
    border-width: 2px;
    padding: calc(0.75rem - 1px);
    outline: none;
}

.md-textarea:focus-visible {
    outline: 2px solid var(--md-primary);
    outline-offset: 2px;
}

/* Tipografía Material Design */
.md-typography-h1 {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.01em;
    color: var(--md-on-surface);
    text-wrap: balance;
    word-break: break-word;
    hyphens: auto;
}

.md-typography-h5 {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    letter-spacing: 0;
    color: var(--md-on-surface);
}

.md-typography-body1 {
    font-size: clamp(0.85rem, 2.5vw, 1rem);
    font-weight: 400;
    line-height: 1.5;
    letter-spacing: 0.03125em;
    color: var(--md-on-surface);
}

.md-typography-body2 {
    font-size: clamp(0.8rem, 2.5vw, 0.875rem);
    font-weight: 300;
    line-height: 1.4;
    letter-spacing: 0.0178571429em;
    color: var(--md-on-surface-variant);
    text-wrap: balance;
}

/* Descripción de herramientas */
.herramientas-ipch-wrapper .tool-description,
.herramientas-ipch-wrapper p.md-typography-body1[style*="text-align: center"],
.herramientas-ipch-wrapper p.md-typography-body2[style*="text-align: center"] {
    font-weight: 300 !important;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.md-typography-subtitle1 {
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.75rem;
    letter-spacing: 0.009375em;
    color: var(--md-on-surface);
}

.md-typography-caption {
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1rem;
    letter-spacing: 0.0333333333em;
    color: var(--md-on-surface-variant);
}

/* Divider */
.md-divider {
    border: none;
    border-top: 1px solid rgba(0,0,0,0.12);
    margin: 1rem 0;
}

/* Mensajes de error */
.md-error {
    color: var(--md-error);
    font-size: 0.75rem;
    margin-top: 0.5rem;
    min-height: 1.5rem;
}

/* Loader */
.md-loader {
    border: 3px solid rgba(166, 0, 0, 0.2);
    border-left-color: var(--md-primary);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Animaciones */
.md-fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
    border-radius: 4px;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-text {
    height: 1.2em;
    margin: 0.5rem 0;
}

/* Grupos de input */
.input-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: flex-end;
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

.input-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

/* Responsive */
@media (max-width: 600px) {
    .herramientas-ipch-wrapper {
        padding: 0.5rem;
    }
    
    .md-card {
        padding: 1rem;
    }
    
    .md-typography-h1 {
        font-size: 1.1rem;
        line-height: 1.3;
        font-weight: 700;
    }
    
    .md-typography-body1,
    .md-typography-body2 {
        font-size: 0.8rem;
        line-height: 1.3;
    }
    
    .input-group {
        flex-direction: column;
        flex-wrap: wrap;
    }
    
    .input-wrapper {
        flex: 1;
        min-width: 0;
        width: 100%;
    }
    
    .md-button {
        width: 100%;
        margin-top: 1rem;
        flex-shrink: 0;
    }
}

@media (max-width: 400px) {
    .md-typography-h1 {
        font-size: 1rem;
        line-height: 1.25;
    }
    
    .md-typography-body1,
    .md-typography-body2 {
        font-size: 0.75rem;
        line-height: 1.25;
    }
}

@media (min-width: 601px) and (max-width: 960px) {
    .md-card {
        padding: 1.25rem;
    }
    
    .md-typography-h1 {
        font-size: 1.35rem;
    }
}
