:root {
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-primary: #0066cc;
    --color-primary-dark: #004a99;
    --color-success: #10b981;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --color-border-focus: #3b82f6;
    --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);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    padding: 20px;
}

.container {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

.header {
    background: var(--color-surface);
    padding: 24px 32px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    border-left: 4px solid var(--color-primary);
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.header-meta {
    display: flex;
    gap: 24px;
    margin-top: 12px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    color: var(--color-text-muted);
}

.header-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--color-surface);
    padding: 8px;
    border-radius: 10px;
    box-shadow: var(--shadow-sm);
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-weight: 500;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover {
    background: rgba(0, 102, 204, 0.08);
    color: var(--color-primary);
}

.tab-btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.tab-content {
    display: none;
    background: var(--color-surface);
    padding: 32px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    animation: fadeIn 0.3s;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.form-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.form-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-section h3::before {
    content: '';
    width: 4px;
    height: 16px;
    background: var(--color-primary);
    border-radius: 2px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 6px;
}

.required {
    color: var(--color-danger);
    font-size: 14px;
}

input[type="text"],
input[type="number"],
select,
textarea {
    padding: 10px 14px;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
    background: var(--color-surface);
}

input[type="text"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
    font-family: inherit;
}

.radio-group,
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-option,
.checkbox-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1.5px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--color-surface);
}

.radio-option:hover,
.checkbox-option:hover {
    border-color: var(--color-primary);
    background: rgba(0, 102, 204, 0.03);
}

.radio-option input[type="radio"],
.checkbox-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.conditional-field {
    display: none;
    margin-top: 16px;
    padding: 16px;
    background: rgba(0, 102, 204, 0.04);
    border-left: 3px solid var(--color-primary);
    border-radius: 6px;
    animation: slideDown 0.3s;
}

.conditional-field.visible {
    display: block;
}

.sugerencias-box {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    margin-top: 80px;
    width: calc(100% - 32px);
}

.sugerencias-box.visible {
    display: block;
}

.sugerencia-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.sugerencia-item:hover {
    background: #f0f9ff;
}

.sugerencia-item:last-child {
    border-bottom: none;
}

.sugerencia-match {
    font-weight: 600;
    color: var(--color-primary);
}

/* Dar espacio al campo de intervención para las sugerencias */
#intervencion {
    position: relative;
}

.form-group {
    position: relative;
}

@keyframes slideDown {
    from { opacity: 0; max-height: 0; }
    to { opacity: 1; max-height: 500px; }
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.alert.danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1.5px solid var(--color-danger);
    color: #991b1b;
}

.alert.warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1.5px solid var(--color-warning);
    color: #92400e;
}

.alert::before {
    content: '⚠';
    font-size: 18px;
}

.dose-input {
    display: none;
    margin-top: 8px;
}

.dose-input.visible {
    display: block;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--color-primary-dark);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--color-border);
    color: var(--color-text);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-success {
    background: var(--color-success);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-success:hover {
    background: #059669;
    transform: translateY(-1px);
}

.action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.summary-box {
    background: #f8fafc;
    border: 1.5px solid var(--color-border);
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 13px;
    line-height: 1.7;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.summary-header h4 {
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

.copy-btn {
    padding: 6px 14px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

.copy-btn.copied {
    background: var(--color-success);
}

.json-output {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin-top: 16px;
    font-size: 12px;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    font-family: 'IBM Plex Mono', monospace;
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: #92400e;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: #065f46;
}

.hidden {
    display: none !important;
}

/* Estilos responsive para móvil */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .header {
        padding: 16px 20px;
    }

    .header h1 {
        font-size: 22px;
    }

    .header-meta {
        flex-direction: column;
        gap: 8px;
        font-size: 12px;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab-btn {
        padding: 10px 12px;
        font-size: 13px;
    }

    .form-section {
        padding: 16px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr !important;
    }
}
