/* ============================================
   CSS MEJORADO PARA SISTEMA DE CLÁUSULAS
   - Alta legibilidad y contraste
   - Diseño moderno y profesional
   - Responsive
   ============================================ */

/* VARIABLES DE COLOR - Fácil personalización */
:root {
    /* Colores principales */
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #3b82f6;
    
    /* Colores de estado */
    --success-color: #059669;
    --success-light: #d1fae5;
    --error-color: #dc2626;
    --error-light: #fee2e2;
    --warning-color: #d97706;
    
    /* Grises para legibilidad óptima */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    
    /* Texto */
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;
    
    /* Sombras */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* RESET Y BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 0;
    margin: 0;
    /* REMOVIDO: height, width y padding-left fijos que rompían el layout */
}

/* CONTENEDOR PRINCIPAL */
.container {
    max-width: 900px;
    width: 90%;
    margin: 2rem auto;
    padding: 2rem;
    background-color: white;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

/* NAVEGACIÓN */
nav {
    background: white;
    padding: 1rem 2rem;
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

nav li {
    margin: 0;
}

nav a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    transition: all 0.2s;
    display: inline-block;
}

nav a:hover {
    background-color: var(--gray-100);
    color: var(--primary-color);
}

/* TÍTULOS */
h1 {
    text-align: center;
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

h2 {
    color: var(--text-primary);
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-size: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--gray-200);
}

/* FORMULARIOS */
form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Labels mejorados */
label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Inputs de texto mejorados */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background-color: white;
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    transition: all 0.2s;
    margin-bottom: 0;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:hover,
textarea:hover,
select:hover {
    border-color: var(--gray-600);
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Textarea específico */
textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

/* Select mejorado */
select {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
    padding-right: 2.5rem;
    appearance: none;
}

/* Select múltiple */
select[multiple] {
    min-height: 200px;
    padding-right: 1rem;
    background-image: none;
}

select[multiple] option {
    padding: 0.6rem 0.75rem;
    margin: 2px 0;
    border-radius: 4px;
}

select[multiple] option:checked {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
}

/* BOTONES */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    white-space: nowrap;
}

button[type="submit"],
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    box-shadow: var(--shadow-sm);
}

button[type="submit"]:hover,
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-color));
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

button[type="submit"]:active,
.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background-color: var(--gray-200);
    color: var(--text-primary);
    border: 1px solid var(--gray-300);
}

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

.btn-danger {
    background-color: var(--error-color);
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Grupo de botones */
.button-group {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* ALERTAS Y MENSAJES */
.alert {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid;
}

.alert-success {
    background-color: var(--success-light);
    border-color: var(--success-color);
    color: #065f46;
}

.alert-error {
    background-color: var(--error-light);
    border-color: var(--error-color);
    color: #991b1b;
}

.alert-info {
    background-color: #dbeafe;
    border-color: var(--primary-color);
    color: #1e40af;
}

/* TABLAS */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    margin: 1.5rem 0;
}

table th {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: white;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--gray-200);
}

table tbody tr:hover {
    background-color: var(--gray-50);
}

/* ENLACES */
a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* LISTAS */
ul {
    padding-left: 1.5rem;
}

ul li {
    margin-bottom: 0.5rem;
}

/* HELPER CLASSES */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* FOOTER */
footer {
    background: white;
    padding: 2rem;
    text-align: center;
    margin-top: 3rem;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

footer p {
    color: var(--text-muted);
    margin: 0;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    .container {
        width: 95%;
        padding: 1.5rem;
        margin: 1rem auto;
    }
    
    nav {
        padding: 1rem;
    }
    
    nav ul {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    nav a {
        display: block;
        text-align: center;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    button,
    .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        width: 100%;
        padding: 1rem;
        border-radius: 0;
        margin: 0;
    }
    
    h1 {
        font-size: 1.25rem;
    }
    
    input,
    textarea,
    select {
        font-size: 16px; /* Evita zoom en iOS */
    }
}

/* LOADING SPINNER */
.spinner {
    border: 3px solid var(--gray-200);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* MEJORAS ESPECÍFICAS PARA SELECT MÚLTIPLE */
select[size],
select[multiple] {
    padding: 0.5rem;
}

select[size] option,
select[multiple] option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
}

/* MEJORAS PARA EASYMDE (Editor Markdown) */
.EasyMDEContainer {
    margin-bottom: 1rem;
}

.EasyMDEContainer .CodeMirror {
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 1rem;
}

.EasyMDEContainer .CodeMirror:hover {
    border-color: var(--gray-600);
}

.EasyMDEContainer .CodeMirror-focused {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.editor-toolbar {
    border: 2px solid var(--gray-300);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: white;
}

.editor-toolbar a {
    color: var(--text-primary) !important;
}

.editor-toolbar a:hover,
.editor-toolbar a.active {
    background: var(--gray-100) !important;
    border-color: var(--gray-300) !important;
}

/* MEJORAS PARA CHECKBOX Y RADIO INPUTS */
input[type="checkbox"],
input[type="radio"] {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    margin-right: 0.5rem;
}

/* HR MEJORADO */
hr {
    border: none;
    border-top: 2px solid var(--gray-200);
    margin: 2rem 0;
}
.clausula {
    margin-bottom: 2em;
}

.clausula h2 {
    color: #1f2937;
    font-size: 18pt;
    margin-bottom: 0.5em;
}

.clausula-contenido {
    line-height: 1.5;
}

.clausula table {
    width: 100%;
    border-collapse: collapse;
}

.clausula table td,
.clausula table th {
    border: 1px solid #999;
    padding: 6px;
}